From 266a2434f2d357338d8f35eca6f1554cbeac0413 Mon Sep 17 00:00:00 2001 From: Eric Hartmann Date: Tue, 16 May 2017 13:33:25 +0200 Subject: [PATCH] Make Hazelcast test more robust --- .../sonar/application/cluster/HazelcastClusterTest.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/HazelcastClusterTest.java b/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/HazelcastClusterTest.java index cc8a0baab1c..28103e103d8 100644 --- a/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/HazelcastClusterTest.java +++ b/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/HazelcastClusterTest.java @@ -48,6 +48,7 @@ import org.sonar.process.ProcessId; import org.sonar.process.ProcessProperties; import org.sonar.process.cluster.ClusterObjectKeys; +import static junit.framework.TestCase.fail; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.timeout; @@ -169,9 +170,11 @@ public class HazelcastClusterTest { }, false); hzClient.shutdown(); - latch.await(1, TimeUnit.SECONDS); - - assertThat(hzCluster.hzInstance.getSet(ClusterObjectKeys.CLIENT_UUIDS)).isEmpty(); + if (latch.await(5, TimeUnit.SECONDS)) { + assertThat(hzCluster.hzInstance.getSet(ClusterObjectKeys.CLIENT_UUIDS).size()).isEqualTo(0); + } else { + fail("The client UUID have not been removed from the Set within 5 seconds' time lapse"); + } } } -- 2.39.5