Skip to content

Commit

Permalink
Move test to persistent sequence numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-adaptive committed Aug 29, 2024
1 parent 4513120 commit 02bab7c
Showing 1 changed file with 6 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
import uk.co.real_logic.artio.builder.*;
import uk.co.real_logic.artio.decoder.*;
import uk.co.real_logic.artio.engine.SessionInfo;
import uk.co.real_logic.artio.engine.framer.LibraryInfo;
import uk.co.real_logic.artio.library.FixLibrary;
import uk.co.real_logic.artio.messages.*;
import uk.co.real_logic.artio.messages.DisconnectReason;
import uk.co.real_logic.artio.messages.InitialAcceptedSessionOwner;
import uk.co.real_logic.artio.messages.SessionReplyStatus;
import uk.co.real_logic.artio.messages.ThrottleConfigurationStatus;
import uk.co.real_logic.artio.session.Session;
import uk.co.real_logic.artio.session.SessionWriter;
import uk.co.real_logic.artio.util.MutableAsciiBuffer;

import java.io.IOException;
Expand All @@ -54,7 +55,8 @@
import static uk.co.real_logic.artio.messages.InitialAcceptedSessionOwner.ENGINE;
import static uk.co.real_logic.artio.messages.InitialAcceptedSessionOwner.SOLE_LIBRARY;
import static uk.co.real_logic.artio.messages.ThrottleConfigurationStatus.OK;
import static uk.co.real_logic.artio.system_tests.AbstractGatewayToGatewaySystemTest.*;
import static uk.co.real_logic.artio.system_tests.AbstractGatewayToGatewaySystemTest.LONG_TEST_TIMEOUT_IN_MS;
import static uk.co.real_logic.artio.system_tests.AbstractGatewayToGatewaySystemTest.TEST_TIMEOUT_IN_MS;
import static uk.co.real_logic.artio.system_tests.FixConnection.BUFFER_SIZE;
import static uk.co.real_logic.artio.system_tests.MessageBasedInitiatorSystemTest.assertConnectionDisconnects;
import static uk.co.real_logic.artio.system_tests.SystemTestUtil.*;
Expand Down Expand Up @@ -607,70 +609,6 @@ public void shouldSupportLogonBasedSequenceNumberResetWithMessagesSentBeforeLogo
});
}

@Test(timeout = TEST_TIMEOUT_IN_MS)
public void shouldSupportFollowerSessionLogonWithoutSequenceResetOnDisconnectBeforeLibraryLogonResponse()
throws IOException
{
setup(false, true);
setupLibrary();

final List<SessionInfo> noSessionContext = engine.allSessions();
assertEquals(0, noSessionContext.size());

final SessionWriter sessionWriter = createFollowerSession(
TEST_TIMEOUT_IN_MS, testSystem, library, INITIATOR_ID, ACCEPTOR_ID);
final SessionReplyStatus requestSessionReply = requestSession(library, sessionWriter.id(), testSystem);
assertEquals(SessionReplyStatus.OK, requestSessionReply);

try (FixConnection connection = FixConnection.initiate(port))
{
connection.logon(true);
Timing.assertEventuallyTrue("Library did not transition session to connected",
() ->
{
library.poll(1);
final List<Session> sessions = library.sessions();
return sessions.size() == 1 && sessions.get(0).state() == SessionState.CONNECTED;
}
);
}

Timing.assertEventuallyTrue("Fix connection was not disconnected",
() ->
{
final Reply<List<LibraryInfo>> libraryReply = engine.libraries();
while (!libraryReply.hasCompleted())
{
sleep(500);
}

final List<LibraryInfo> allLibraryInfo = libraryReply.resultIfPresent();
for (final LibraryInfo libraryInfo : allLibraryInfo) {
if (libraryInfo.libraryId() == libraryId) {
return libraryInfo.sessions().isEmpty();
}
}
return false;
}
);

Timing.assertEventuallyTrue("Library did not transition session to active",
() ->
{
library.poll(1);
final List<Session> sessions = library.sessions();
return sessions.size() == 1 && sessions.get(0).state() == SessionState.ACTIVE;
}
);

assertEngineSubscriptionCaughtUpToLibraryPublication(
testSystem, mediaDriver.mediaDriver().aeronDirectoryName(), engine, library);

final List<SessionInfo> sessionContextAfterLogonNoSenderEndpoint = engine.allSessions();
assertEquals(1, sessionContextAfterLogonNoSenderEndpoint.size());
assertEquals(0, sessionContextAfterLogonNoSenderEndpoint.get(0).sequenceIndex());
}

@Test(timeout = TEST_TIMEOUT_IN_MS)
public void shouldHandleOnlineResetFollowedByDisconnectAndRestart() throws IOException
{
Expand Down

0 comments on commit 02bab7c

Please sign in to comment.