@@ -56,12 +56,11 @@ public async Task GivenValidJobs_WhenJobHostingStart_ThenJobsShouldBeExecute()
56
56
57
57
JobHosting jobHosting = new JobHosting ( queueClient , factory , _logger ) ;
58
58
jobHosting . PollingFrequencyInSeconds = 0 ;
59
- jobHosting . MaxRunningJobCount = 5 ;
60
59
61
60
CancellationTokenSource tokenSource = new CancellationTokenSource ( ) ;
62
61
63
62
tokenSource . CancelAfter ( TimeSpan . FromSeconds ( 2 ) ) ;
64
- await jobHosting . ExecuteAsync ( 0 , "test" , tokenSource ) ;
63
+ await jobHosting . ExecuteAsync ( 0 , 5 , "test" , tokenSource ) ;
65
64
66
65
Assert . Equal ( jobCount , executedJobCount ) ;
67
66
foreach ( JobInfo job in jobs )
@@ -121,12 +120,11 @@ public async Task GivenJobWithCriticalException_WhenJobHostingStart_ThenJobShoul
121
120
122
121
JobHosting jobHosting = new JobHosting ( queueClient , factory , _logger ) ;
123
122
jobHosting . PollingFrequencyInSeconds = 0 ;
124
- jobHosting . MaxRunningJobCount = 1 ;
125
123
126
124
CancellationTokenSource tokenSource = new CancellationTokenSource ( ) ;
127
125
128
126
tokenSource . CancelAfter ( TimeSpan . FromSeconds ( 1 ) ) ;
129
- await jobHosting . ExecuteAsync ( 0 , "test" , tokenSource ) ;
127
+ await jobHosting . ExecuteAsync ( 0 , 1 , "test" , tokenSource ) ;
130
128
131
129
Assert . Equal ( 2 , executeCount ) ;
132
130
@@ -163,13 +161,12 @@ public async Task GivenAnCrashJob_WhenJobHostingStart_ThenJobShouldBeRePickup()
163
161
164
162
JobHosting jobHosting = new JobHosting ( queueClient , factory , _logger ) ;
165
163
jobHosting . PollingFrequencyInSeconds = 0 ;
166
- jobHosting . MaxRunningJobCount = 1 ;
167
164
jobHosting . JobHeartbeatTimeoutThresholdInSeconds = 1 ;
168
165
169
166
CancellationTokenSource tokenSource = new CancellationTokenSource ( ) ;
170
167
171
168
tokenSource . CancelAfter ( TimeSpan . FromSeconds ( 2 ) ) ;
172
- await jobHosting . ExecuteAsync ( 0 , "test" , tokenSource ) ;
169
+ await jobHosting . ExecuteAsync ( 0 , 1 , "test" , tokenSource ) ;
173
170
174
171
Assert . Equal ( JobStatus . Completed , job1 . Status ) ;
175
172
Assert . Equal ( 1 , executeCount0 ) ;
@@ -198,12 +195,11 @@ public async Task GivenAnLongRunningJob_WhenJobHostingStop_ThenJobShouldBeComple
198
195
JobInfo job1 = ( await queueClient . EnqueueAsync ( 0 , new string [ ] { "job1" } , null , false , false , CancellationToken . None ) ) . First ( ) ;
199
196
JobHosting jobHosting = new JobHosting ( queueClient , factory , _logger ) ;
200
197
jobHosting . PollingFrequencyInSeconds = 0 ;
201
- jobHosting . MaxRunningJobCount = 1 ;
202
198
jobHosting . JobHeartbeatTimeoutThresholdInSeconds = 1 ;
203
199
204
200
CancellationTokenSource tokenSource = new CancellationTokenSource ( ) ;
205
201
206
- Task hostingTask = jobHosting . ExecuteAsync ( 0 , "test" , tokenSource ) ;
202
+ Task hostingTask = jobHosting . ExecuteAsync ( 0 , 1 , "test" , tokenSource ) ;
207
203
autoResetEvent . WaitOne ( ) ;
208
204
tokenSource . Cancel ( ) ;
209
205
@@ -238,13 +234,12 @@ public async Task GivenJobWithInvalidOperationException_WhenJobHostingStart_Then
238
234
239
235
JobHosting jobHosting = new JobHosting ( queueClient , factory , _logger ) ;
240
236
jobHosting . PollingFrequencyInSeconds = 0 ;
241
- jobHosting . MaxRunningJobCount = 1 ;
242
237
jobHosting . JobHeartbeatTimeoutThresholdInSeconds = 1 ;
243
238
244
239
CancellationTokenSource tokenSource = new CancellationTokenSource ( ) ;
245
240
246
241
tokenSource . CancelAfter ( TimeSpan . FromSeconds ( 2 ) ) ;
247
- await jobHosting . ExecuteAsync ( 0 , "test" , tokenSource ) ;
242
+ await jobHosting . ExecuteAsync ( 0 , 1 , "test" , tokenSource ) ;
248
243
249
244
Assert . Equal ( JobStatus . Failed , job1 . Status ) ;
250
245
Assert . Equal ( 1 , executeCount0 ) ;
@@ -276,12 +271,11 @@ public async Task GivenJobWithCanceledException_WhenJobHostingStart_ThenJobShoul
276
271
277
272
JobHosting jobHosting = new JobHosting ( queueClient , factory , _logger ) ;
278
273
jobHosting . PollingFrequencyInSeconds = 0 ;
279
- jobHosting . MaxRunningJobCount = 1 ;
280
274
jobHosting . JobHeartbeatTimeoutThresholdInSeconds = 15 ;
281
275
282
276
CancellationTokenSource tokenSource = new CancellationTokenSource ( ) ;
283
277
tokenSource . CancelAfter ( TimeSpan . FromSeconds ( 2 ) ) ;
284
- await jobHosting . ExecuteAsync ( 0 , "test" , tokenSource ) ;
278
+ await jobHosting . ExecuteAsync ( 0 , 1 , "test" , tokenSource ) ;
285
279
286
280
Assert . Equal ( JobStatus . Cancelled , job1 . Status ) ;
287
281
Assert . Equal ( 1 , executeCount0 ) ;
@@ -313,11 +307,10 @@ public async Task GivenJobRunning_WhenCancel_ThenJobShouldBeCancelled()
313
307
JobHosting jobHosting = new JobHosting ( queueClient , factory , _logger ) ;
314
308
jobHosting . PollingFrequencyInSeconds = 0 ;
315
309
jobHosting . JobHeartbeatIntervalInSeconds = 1 ;
316
- jobHosting . MaxRunningJobCount = 1 ;
317
310
318
311
CancellationTokenSource tokenSource = new CancellationTokenSource ( ) ;
319
312
tokenSource . CancelAfter ( TimeSpan . FromSeconds ( 2 ) ) ;
320
- Task hostingTask = jobHosting . ExecuteAsync ( 0 , "test" , tokenSource ) ;
313
+ Task hostingTask = jobHosting . ExecuteAsync ( 0 , 1 , "test" , tokenSource ) ;
321
314
322
315
autoResetEvent . WaitOne ( ) ;
323
316
await queueClient . CancelJobByGroupIdAsync ( 0 , job1 . GroupId , CancellationToken . None ) ;
@@ -392,13 +385,12 @@ public async Task GivenRandomFailuresInQueueClient_WhenStartHosting_ThenAllTasks
392
385
393
386
var jobHosting = new JobHosting ( queueClient , factory , _logger ) ;
394
387
jobHosting . PollingFrequencyInSeconds = 0 ;
395
- jobHosting . MaxRunningJobCount = 10 ;
396
388
jobHosting . JobHeartbeatIntervalInSeconds = 0.001 ;
397
389
jobHosting . JobHeartbeatTimeoutThresholdInSeconds = 1 ;
398
390
399
391
var tokenSource = new CancellationTokenSource ( ) ;
400
392
tokenSource . CancelAfter ( TimeSpan . FromSeconds ( 60 ) ) ;
401
- var host = Task . Run ( async ( ) => await jobHosting . ExecuteAsync ( 0 , "test" , tokenSource ) ) ;
393
+ var host = Task . Run ( async ( ) => await jobHosting . ExecuteAsync ( 0 , 10 , "test" , tokenSource ) ) ;
402
394
while ( jobs . Where ( t => t . Status == JobStatus . Completed ) . Count ( ) < numberOfJobs && ! tokenSource . IsCancellationRequested )
403
395
{
404
396
await Task . Delay ( TimeSpan . FromSeconds ( 1 ) ) ;
0 commit comments