Skip to content

Commit

Permalink
Sole library mode fix engine add accepting engine timeout and decreas…
Browse files Browse the repository at this point in the history
…e test reply timeout
  • Loading branch information
marc-adaptive committed Jan 3, 2025
1 parent 23fa141 commit 45e32a4
Showing 1 changed file with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import uk.co.real_logic.artio.library.FixLibrary;
import uk.co.real_logic.artio.library.LibraryConfiguration;
import org.junit.Test;
import uk.co.real_logic.artio.messages.SessionState;
import uk.co.real_logic.artio.session.Session;

import java.util.List;

Expand Down Expand Up @@ -56,7 +54,6 @@ private void launch(final boolean logMessages, final boolean useScheduler)

final EngineConfiguration acceptingConfig = acceptingConfig(port, ACCEPTOR_ID, INITIATOR_ID, nanoClock)
.deleteLogFileDirOnStart(true)
.replyTimeoutInMs(120_000)
.initialAcceptedSessionOwner(SOLE_LIBRARY);

if (useScheduler)
Expand Down Expand Up @@ -219,21 +216,33 @@ public void shouldInitiatingLibraryDisconnectSessionOnLibraryTimeout()
testSystem.remove(initiatingLibrary);
awaitLibraryDisconnect(initiatingEngine, testSystem);

assertEventuallyTrue("Accepting library did not recognize disconnected session",
() ->
{
testSystem.poll();
final List<Session> sessions = acceptingLibrary.sessions();
assertEquals(1, sessions.size());
final Session session = sessions.get(0);
assertEquals(SessionState.DISCONNECTED, session.state());
}
);
assertSessionDisconnected(acceptingSession);
assertDisconnectedLibraryAndConnection("Initiating Engine did not disconnect session", initiatingEngine);
}

assertEventuallyTrue("Initiating Engine did not disconnect session",
@Test(timeout = TEST_TIMEOUT_IN_MS)
public void shouldAcceptingLibraryDisconnectSessionOnLibraryTimeout()
{
// Equivalent invariant tested in Engine mode in NoLoggingGatewayToGatewaySystemTest
launch(false, false);

connectAndAcquire();
acceptingMessagesCanBeExchanged();

// timeout acceptingLibrary
testSystem.remove(acceptingLibrary);
awaitLibraryDisconnect(acceptingEngine, testSystem);

assertSessionDisconnected(initiatingSession);
assertDisconnectedLibraryAndConnection("Accepting Engine did not disconnect session", acceptingEngine);
}

private static void assertDisconnectedLibraryAndConnection(final String message, final FixEngine fixEngine)
{
assertEventuallyTrue(message,
() ->
{
final Reply<List<LibraryInfo>> libraryInfoReply = initiatingEngine.libraries();
final Reply<List<LibraryInfo>> libraryInfoReply = fixEngine.libraries();
assertTrue(libraryInfoReply.hasCompleted());
final List<LibraryInfo> libraryInfo = libraryInfoReply.resultIfPresent();
assertEquals(1, libraryInfo.size());
Expand Down

0 comments on commit 45e32a4

Please sign in to comment.