Skip to content

Commit

Permalink
Reduce the chances that successfulCheckTest will fail (#14688)
Browse files Browse the repository at this point in the history
* Reduce the chances that successfulCheckTest will fail

Signed-off-by: Sergii Kabashniuk <skabashniuk@redhat.com>
  • Loading branch information
skabashnyuk committed Sep 30, 2019
1 parent 4e1492b commit 66d7729
Showing 1 changed file with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public class ServerCheckerTest {
private static final String MACHINE_NAME = "mach1";
private static final String SERVER_REF = "ref1";
private static final long PERIOD_MS = 10;
private static final long TIMEOUT_MS = 500;
private static final long CHECKER_TIMEOUT_MS = 5000;
private static final long TEST_TIMEOUT_MS = CHECKER_TIMEOUT_MS + 1000;
private static final int SUCCESS_THRESHOLD = 1;

private Timer timer;
Expand All @@ -45,25 +46,25 @@ public class ServerCheckerTest {
@BeforeMethod
public void setUp() throws Exception {
timer = new Timer(true);
}

@AfterMethod
public void tearDown() throws Exception {
timer.cancel();
}

@Test(timeOut = TEST_TIMEOUT_MS)
public void successfulCheckTest() throws Exception {
checker =
spy(
new TestServerChecker(
MACHINE_NAME,
SERVER_REF,
PERIOD_MS,
TIMEOUT_MS,
CHECKER_TIMEOUT_MS,
SUCCESS_THRESHOLD,
TimeUnit.MILLISECONDS,
timer));
}

@AfterMethod
public void tearDown() throws Exception {
timer.cancel();
}

@Test(timeOut = TIMEOUT_MS)
public void successfulCheckTest() throws Exception {
CompletableFuture<String> reportCompFuture = checker.getReportCompFuture();
// not considered as available before start
assertFalse(reportCompFuture.isDone());
Expand All @@ -83,7 +84,7 @@ public void successfulCheckTest() throws Exception {
verify(checker, atLeast(2)).isAvailable();
}

@Test(timeOut = TIMEOUT_MS)
@Test(timeOut = TEST_TIMEOUT_MS)
public void checkTimeoutTest() throws Exception {
checker =
spy(
Expand Down

0 comments on commit 66d7729

Please sign in to comment.