-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Fix open/close race in ConnectionManagerTests #50621
Fix open/close race in ConnectionManagerTests #50621
Conversation
Currently we reuse the same test connection for all connection attempts in the testConcurrentConnectsAndDisconnects test. This means that if the connection fails due to a pre-existing connection, the connection will be closed impacting the state of all conenction attempts. This commit fixes the test, by returning a unique connection for each attempt.
Pinging @elastic/es-distributed (:Distributed/Network) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I left a few small extra requests.
server/src/test/java/org/elasticsearch/transport/ConnectionManagerTests.java
Outdated
Show resolved
Hide resolved
doAnswer(invocationOnMock -> { | ||
Transport.Connection connection = new TestConnect(node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we keep track of all of these connections and assert that all but one of them has been closed when the dust has settled?
server/src/test/java/org/elasticsearch/transport/ConnectionManagerTests.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test failure looks relevant - see comment. Also could you even out the probabilities of the branches in the ConnectionValidator
too?
|
||
// Only a single connection attempt should be open. | ||
long size = connections.stream().filter(c -> !c.isClosed()).count(); | ||
assertEquals(1, size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I misled you, this can be zero if all 10 connection attempts fail.
@@ -198,6 +207,16 @@ public void testConcurrentConnectsAndDisconnects() throws BrokenBarrierException | |||
}); | |||
|
|||
assertEquals(10, nodeConnectedCount.get() + nodeFailureCount.get()); | |||
|
|||
// Only a single connection attempt should be open. | |||
long size = connections.stream().filter(c -> !c.isClosed()).count(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
== false
☠️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks for the extra iterations TIm
Currently we reuse the same test connection for all connection attempts in the testConcurrentConnectsAndDisconnects test. This means that if the connection fails due to a pre-existing connection, the connection will be closed impacting the state of all connection attempts. This commit fixes the test, by returning a unique connection for each attempt. Fixes #49903.
Currently we reuse the same test connection for all connection attempts in the testConcurrentConnectsAndDisconnects test. This means that if the connection fails due to a pre-existing connection, the connection will be closed impacting the state of all connection attempts. This commit fixes the test, by returning a unique connection for each attempt. Fixes elastic#49903.
Currently we reuse the same test connection for all connection attempts
in the testConcurrentConnectsAndDisconnects test. This means that if the
connection fails due to a pre-existing connection, the connection will
be closed impacting the state of all connection attempts. This commit
fixes the test, by returning a unique connection for each attempt.
Fixes #49903.