From: antoine.vinot Date: Fri, 13 Oct 2023 13:11:55 +0000 (+0200) Subject: SONAR-20725 - Increase timeout time for thread testing X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e5cff5fff7b15432a104b182b25f941ad3877bfe;p=sonarqube.git SONAR-20725 - Increase timeout time for thread testing --- diff --git a/server/sonar-process/src/test/java/org/sonar/process/AbstractStopperThreadTest.java b/server/sonar-process/src/test/java/org/sonar/process/AbstractStopperThreadTest.java index 80720dbebcf..a8b4dd35531 100644 --- a/server/sonar-process/src/test/java/org/sonar/process/AbstractStopperThreadTest.java +++ b/server/sonar-process/src/test/java/org/sonar/process/AbstractStopperThreadTest.java @@ -20,9 +20,11 @@ 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)); + } + } }