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

Cleanup Transport*VotingConfigExclusionsActionTests #98146

Conversation

alyokaz
Copy link
Contributor

@alyokaz alyokaz commented Aug 2, 2023

This pull request fixes #98057

The assertions have been moved into the handlers where they can be, and the calls to countDownLatch.await() as been replaced by safeAwait.

Attempting to replace TransportResponseHandler with ActionListenerResponseHandler seems to be less concise due to the need to implement an ActionListener for its constructor, which then requires the introduction of a new method to keep things DRY.

@elasticsearchmachine elasticsearchmachine added needs:triage Requires assignment of a team area label v8.10.0 external-contributor Pull request authored by a developer outside the Elasticsearch team labels Aug 2, 2023
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.

Thanks for the contribution @alyokaz; I left one comment inline. Also to close #98057 you'd have to do the same thing to TransportClearVotingConfigExclusionsActionTests. Finally, would you merge the latest main and fix up the compile errors?

@@ -170,11 +168,11 @@ public void testWithdrawsVoteFromANode() throws InterruptedException {
})
);

assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
safeAwait(countDownLatch);
assertThat(clusterService.getClusterApplierService().state().getVotingConfigExclusions(), contains(otherNode1Exclusion));
Copy link
Contributor

Choose a reason for hiding this comment

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

You've moved some of the assertions about the current state into the success handler - I would slightly prefer them all to move, but whichever way we go I'd rather we were consistent.

Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is still outstanding.

Copy link
Contributor Author

@alyokaz alyokaz Aug 4, 2023

Choose a reason for hiding this comment

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

Apologies, I had just taken a quick look at the merge conflicts, I hadn't meant to give impression I had addressed the issues you raised. I should have made my intentions more explicit.

I was keeping some of the assertions outside the handler because I'd, superficially, made the assumption the handler must be being called twice in order to decrement the CountDownLatch twice, so the assertion would need to be outside the handler to prevent it being called twice also. I can see this isn't the case now, so have moved the remaining assertions as well.

@DaveCTurner DaveCTurner self-assigned this Aug 2, 2023
@DaveCTurner DaveCTurner added :Distributed Coordination/Cluster Coordination Cluster formation and cluster state publication, including cluster membership and fault detection. >test Issues or PRs that are addressing/adding tests and removed needs:triage Requires assignment of a team area label labels Aug 2, 2023
@elasticsearchmachine elasticsearchmachine added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label Aug 2, 2023
@elasticsearchmachine
Copy link
Collaborator

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

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.

Thanks for the updates @alyokaz, however this now doesn't even compile (or pass ./gradlew precommit).

@@ -170,11 +168,11 @@ public void testWithdrawsVoteFromANode() throws InterruptedException {
})
);

assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
safeAwait(countDownLatch);
assertThat(clusterService.getClusterApplierService().state().getVotingConfigExclusions(), contains(otherNode1Exclusion));
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is still outstanding.

Move assertions into success handlers.
Replace call to await on CoundDownLatch with safeAwait.
@alyokaz alyokaz force-pushed the refactor-98057-clean-up-transport-voting-config-exclusion-action-tests branch from 725ac65 to 7b2b127 Compare August 4, 2023 21:08
@alyokaz
Copy link
Contributor Author

alyokaz commented Aug 4, 2023

I've ran ./gradlew precommit, fixed the violations and rebased the branch on to main.

@alyokaz alyokaz requested a review from DaveCTurner August 4, 2023 21:11
@DaveCTurner
Copy link
Contributor

@elasticmachine test this please

@DaveCTurner DaveCTurner dismissed their stale review August 6, 2023 09:17

all comments addressed

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 @alyokaz

@DaveCTurner DaveCTurner merged commit 29059e6 into elastic:main Aug 6, 2023
@alyokaz
Copy link
Contributor Author

alyokaz commented Aug 8, 2023

Happy to contribute @DaveCTurner, thanks for the review

DaveCTurner added a commit to DaveCTurner/elasticsearch that referenced this pull request Aug 17, 2023
The docs for this API say the following:

> If the API fails, you can safely retry it. Only a successful response
> guarantees that the node has been removed from the voting
> configuration and will not be reinstated.

Unfortunately this isn't true today: if the request adds no exclusions
then we do not wait before responding. This commit makes the API wait
until all exclusions are really applied.

Backport of elastic#98386, plus the test changes from elastic#98146 and elastic#98356.
elasticsearchmachine pushed a commit that referenced this pull request Aug 17, 2023
The docs for this API say the following:

> If the API fails, you can safely retry it. Only a successful response
> guarantees that the node has been removed from the voting
> configuration and will not be reinstated.

Unfortunately this isn't true today: if the request adds no exclusions
then we do not wait before responding. This commit makes the API wait
until all exclusions are really applied.

Backport of #98386, plus the test changes from #98146 and #98356.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Cluster Coordination Cluster formation and cluster state publication, including cluster membership and fault detection. external-contributor Pull request authored by a developer outside the Elasticsearch team Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. >test Issues or PRs that are addressing/adding tests v8.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up Transport*VotingConfigExclusionsActionTests
3 participants