@@ -284,17 +284,13 @@ public function hasMaxRetryDuration() {
284
284
285
285
/**
286
286
* @test
287
- * @testWith [{"retryCount": 1, "shouldHaveFailed": false}]
288
- * [{"retryCount": 2, "shouldHaveFailed": false}]
289
- * [{"retryCount": 2, "travelSeconds": 29, "shouldHaveFailed": false}]
290
- * [{"retryCount": 2, "travelSeconds": 31, "shouldHaveFailed": true}]
287
+ * @dataProvider whenIsJobFailingProvider
291
288
*/
292
289
public function job_max_attempts_is_ignored_if_has_retry_until ($ example )
293
290
{
294
291
// Arrange
295
292
$ this ->request ->headers ->add (['X-CloudTasks-TaskRetryCount ' => $ example ['retryCount ' ]]);
296
293
297
- $ now = Carbon::now ()->getTimestamp ();
298
294
if (array_key_exists ('travelSeconds ' , $ example )) {
299
295
Carbon::setTestNow (Carbon::now ()->addSeconds ($ example ['travelSeconds ' ]));
300
296
}
@@ -346,6 +342,105 @@ public function getFirstAttempt() {
346
342
}
347
343
}
348
344
345
+ public function whenIsJobFailingProvider ()
346
+ {
347
+ $ this ->createApplication ();
348
+
349
+ // 8.x behavior: if retryUntil, only check that.
350
+ // 6.x behavior: if retryUntil, check that, otherwise check maxAttempts
351
+
352
+ // max retry count is 3
353
+ // max retryUntil is 30 seconds
354
+
355
+ if (version_compare (app ()->version (), '8.0.0 ' , '>= ' )) {
356
+ return [
357
+ [
358
+ [
359
+ 'retryCount ' => 1 ,
360
+ 'shouldHaveFailed ' => false ,
361
+ ],
362
+ ],
363
+ [
364
+ [
365
+ 'retryCount ' => 2 ,
366
+ 'shouldHaveFailed ' => false ,
367
+ ],
368
+ ],
369
+ [
370
+ [
371
+ 'retryCount ' => 1 ,
372
+ 'travelSeconds ' => 29 ,
373
+ 'shouldHaveFailed ' => false ,
374
+ ],
375
+ ],
376
+ [
377
+ [
378
+ 'retryCount ' => 1 ,
379
+ 'travelSeconds ' => 31 ,
380
+ 'shouldHaveFailed ' => true ,
381
+ ],
382
+ ],
383
+ [
384
+ [
385
+ 'retryCount ' => 1 ,
386
+ 'travelSeconds ' => 32 ,
387
+ 'shouldHaveFailed ' => true ,
388
+ ],
389
+ ],
390
+ [
391
+ [
392
+ 'retryCount ' => 1 ,
393
+ 'travelSeconds ' => 31 ,
394
+ 'shouldHaveFailed ' => true ,
395
+ ],
396
+ ],
397
+ ];
398
+ }
399
+
400
+ return [
401
+ [
402
+ [
403
+ 'retryCount ' => 1 ,
404
+ 'shouldHaveFailed ' => false ,
405
+ ],
406
+ ],
407
+ [
408
+ [
409
+ 'retryCount ' => 2 ,
410
+ 'shouldHaveFailed ' => true ,
411
+ ],
412
+ ],
413
+ [
414
+ [
415
+ 'retryCount ' => 1 ,
416
+ 'travelSeconds ' => 29 ,
417
+ 'shouldHaveFailed ' => false ,
418
+ ],
419
+ ],
420
+ [
421
+ [
422
+ 'retryCount ' => 1 ,
423
+ 'travelSeconds ' => 31 ,
424
+ 'shouldHaveFailed ' => true ,
425
+ ],
426
+ ],
427
+ [
428
+ [
429
+ 'retryCount ' => 1 ,
430
+ 'travelSeconds ' => 32 ,
431
+ 'shouldHaveFailed ' => true ,
432
+ ],
433
+ ],
434
+ [
435
+ [
436
+ 'retryCount ' => 1 ,
437
+ 'travelSeconds ' => 32 ,
438
+ 'shouldHaveFailed ' => true ,
439
+ ],
440
+ ],
441
+ ];
442
+ }
443
+
349
444
private function simpleJob ()
350
445
{
351
446
return json_decode (file_get_contents (__DIR__ . '/Support/test-job-payload.json ' ), true );
0 commit comments