[ 
https://issues.apache.org/jira/browse/CASSANDRA-16607?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17323947#comment-17323947
 ] 

Andres de la Peña edited comment on CASSANDRA-16607 at 4/16/21, 5:15 PM:
-------------------------------------------------------------------------

It seems that the problem is that since CASSANDRA-12653 
{{MockMessagingSpy#mockedMessageResponses}} is increased asynchronously by 
[this 
thread|https://github.com/apache/cassandra/blob/trunk/test/unit/org/apache/cassandra/net/MatcherResponse.java#L185-L198].
 Because of this the value of {{mockedMessageResponses}} can be checked before 
it has been increased by the thread, causing the reported failure. While the 
test doesn't fail very often, the failure can be easily reproduced by manually 
adding a sleep in the aforementioned thread.

The proposed PRs simply use {{spinAssertEquals}} to wait for the writer thread. 
Also, I think there could be thread safety issues when increasing 
{{mockedMessageResponses}} from different threads, so I'm making it an 
{{AtomicInteger}}.

CI for 3.11:
 * 
[CircleCI|https://app.circleci.com/pipelines/github/adelapena/cassandra/275/workflows/8be80b18-c168-478d-ae1d-7cb5c04d4b9d]
 * [Multiplexer 
MockMessagingServiceTest|https://jenkins-dse.build.dsinternal.org/view/Parameterized/job/parameterized-testall/805/]
 * [Multiplexer 
ShadowRoundTest|https://jenkins-dse.build.dsinternal.org/view/Parameterized/job/parameterized-testall/807/]

CI for trunk:
 * [CircleCI 
j8|https://app.circleci.com/pipelines/github/adelapena/cassandra/276/workflows/f95f3503-1471-492a-ab86-13b7cd9fded2]
 * [CircleCI 
j11|https://app.circleci.com/pipelines/github/adelapena/cassandra/275/workflows/8be80b18-c168-478d-ae1d-7cb5c04d4b9d]
 * [Multiplexer 
MockMessagingServiceTest|https://jenkins-dse.build.dsinternal.org/view/Parameterized/job/parameterized-testall/806/]
 * [Multiplexer 
ShadowRoundTest|https://jenkins-dse.build.dsinternal.org/view/Parameterized/job/parameterized-testall/808/]


was (Author: adelapena):
It seems that the problem is that since CASSANDRA-12653 
{{MockMessagingSpy#mockedMessageResponses}} is increased asynchronously by 
[this 
thread|https://github.com/apache/cassandra/blob/trunk/test/unit/org/apache/cassandra/net/MatcherResponse.java#L185-L198].
 Because of this the value of {{mockedMessageResponses}} can be checked before 
it has been increased by the thread, causing the reported failure.

The proposed PRs simply use {{spinAssertEquals}} to wait for the writer thread. 
Also, I think there could be thread safety issues when increasing 
{{mockedMessageResponses}} from different threads, so I'm making it an 
{{AtomicInteger}}.

CI for 3.11:
 * 
[CircleCI|https://app.circleci.com/pipelines/github/adelapena/cassandra/275/workflows/8be80b18-c168-478d-ae1d-7cb5c04d4b9d]
 * [Multiplexer 
MockMessagingServiceTest|https://jenkins-dse.build.dsinternal.org/view/Parameterized/job/parameterized-testall/805/]
 * [Multiplexer 
ShadowRoundTest|https://jenkins-dse.build.dsinternal.org/view/Parameterized/job/parameterized-testall/807/]

CI for trunk:
 * [CircleCI 
j8|https://app.circleci.com/pipelines/github/adelapena/cassandra/276/workflows/f95f3503-1471-492a-ab86-13b7cd9fded2]
 * [CircleCI 
j11|https://app.circleci.com/pipelines/github/adelapena/cassandra/275/workflows/8be80b18-c168-478d-ae1d-7cb5c04d4b9d]
 * [Multiplexer 
MockMessagingServiceTest|https://jenkins-dse.build.dsinternal.org/view/Parameterized/job/parameterized-testall/806/]
 * [Multiplexer 
ShadowRoundTest|https://jenkins-dse.build.dsinternal.org/view/Parameterized/job/parameterized-testall/808/]

> Fix flaky test testRequestResponse – 
> org.apache.cassandra.net.MockMessagingServiceTest
> --------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-16607
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-16607
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Test/unit
>            Reporter: David Capwell
>            Assignee: Andres de la Peña
>            Priority: Normal
>             Fix For: 3.11.11, 4.0-rc
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> https://ci-cassandra.apache.org/blue/organizations/jenkins/Cassandra-devbranch/detail/Cassandra-devbranch/659/tests/
> {code}
> Error
> expected:<1> but was:<0>
> Stacktrace
> junit.framework.AssertionFailedError: expected:<1> but was:<0>
>       at 
> org.apache.cassandra.net.MockMessagingServiceTest.testRequestResponse(MockMessagingServiceTest.java:81)
>       at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> Standard Output
> INFO  [main] 2021-04-15 08:22:46,838 YamlConfigurationLoader.java:93 - 
> Configuration location: 
> file:/home/cassandra/cassandra/test/conf/cassandra.yaml
> DEBUG [main] 2021-04-15 08:22:46,840 YamlConfigurationLoader.java:112 - 
> Loading settings from file:/home/cassandra/cassandra/test/conf/cassandra.yaml
> DEBUG [main] 2021-04-15 08:22:46,899 InternalLoggerFactory.java:63 - Using 
> SLF4J as the default logging framework
> DEBUG [main] 2021-04-15 08:22:46,911 PlatformDependent0.java:417 - 
> -Dio.netty.noUnsaf
> ...[truncated 61235 chars]...
> te NORMAL, token [a57d4b7f61f49471614b7ac41f16477e]
> DEBUG [main] 2021-04-15 08:22:49,840 StorageService.java:2674 - New node 
> /127.0.0.1:7069 at token a57d4b7f61f49471614b7ac41f16477e
> DEBUG [main] 2021-04-15 08:22:49,848 StorageService.java:2727 - Node 
> /127.0.0.1:7069 state NORMAL, token [a57d4b7f61f49471614b7ac41f16477e]
> INFO  [main] 2021-04-15 08:22:49,848 StorageService.java:2730 - Node 
> /127.0.0.1:7069 state jump to NORMAL
> DEBUG [main] 2021-04-15 08:22:49,849 StorageService.java:1619 - NORMAL
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to