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 Oct 14, 2023
1 parent 4684ba7 commit 1f8c392
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,17 @@ public void run() {
}

pool.shutdown();
pool.awaitTermination(2000, TimeUnit.MILLISECONDS);
boolean finished = pool.awaitTermination(60, TimeUnit.SECONDS);

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.assertTrue(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 60 seconds");
}
}

@Test
Expand Down

0 comments on commit 1f8c392

Please sign in to comment.