From 45e32a40521f54bad9f0fce1c3758def6555d562 Mon Sep 17 00:00:00 2001 From: marc-adaptive Date: Fri, 3 Jan 2025 11:50:29 -0500 Subject: [PATCH] Sole library mode fix engine add accepting engine timeout and decrease test reply timeout --- .../system_tests/SoleLibrarySystemTest.java | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/artio-system-tests/src/test/java/uk/co/real_logic/artio/system_tests/SoleLibrarySystemTest.java b/artio-system-tests/src/test/java/uk/co/real_logic/artio/system_tests/SoleLibrarySystemTest.java index c1108249f2..9b80eeea0d 100644 --- a/artio-system-tests/src/test/java/uk/co/real_logic/artio/system_tests/SoleLibrarySystemTest.java +++ b/artio-system-tests/src/test/java/uk/co/real_logic/artio/system_tests/SoleLibrarySystemTest.java @@ -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; @@ -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) @@ -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 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> libraryInfoReply = initiatingEngine.libraries(); + final Reply> libraryInfoReply = fixEngine.libraries(); assertTrue(libraryInfoReply.hasCompleted()); final List libraryInfo = libraryInfoReply.resultIfPresent(); assertEquals(1, libraryInfo.size());