mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 02:14:54 +00:00
[TEST] Fix testTimedOutUpdateTaskCleanedUp to wait for blocking task to be completed
The "test" task can complete its execution with a timeout exception before the "block-task" actually starts executing. The test thus has to wait for both to be completed before checking that the updateTasksPerExecutor map has been properly cleaned up.
This commit is contained in:
parent
b9bee8bca3
commit
b1fd257c42
@ -150,6 +150,7 @@ public class ClusterServiceTests extends ESTestCase {
|
||||
|
||||
public void testTimedOutUpdateTaskCleanedUp() throws Exception {
|
||||
final CountDownLatch block = new CountDownLatch(1);
|
||||
final CountDownLatch blockCompleted = new CountDownLatch(1);
|
||||
clusterService.submitStateUpdateTask("block-task", new ClusterStateUpdateTask() {
|
||||
@Override
|
||||
public ClusterState execute(ClusterState currentState) {
|
||||
@ -158,6 +159,7 @@ public class ClusterServiceTests extends ESTestCase {
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
blockCompleted.countDown();
|
||||
return currentState;
|
||||
}
|
||||
|
||||
@ -187,6 +189,7 @@ public class ClusterServiceTests extends ESTestCase {
|
||||
});
|
||||
block.countDown();
|
||||
block2.await();
|
||||
blockCompleted.await();
|
||||
synchronized (clusterService.updateTasksPerExecutor) {
|
||||
assertTrue("expected empty map but was " + clusterService.updateTasksPerExecutor,
|
||||
clusterService.updateTasksPerExecutor.isEmpty());
|
||||
|
Loading…
x
Reference in New Issue
Block a user