]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-20725 - Increase timeout time for thread testing
authorantoine.vinot <antoine.vinot@sonarsource.com>
Fri, 13 Oct 2023 13:11:55 +0000 (15:11 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 16 Oct 2023 20:02:36 +0000 (20:02 +0000)
server/sonar-process/src/test/java/org/sonar/process/AbstractStopperThreadTest.java

index 80720dbebcfc65860bf5ea9bac0ac027a9eb4c82..a8b4dd35531c5bd51911edab431f8aaaccfd54ff 100644 (file)
 package org.sonar.process;
 
 import java.util.concurrent.TimeUnit;
+import org.awaitility.core.ConditionTimeoutException;
 import org.junit.Test;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
 import static org.awaitility.Awaitility.await;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.mock;
@@ -72,7 +74,15 @@ public class AbstractStopperThreadTest {
     verify(monitored, timeout(3_000)).hardStop();
 
     stopper.stopIt();
-    await().atMost(3, TimeUnit.SECONDS).until(() -> !stopper.isAlive());
-    assertThat(stopper.isAlive()).isFalse();
+
+    int timeout = 10;
+    try {
+      await()
+        .atMost(timeout, TimeUnit.SECONDS)
+        .until(() -> !stopper.isAlive());
+    } catch (ConditionTimeoutException conditionTimeoutException) {
+      fail(String.format("Thread was still alive after %d seconds.", timeout));
+    }
+
   }
 }