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;
|
||||
}
|
||||
}
|
||||
int numberOfThreads = randomIntBetween(2, 256);
|
||||
int numberOfThreads = randomIntBetween(2, 8);
|
||||
int tasksSubmittedPerThread = randomIntBetween(1, 1024);
|
||||
|
||||
ConcurrentMap<String, AtomicInteger> counters = new ConcurrentHashMap<>();
|
||||
CountDownLatch latch = new CountDownLatch(numberOfThreads * tasksSubmittedPerThread);
|
||||
CountDownLatch updateLatch = new CountDownLatch(numberOfThreads * tasksSubmittedPerThread);
|
||||
ClusterStateTaskListener listener = new ClusterStateTaskListener() {
|
||||
@Override
|
||||
public void onFailure(String source, Throwable t) {
|
||||
|
@ -780,7 +780,7 @@ public class ClusterServiceIT extends ESIntegTestCase {
|
|||
@Override
|
||||
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
|
||||
counters.computeIfAbsent(source, key -> new AtomicInteger()).incrementAndGet();
|
||||
latch.countDown();
|
||||
updateLatch.countDown();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -814,7 +814,7 @@ public class ClusterServiceIT extends ESIntegTestCase {
|
|||
clusterService.submitStateUpdateTask(
|
||||
Thread.currentThread().getName(),
|
||||
new Task(),
|
||||
ClusterStateTaskConfig.build(Priority.NORMAL),
|
||||
ClusterStateTaskConfig.build(randomFrom(Priority.values())),
|
||||
executor,
|
||||
listener);
|
||||
}
|
||||
|
@ -829,7 +829,7 @@ public class ClusterServiceIT extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
// wait until all the cluster state updates have been processed
|
||||
latch.await();
|
||||
updateLatch.await();
|
||||
|
||||
// assert the number of executed tasks is correct
|
||||
assertEquals(numberOfThreads * tasksSubmittedPerThread, counter.get());
|
||||
|
|
Loading…
Reference in New Issue