Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky Windows build #616

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -79,7 +79,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 @@ -136,7 +136,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
Loading