Cleanup ClusterServiceIT#testClusterStateBatchedUpdates
This commit addresses some issues that arose during the review of #14899 but were lost during squash while integrating into master. - the number of test threads is dropped to at most eight - a local variable is renamed for clarity - task priorities are randomized
This commit is contained in:
parent
e7952e2023
commit
bbef8acd3c
|
@ -766,11 +766,11 @@ public class ClusterServiceIT extends ESIntegTestCase {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int numberOfThreads = randomIntBetween(2, 256);
|
int numberOfThreads = randomIntBetween(2, 8);
|
||||||
int tasksSubmittedPerThread = randomIntBetween(1, 1024);
|
int tasksSubmittedPerThread = randomIntBetween(1, 1024);
|
||||||
|
|
||||||
ConcurrentMap<String, AtomicInteger> counters = new ConcurrentHashMap<>();
|
ConcurrentMap<String, AtomicInteger> counters = new ConcurrentHashMap<>();
|
||||||
CountDownLatch latch = new CountDownLatch(numberOfThreads * tasksSubmittedPerThread);
|
CountDownLatch updateLatch = new CountDownLatch(numberOfThreads * tasksSubmittedPerThread);
|
||||||
ClusterStateTaskListener listener = new ClusterStateTaskListener() {
|
ClusterStateTaskListener listener = new ClusterStateTaskListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(String source, Throwable t) {
|
public void onFailure(String source, Throwable t) {
|
||||||
|
@ -780,7 +780,7 @@ public class ClusterServiceIT extends ESIntegTestCase {
|
||||||
@Override
|
@Override
|
||||||
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
|
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
|
||||||
counters.computeIfAbsent(source, key -> new AtomicInteger()).incrementAndGet();
|
counters.computeIfAbsent(source, key -> new AtomicInteger()).incrementAndGet();
|
||||||
latch.countDown();
|
updateLatch.countDown();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -814,7 +814,7 @@ public class ClusterServiceIT extends ESIntegTestCase {
|
||||||
clusterService.submitStateUpdateTask(
|
clusterService.submitStateUpdateTask(
|
||||||
Thread.currentThread().getName(),
|
Thread.currentThread().getName(),
|
||||||
new Task(),
|
new Task(),
|
||||||
ClusterStateTaskConfig.build(Priority.NORMAL),
|
ClusterStateTaskConfig.build(randomFrom(Priority.values())),
|
||||||
executor,
|
executor,
|
||||||
listener);
|
listener);
|
||||||
}
|
}
|
||||||
|
@ -829,7 +829,7 @@ public class ClusterServiceIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait until all the cluster state updates have been processed
|
// wait until all the cluster state updates have been processed
|
||||||
latch.await();
|
updateLatch.await();
|
||||||
|
|
||||||
// assert the number of executed tasks is correct
|
// assert the number of executed tasks is correct
|
||||||
assertEquals(numberOfThreads * tasksSubmittedPerThread, counter.get());
|
assertEquals(numberOfThreads * tasksSubmittedPerThread, counter.get());
|
||||||
|
|
Loading…
Reference in New Issue