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

Fix open/close race in ConnectionManagerTests #50621

Merged
merged 6 commits into from
Jan 8, 2020

Conversation

Tim-Brooks
Copy link
Contributor

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 conenction attempts. This commit
fixes the test, by returning a unique connection for each attempt.
@Tim-Brooks Tim-Brooks added >test Issues or PRs that are addressing/adding tests :Distributed Coordination/Network Http and internode communication implementations v8.0.0 v7.6.0 labels Jan 3, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (:Distributed/Network)

Copy link
Contributor

@DaveCTurner DaveCTurner left a 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.

doAnswer(invocationOnMock -> {
Transport.Connection connection = new TestConnect(node);
Copy link
Contributor

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?

Copy link
Contributor

@DaveCTurner DaveCTurner left a 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);
Copy link
Contributor

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();
Copy link
Contributor

Choose a reason for hiding this comment

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

== false ☠️

Copy link
Contributor

@DaveCTurner DaveCTurner left a 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

@Tim-Brooks Tim-Brooks merged commit 31b21e5 into elastic:master Jan 8, 2020
Tim-Brooks added a commit that referenced this pull request Jan 14, 2020
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.
SivagurunathanV pushed a commit to SivagurunathanV/elasticsearch that referenced this pull request Jan 23, 2020
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.
@Tim-Brooks Tim-Brooks deleted the fix_connection_manager_test branch April 30, 2020 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Network Http and internode communication implementations >test Issues or PRs that are addressing/adding tests v7.6.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CI] ConnectionManagerTests.testConcurrentConnectsAndDisconnects timed out
4 participants