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

Fixing flaky tests #517

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Next Next commit
fixing inderterminism in FIXP session disconnect timeout test
lucianoviana committed Oct 21, 2024
commit ac1fb4db1a5fd86c469e43f0829854e92ff4f064
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@
import uk.co.real_logic.artio.session.Session;

import java.io.IOException;
import java.time.Duration;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.LockSupport;
@@ -402,13 +403,15 @@ public void shouldDisconnectIfNegotiateTimeout() throws IOException
{
setupArtio(TEST_NO_LOGON_DISCONNECT_TIMEOUT_IN_MS, 1);

final long timeInMs = System.currentTimeMillis();
// taking from the same clock used by the framer which gives more accuracy
final long timeInNs = nanoClock.nanoTime();
try (BinaryEntryPointClient client = newClient())
{
client.assertDisconnected();
final long durationInMs = System.currentTimeMillis() - timeInMs;
final long acceptableLowerBoundInMs = TEST_NO_LOGON_DISCONNECT_TIMEOUT_IN_MS - TIMEOUT_EPSILON_IN_MS;
assertThat(durationInMs, Matchers.greaterThanOrEqualTo(acceptableLowerBoundInMs));
final long acceptableLowerBoundInMs = Duration.ofMillis(TEST_NO_LOGON_DISCONNECT_TIMEOUT_IN_MS)
.minusMillis(TIMEOUT_EPSILON_IN_MS).toNanos();
final long durationInNs = nanoClock.nanoTime() - timeInNs;
assertThat(durationInNs, Matchers.greaterThanOrEqualTo(acceptableLowerBoundInMs));
}

// Test that we can still establish the connection after this
@@ -1333,6 +1336,7 @@ private void shouldPruneAwayOldArchivePositions(

exchangeOverASegmentOfMessages(finishSending);

testSystem.await("connection is still on", () -> !connection.isConnected());
resetOp.reset();

assertPruneWorks();
@@ -1391,6 +1395,7 @@ private void exchangeOverASegmentOfMessages(final boolean finishSending) throws
acceptorInitiatedFinishSending(client, overASegmentOfMessages);
}
}
assertConnectionDisconnected();
}

// ----------------------------------