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

[Backport 2.x] Fix flaky DecommissionControllerTests.testTimesOut (#4683) (#4688) #5206

Merged
merged 1 commit into from
Nov 10, 2022
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 @@ -8,6 +8,7 @@

package org.opensearch.cluster.decommission;

import org.hamcrest.MatcherAssert;
import org.junit.After;
import org.junit.Before;
import org.opensearch.OpenSearchTimeoutException;
Expand Down Expand Up @@ -45,6 +46,7 @@
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

Expand All @@ -53,6 +55,7 @@
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.sameInstance;
import static org.opensearch.cluster.ClusterState.builder;
import static org.opensearch.cluster.OpenSearchAllocationTestCase.createAllocationService;
Expand Down Expand Up @@ -213,25 +216,28 @@ public void testTimesOut() throws InterruptedException {
nodesToBeRemoved.add(clusterService.state().nodes().get("node13"));
nodesToBeRemoved.add(clusterService.state().nodes().get("node14"));
nodesToBeRemoved.add(clusterService.state().nodes().get("node15"));
final AtomicReference<Exception> exceptionReference = new AtomicReference<>();
decommissionController.removeDecommissionedNodes(
nodesToBeRemoved,
"unit-test-timeout",
TimeValue.timeValueMillis(2),
new ActionListener<Void>() {
TimeValue.timeValueMillis(0),
new ActionListener<>() {
@Override
public void onResponse(Void unused) {
fail("response shouldn't have been called");
countDownLatch.countDown();
}

@Override
public void onFailure(Exception e) {
assertThat(e, instanceOf(OpenSearchTimeoutException.class));
assertThat(e.getMessage(), containsString("waiting for removal of decommissioned nodes"));
exceptionReference.set(e);
countDownLatch.countDown();
}
}
);
assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
MatcherAssert.assertThat("Expected onFailure to be called", exceptionReference.get(), notNullValue());
MatcherAssert.assertThat(exceptionReference.get(), instanceOf(OpenSearchTimeoutException.class));
MatcherAssert.assertThat(exceptionReference.get().getMessage(), containsString("waiting for removal of decommissioned nodes"));
}

public void testSuccessfulDecommissionStatusMetadataUpdate() throws InterruptedException {
Expand Down