Skip to content

Commit 9e0632c

Browse files
authored
[churn] Attempt to fix flaky StatusTrackerTest (#4347)
* attempt to fix flaky StatusTrackerTest Error: redis.clients.jedis.mcf.StatusTrackerTest.testWaitForHealthStatus_EventDriven -- Time elapsed: 0.130 s <<< FAILURE! org.opentest4j.AssertionFailedError: Listener should have been registered ==> expected: not <null> .. at redis.clients.jedis.mcf.StatusTrackerTest.testWaitForHealthStatus_EventDriven(StatusTrackerTest.java:78) * foramt
1 parent b02eb1f commit 9e0632c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/test/java/redis/clients/jedis/mcf/StatusTrackerTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static org.mockito.Mockito.*;
55
import static org.awaitility.Awaitility.await;
66

7+
import java.time.Duration;
78
import java.util.concurrent.CountDownLatch;
89
import java.util.concurrent.TimeUnit;
910
import java.util.concurrent.atomic.AtomicReference;
@@ -71,11 +72,9 @@ void testWaitForHealthStatus_EventDriven() throws InterruptedException {
7172
});
7273
waitingThread.start();
7374

74-
// Give some time for the listener to be registered
75-
Thread.sleep(50);
75+
await().atMost(Duration.ofMillis(100L)).pollInterval(Duration.ofMillis(5L)).untilAsserted(
76+
() -> assertNotNull(capturedListener[0], "Listener should have been registered"));
7677

77-
// Simulate health status change event
78-
assertNotNull(capturedListener[0], "Listener should have been registered");
7978
HealthStatusChangeEvent event = new HealthStatusChangeEvent(testEndpoint, HealthStatus.UNKNOWN,
8079
HealthStatus.HEALTHY);
8180
capturedListener[0].onStatusChange(event);

0 commit comments

Comments
 (0)