From 9a6d146d06319142a8b86ca8912b6ae93a81587d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=A6=E7=94=B0=20=E6=86=B2=E5=A4=AA=E9=83=8E?= Date: Sat, 7 Oct 2023 17:50:27 +0900 Subject: [PATCH] Fix timing sensitive flaky test --- .../Queue/ThrottlesExceptionsWithRedisTest.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/Integration/Queue/ThrottlesExceptionsWithRedisTest.php b/tests/Integration/Queue/ThrottlesExceptionsWithRedisTest.php index 87a7af68a22c..358d0a8b2513 100644 --- a/tests/Integration/Queue/ThrottlesExceptionsWithRedisTest.php +++ b/tests/Integration/Queue/ThrottlesExceptionsWithRedisTest.php @@ -10,6 +10,7 @@ use Illuminate\Queue\CallQueuedHandler; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\Middleware\ThrottlesExceptionsWithRedis; +use Illuminate\Support\Carbon; use Illuminate\Support\Str; use Mockery as m; use Orchestra\Testbench\TestCase; @@ -23,6 +24,8 @@ protected function setUp(): void parent::setUp(); $this->setUpRedis(); + + Carbon::setTestNow(now()); } protected function tearDown(): void @@ -31,6 +34,8 @@ protected function tearDown(): void $this->tearDownRedis(); + Carbon::setTestNow(); + m::close(); } @@ -38,10 +43,7 @@ public function testCircuitIsOpenedForJobErrors() { $this->assertJobWasReleasedImmediately(CircuitBreakerWithRedisTestJob::class, $key = Str::random()); $this->assertJobWasReleasedImmediately(CircuitBreakerWithRedisTestJob::class, $key); - - retry(2, function () use ($key) { - $this->assertJobWasReleasedWithDelay(CircuitBreakerWithRedisTestJob::class, $key); - }); + $this->assertJobWasReleasedWithDelay(CircuitBreakerWithRedisTestJob::class, $key); } public function testCircuitStaysClosedForSuccessfulJobs() @@ -57,10 +59,7 @@ public function testCircuitResetsAfterSuccess() $this->assertJobRanSuccessfully(CircuitBreakerWithRedisSuccessfulJob::class, $key); $this->assertJobWasReleasedImmediately(CircuitBreakerWithRedisTestJob::class, $key); $this->assertJobWasReleasedImmediately(CircuitBreakerWithRedisTestJob::class, $key); - - retry(2, function () use ($key) { - $this->assertJobWasReleasedWithDelay(CircuitBreakerWithRedisTestJob::class, $key); - }); + $this->assertJobWasReleasedWithDelay(CircuitBreakerWithRedisTestJob::class, $key); } protected function assertJobWasReleasedImmediately($class, $key)