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

Test cleanup #524

Merged
merged 9 commits into from
Oct 17, 2024
Merged

Test cleanup #524

merged 9 commits into from
Oct 17, 2024

Conversation

lucianoviana
Copy link
Contributor

No description provided.


return acceptor
.receivedMessage("2")
.anyMatch((message) -> msgSeqNo == Integer.parseInt(message.get(Constants.MSG_SEQ_NUM)));

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note test

Potential uncaught 'java.lang.NumberFormatException'.

return acceptor
.receivedMessage("2")
.anyMatch((message) -> msgSeqNo == Integer.parseInt(message.get(Constants.MSG_SEQ_NUM)));

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException

Potential uncaught 'java.lang.NumberFormatException'.
@@ -89,6 +90,8 @@ public final class BinaryEntryPointClient implements AutoCloseable
private long keepAliveIntervalInMs = KEEP_ALIVE_INTERVAL_IN_MS;
private CancelOnDisconnectType cancelOnDisconnectType = DO_NOT_CANCEL_ON_DISCONNECT_OR_TERMINATE;
private long codTimeoutWindow = DeltaInMillisEncoder.timeNullValue();
private static final OtfHeaderDecoder OTF_HEADER_DECODER = new OtfHeaderDecoder(
BinaryEntryPointProtocol.loadSbeIr().headerStructure());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this instead of a regular MessageHeaderDecoder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what the JsonPrinter.print method uses. I've just reproduced the issue and it happens when we run shouldDisconnectConnectionWhenOutOfRangeTemplateIdUsed() test with FIX_TEST log tag enabled.

@@ -332,8 +335,15 @@ private void print(final UnsafeBuffer unsafeReadBuffer, final String prefixStrin
if (DebugLogger.isEnabled(FIX_TEST))
{
final StringBuilder sb = new StringBuilder();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move into the if too.

@@ -216,7 +216,7 @@ private void assertTriggersCancelOnDisconnect(final long logoutTimeInNs)
assertEquals(onlySession.key(), result.context.key());
final long timeoutTakenInNs = result.timeInNs - logoutTimeInNs;
assertThat(timeoutTakenInNs, greaterThanOrEqualTo(codTimeoutInNs));
assertEquals(1, timeoutHandler.invokeCount());
testSystem.await("timeoutHandler.invokeCount() is not 1", () -> 1 == timeoutHandler.invokeCount());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this fails you will lose the actual invokeCount.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as I said privately I'd prefer refactoring this await method later on as it's being used in a bunch of tests - for now i'm just reusing it.

static void assertReceivedResendRequest(
final TestSystem testSystem, final FakeOtfAcceptor acceptor, final int msgSeqNo)
{
assertEventuallyTrue("Failed to received heartbeat",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

receive resend request

}
libraries.forEach((library) -> library.poll(LIBRARY_LIMIT));
final int result = resultInvokeFramer + libraries.stream().mapToInt((library) ->
library.poll(LIBRARY_LIMIT)).sum();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not use streams here.

@@ -53,6 +53,7 @@

public class TestSystem
{
final ExecutorService executor = Executors.newSingleThreadExecutor();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private

@@ -1134,6 +1147,16 @@ private void exchangeMessagesAroundARestart(
assertSequenceFromInitToAcceptAt(expectedInitToAccSeqNum, expectedAccToInitSeqNum);
}

// this means a resend request will be sent by the acceptor
if (initialSentSequenceNumber > expectedAccToInitSeqNum)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't you comparing sequence numbers across two different directions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeh - am fixing the logic - thx

@lucianoviana lucianoviana force-pushed the testCleanup branch 2 times, most recently from 8e4f925 to fbed143 Compare October 15, 2024 08:28
static void assertReceivedResendRequest(
final TestSystem testSystem, final FakeOtfAcceptor acceptor, final int msgSeqNo)
{
assertEventuallyTrue("Failed to receive resent request",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resend

 - returning workCount and trySend result to improve debugging
- SlowConsumerTest.sendMessage call is now protected against back pressure as it's now wrapped around a awaitSend call.
-fixing BinaryEntryPointClient call to jsonPrint when FIX_TEST is enabled
-cancelOnDisconnect test was using wrong assumption on logout time
@lucianoviana lucianoviana merged commit a54a713 into real-logic:master Oct 17, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants