Skip to content

Commit

Permalink
Merge pull request #617 from tilln/fix/flaky-windows-build-next
Browse files Browse the repository at this point in the history
Fix flaky Windows build
  • Loading branch information
ar authored Sep 16, 2024
2 parents 1d2c0e8 + 0babf20 commit 722ce85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions jpos/src/test/java/org/jpos/space/TSpaceTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void testExpiration() {
sp.out("testExpiration_Key", "ABC", 50);
assertEquals("ABC", sp.rdp("testExpiration_Key"));
try {
Thread.sleep(60);
Thread.sleep(75); // allow for low system timer accuracy
} catch (InterruptedException e) {
}
assertNull(sp.rdp("testExpiration_Key"), "ABC");
Expand Down Expand Up @@ -137,7 +137,7 @@ public void testGC() throws Exception {
sp.out("testGC_Key", "XYZ", 50);
assertEquals("ABC", sp.rdp("testGC_Key"));
try {
Thread.sleep(60);
Thread.sleep(75); // allow for low system timer accuracy
} catch (InterruptedException e) {
}
assertEquals("testGC_Key", sp.getKeysAsString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,24 @@ public void testSingleThread () throws Exception {
ThroughputControl tc = new ThroughputControl (2, 1000);
Instant start = Instant.now();
assertTrue (tc.control() == 0L, "Control should return 0L");
// Allow for low system timer accuracy via a tolerance of 25 milliseconds either way:
assertTrue (
Duration.between(start, Instant.now()).toMillis() < 1000L,
Duration.between(start, Instant.now()).toMillis() < 1000L + 25L,
"Elapsed time should be less than one second"
);
tc.control();
assertTrue (
Duration.between(start, Instant.now()).toMillis() < 1000L,
Duration.between(start, Instant.now()).toMillis() < 1000L + 25L,
"Elapsed time should still be less than one second"
);
tc.control();
assertTrue (
Duration.between(start, Instant.now()).toMillis() > 1000L,
Duration.between(start, Instant.now()).toMillis() > 1000L - 25L,
"Elapsed time should be greater than one second"
);
tc.control();
assertTrue (
Duration.between(start, Instant.now()).toMillis() < 2000L,
Duration.between(start, Instant.now()).toMillis() < 2000L - 25L,
"second transaction should be less than two seconds"
);
}
Expand Down

0 comments on commit 722ce85

Please sign in to comment.