Skip to content

Commit

Permalink
fix: fix flakiness in test MessageIdFactoryTest#testDefaultDomainInPa…
Browse files Browse the repository at this point in the history
…rallel
  • Loading branch information
simonh5 committed Sep 26, 2023
1 parent 4684ba7 commit 6de7273
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,18 @@ public void run() {
}

pool.shutdown();
pool.awaitTermination(2000, TimeUnit.MILLISECONDS);
boolean finished = pool.awaitTermination(1, TimeUnit.HOURS);

int total = threads * messagesPerThread;
if (finished) {
int total = threads * messagesPerThread;

Assert.assertEquals("Not all threads completed in time.", total, ids.size());
Assert.assertEquals(true, ids.contains(String.format("default-parallel-c0a81f9e-403215-%s", total - 1)));
Assert.assertEquals(String.format("default-parallel-c0a81f9e-403215-%s", total), factory.getNextId());
}
Assert.assertEquals("Not all threads completed in time.", total, ids.size());
Assert.assertEquals(true, ids.contains(String.format("default-parallel-c0a81f9e-403215-%s", total - 1)));
Assert.assertEquals(String.format("default-parallel-c0a81f9e-403215-%s", total), factory.getNextId());
} else {
Assert.fail("Threads did not finish in 1 hour");
}
}

@Test
public void testGivenDomainInParallel() throws Exception {
Expand Down

0 comments on commit 6de7273

Please sign in to comment.