Skip to content

Fix RareClusterStateIT Publication Cancel #62662

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

Merged
merged 1 commit into from
Sep 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.StreamSupport;

import static java.util.Collections.emptyMap;
import static java.util.Collections.emptySet;
import static org.elasticsearch.action.DocWriteResponse.Result.CREATED;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.hamcrest.Matchers.arrayWithSize;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasSize;
Expand Down Expand Up @@ -142,17 +140,16 @@ private <Req extends ActionRequest, Res extends ActionResponse> ActionFuture<Res
ActionRequestBuilder<Req, Res> req) throws Exception {
// Wait for no publication in progress to not accidentally cancel a publication different from the one triggered by the given
// request.
assertBusy(
() -> {
assertFalse(((Coordinator) internalCluster().getCurrentMasterNodeInstance(Discovery.class)).publicationInProgress());
assertThat(StreamSupport.stream(
internalCluster().getInstances(Discovery.class).spliterator(), false)
.map(coordinator -> ((Coordinator) coordinator).getLastAcceptedState().version())
.distinct().toArray(), arrayWithSize(1));
});
final Coordinator masterCoordinator = (Coordinator) internalCluster().getCurrentMasterNodeInstance(Discovery.class);
assertBusy(() -> {
assertFalse(masterCoordinator.publicationInProgress());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made this whole thing a little less weird to read as well here, the stream + iterator + array size assertion was just weirdly complicated.

final long applierVersion = masterCoordinator.getApplierState().version();
for (Discovery instance : internalCluster().getInstances(Discovery.class)) {
assertEquals(((Coordinator) instance).getApplierState().version(), applierVersion);
}
});
ActionFuture<Res> future = req.execute();
assertBusy(
() -> assertTrue(((Coordinator)internalCluster().getCurrentMasterNodeInstance(Discovery.class)).cancelCommittedPublication()));
assertBusy(() -> assertTrue(masterCoordinator.cancelCommittedPublication()));
return future;
}

Expand Down