[
https://issues.apache.org/jira/browse/CASSANDRA-16949?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17767895#comment-17767895
]
Jacek Lewandowski commented on CASSANDRA-16949:
-----------------------------------------------
This test is weird.
Looking at the script:
{code:java}
client.connect(address, port);
assertTrue(client.isConnected());
// Only install the transform after protocol negotiation is complete
controller.withPayloadTransform(transform);
for (int i = 0; i < messageCount; i++)
client.send(envelopeProvider.apply(i));
client.awaitResponses();
// Client has disconnected
assertFalse(client.isConnected());
// But before it did, it sent an error response
Envelope received = client.inboundMessages.poll();
assertNotNull(received); // <----------------------- ERROR
Message.Response response =
Message.responseDecoder().decode(client.channel, received);
{code}
We can see that we first wait for the error message, then expect the connection
to be closed, and eventually, we read the message asserting its content.
So, the first thing is that {{client.awaitResponses()}} awaits two messages and
returns regardless of whether it is successful. Only one message is being sent
- the error message, so the statement always times out. Irrespective of whether
the server completes its job or not, we expect the client to be disconnected -
it is enough to add a small sleep in the {{ExceptionHandlers}} before the
connection should be closed and the test starts to fail at
{{assertFalse(client.isConnected())}}. Eventually - we test it with networking,
and since we only make sure that the error message is sent before the
connection is closed, we cannot guarantee the order of events will be retained
on the client side. It is even more apparent in real deployments.
So, if I'm not wrong, the expectation that the client receives and processes
the error message before closing the connection without expecting any ack from
the client does not make sense. If we want to verify that such a message is
sent before closing the connection on the server side, we should implement the
test differently - assert that the message was sent rather than received.
Otherwise, if we expect the client to process the error message before closing
the connection, we should expect some ack from the client before the server
closes the connection.
[~dcapwell] wdyt ?
> Fix flaky test org.apache.cassandra.transport.CQLConnectionTest
> ---------------------------------------------------------------
>
> Key: CASSANDRA-16949
> URL: https://issues.apache.org/jira/browse/CASSANDRA-16949
> Project: Cassandra
> Issue Type: Bug
> Components: Test/unit
> Reporter: David Capwell
> Priority: Normal
> Fix For: 5.x
>
>
> https://app.circleci.com/pipelines/github/dcapwell/cassandra/1037/workflows/c728d370-49b9-41aa-bdfb-8c41cf0355d8/jobs/6577/parallel-runs/3
> {code}
> [junit-timeout] Testsuite: org.apache.cassandra.transport.CQLConnectionTest
> [junit-timeout] Testsuite: org.apache.cassandra.transport.CQLConnectionTest
> Tests run: 9, Failures: 4, Errors: 0, Skipped: 0, Time elapsed: 12.926 sec
> [junit-timeout]
> [junit-timeout] Testcase:
> handleCorruptionOfLargeMessageFrame(org.apache.cassandra.transport.CQLConnectionTest):
> FAILED
> [junit-timeout] null
> [junit-timeout] junit.framework.AssertionFailedError
> [junit-timeout] at
> org.apache.cassandra.transport.CQLConnectionTest.testFrameCorruption(CQLConnectionTest.java:484)
> [junit-timeout] at
> org.apache.cassandra.transport.CQLConnectionTest.testFrameCorruption(CQLConnectionTest.java:446)
> [junit-timeout] at
> org.apache.cassandra.transport.CQLConnectionTest.handleCorruptionOfLargeMessageFrame(CQLConnectionTest.java:217)
> [junit-timeout] at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> [junit-timeout] at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> [junit-timeout] at
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> [junit-timeout]
> [junit-timeout]
> [junit-timeout] Testcase:
> testNegativeEnvelopeBodySize(org.apache.cassandra.transport.CQLConnectionTest):
> FAILED
> [junit-timeout] expected:<[]0L> but was:<[52424]0L>
> [junit-timeout] junit.framework.AssertionFailedError: expected:<[]0L> but
> was:<[52424]0L>
> [junit-timeout] at
> java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
> [junit-timeout] at
> java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> [junit-timeout] at
> java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> [junit-timeout] at
> org.apache.cassandra.transport.CQLConnectionTest$AllocationObserver.lambda$verifier$0(CQLConnectionTest.java:850)
> [junit-timeout] at
> org.apache.cassandra.transport.CQLConnectionTest.testFrameCorruption(CQLConnectionTest.java:492)
> [junit-timeout] at
> org.apache.cassandra.transport.CQLConnectionTest.testFrameCorruption(CQLConnectionTest.java:446)
> [junit-timeout] at
> org.apache.cassandra.transport.CQLConnectionTest.testNegativeEnvelopeBodySize(CQLConnectionTest.java:326)
> [junit-timeout] at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> [junit-timeout] at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> [junit-timeout] at
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> [junit-timeout]
> [junit-timeout]
> [junit-timeout] Testcase:
> testUnrecoverableMessageDecodingErrors(org.apache.cassandra.transport.CQLConnectionTest):
> FAILED
> [junit-timeout] expected:<[]0L> but was:<[52424]0L>
> [junit-timeout] junit.framework.AssertionFailedError: expected:<[]0L> but
> was:<[52424]0L>
> [junit-timeout] at
> java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
> [junit-timeout] at
> java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> [junit-timeout] at
> java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> [junit-timeout] at
> org.apache.cassandra.transport.CQLConnectionTest$AllocationObserver.lambda$verifier$0(CQLConnectionTest.java:850)
> [junit-timeout] at
> org.apache.cassandra.transport.CQLConnectionTest.testFrameCorruption(CQLConnectionTest.java:492)
> [junit-timeout] at
> org.apache.cassandra.transport.CQLConnectionTest.testUnrecoverableMessageDecodingErrors(CQLConnectionTest.java:392)
> [junit-timeout] at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> [junit-timeout] at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> [junit-timeout] at
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> [junit-timeout]
> [junit-timeout]
> [junit-timeout] Testcase:
> testRecoverableEnvelopeDecodingErrors(org.apache.cassandra.transport.CQLConnectionTest):
> FAILED
> [junit-timeout] null
> [junit-timeout] junit.framework.AssertionFailedError
> [junit-timeout] at
> org.apache.cassandra.transport.CQLConnectionTest.runTest(CQLConnectionTest.java:430)
> [junit-timeout] at
> org.apache.cassandra.transport.CQLConnectionTest.testEnvelopeDecodingErrors(CQLConnectionTest.java:292)
> [junit-timeout] at
> org.apache.cassandra.transport.CQLConnectionTest.testRecoverableEnvelopeDecodingErrors(CQLConnectionTest.java:264)
> [junit-timeout] at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> [junit-timeout] at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> [junit-timeout] at
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> [junit-timeout]
> [junit-timeout]
> [junit-timeout] Test org.apache.cassandra.transport.CQLConnectionTest FAILED
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]