Skip to content

Commit

Permalink
fix intermittency in GatewayPublicationTest
Browse files Browse the repository at this point in the history
GatewayPublicationTest > testSavingMessagesOverTermBoundary(int) > [11] 1315 FAILED
    org.opentest4j.AssertionFailedError: failed to save message: -2
        at app//org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:38)
        at app//org.junit.jupiter.api.Assertions.fail(Assertions.java:138)
        at app//uk.co.real_logic.artio.protocol.GatewayPublicationTest.testSavingMessagesOverTermBoundary(GatewayPublicationTest.java:98)
  • Loading branch information
wojciech-adaptive committed Jan 8, 2025
1 parent 07ce02c commit d138075
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.agrona.concurrent.NoOpIdleStrategy;
import org.agrona.concurrent.SystemEpochNanoClock;
import org.agrona.concurrent.UnsafeBuffer;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import uk.co.real_logic.artio.messages.DisconnectReason;
Expand Down Expand Up @@ -38,6 +39,7 @@ static IntStream bodyLengthRange()
);
}

@Timeout(2)
@ParameterizedTest
@MethodSource("bodyLengthRange")
void testSavingMessagesOverTermBoundary(final int bodyLength)
Expand Down Expand Up @@ -74,8 +76,7 @@ void testSavingMessagesOverTermBoundary(final int bodyLength)
ThreadLocalRandom.current().nextBytes(body);
final DirectBuffer srcBuffer = new UnsafeBuffer(body);

int attempt = 1;
do
while (true)
{
final long result = gatewayPublication.saveMessage(
srcBuffer,
Expand All @@ -93,13 +94,11 @@ void testSavingMessagesOverTermBoundary(final int bodyLength)
{
break;
}
if (attempt >= 2)
if (Thread.currentThread().isInterrupted())
{
fail("failed to save message: " + result);
}
attempt++;
}
while (true);

final MessageCapturingProtocolHandler protocolHandler = new MessageCapturingProtocolHandler();
final ProtocolSubscription protocolSubscription = ProtocolSubscription.of(protocolHandler);
Expand Down

0 comments on commit d138075

Please sign in to comment.