Skip to content

Commit eaa0d92

Browse files
authored
Use test cluster exclusive in CancellableTasksIT (#67058)
testRemoveBanParentsOnDisconnect disconnects some nodes and leaves the cluster in an unhealthy state, which fails other tests. We can reconnect nodes after that test. However, this commit chooses to run this suite test-cluster exclusive instead because it is simpler and more stable. Closes #6652
1 parent 31cf058 commit eaa0d92

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksIT.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
import org.elasticsearch.transport.TransportResponseHandler;
6161
import org.elasticsearch.transport.TransportService;
6262
import org.junit.After;
63-
import org.junit.Before;
6463

6564
import java.io.IOException;
6665
import java.util.ArrayList;
@@ -83,6 +82,7 @@
8382
import static org.hamcrest.Matchers.hasSize;
8483
import static org.hamcrest.Matchers.instanceOf;
8584

85+
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST)
8686
public class CancellableTasksIT extends ESIntegTestCase {
8787

8888
static int idGenerator = 0;
@@ -91,15 +91,6 @@ public class CancellableTasksIT extends ESIntegTestCase {
9191
static final Map<TestRequest, CountDownLatch> beforeExecuteLatches = ConcurrentCollections.newConcurrentMap();
9292
static final Map<TestRequest, CountDownLatch> completedLatches = ConcurrentCollections.newConcurrentMap();
9393

94-
@Before
95-
public void resetTestStates() {
96-
idGenerator = 0;
97-
beforeSendLatches.clear();
98-
arrivedLatches.clear();
99-
beforeExecuteLatches.clear();
100-
completedLatches.clear();
101-
}
102-
10394
@After
10495
public void ensureAllBansRemoved() throws Exception {
10596
assertBusy(() -> {
@@ -150,7 +141,7 @@ static Set<TestRequest> allowPartialRequest(TestRequest request) throws Exceptio
150141
beforeSendLatches.get(req).countDown();
151142
}
152143
for (TestRequest req : sentRequests) {
153-
arrivedLatches.get(req).await();
144+
assertTrue(arrivedLatches.get(req).await(60, TimeUnit.SECONDS));
154145
}
155146
Set<TestRequest> completedRequests = new HashSet<>();
156147
for (TestRequest req : randomSubsetOf(sentRequests)) {
@@ -163,7 +154,7 @@ static Set<TestRequest> allowPartialRequest(TestRequest request) throws Exceptio
163154
beforeExecuteLatches.get(req).countDown();
164155
}
165156
for (TestRequest req : completedRequests) {
166-
completedLatches.get(req).await();
157+
assertTrue(completedLatches.get(req).await(60, TimeUnit.SECONDS));
167158
}
168159
return Sets.difference(sentRequests, completedRequests);
169160
}
@@ -500,7 +491,7 @@ protected void doExecute(Task task, TestRequest request, ActionListener<TestResp
500491
GroupedActionListener<TestResponse> groupedListener =
501492
new GroupedActionListener<>(listener.map(r -> new TestResponse()), subRequests.size() + 1);
502493
transportService.getThreadPool().generic().execute(ActionRunnable.supply(groupedListener, () -> {
503-
beforeExecuteLatches.get(request).await();
494+
assertTrue(beforeExecuteLatches.get(request).await(60, TimeUnit.SECONDS));
504495
if (((CancellableTask) task).isCancelled()) {
505496
throw new TaskCancelledException("Task was cancelled while executing");
506497
}
@@ -524,7 +515,7 @@ public void onFailure(Exception e) {
524515

525516
@Override
526517
protected void doRun() throws Exception {
527-
beforeSendLatches.get(subRequest).await();
518+
assertTrue(beforeSendLatches.get(subRequest).await(60, TimeUnit.SECONDS));
528519
if (client.getLocalNodeId().equals(subRequest.node.getId()) && randomBoolean()) {
529520
try {
530521
client.executeLocally(TransportTestAction.ACTION, subRequest, latchedListener);

0 commit comments

Comments
 (0)