@@ -132,20 +132,24 @@ public void testTaskCounts() {
132
132
assertThat (response .getTasks ().size (), greaterThanOrEqualTo (cluster ().numDataNodes ()));
133
133
}
134
134
135
- public void testMasterNodeOperationTasks () {
135
+ public void testMasterNodeOperationTasks () throws Exception {
136
136
registerTaskManagerListeners (ClusterHealthAction .NAME );
137
137
138
138
// First run the health on the master node - should produce only one task on the master node
139
139
internalCluster ().masterClient ().admin ().cluster ().prepareHealth ().get ();
140
140
assertEquals (1 , numberOfEvents (ClusterHealthAction .NAME , Tuple ::v1 )); // counting only registration events
141
- assertEquals (1 , numberOfEvents (ClusterHealthAction .NAME , event -> event .v1 () == false )); // counting only unregistration events
141
+ // counting only unregistration events
142
+ // When checking unregistration events there might be some delay since receiving the response from the cluster doesn't
143
+ // guarantee that the task has been unregistered.
144
+ assertBusy (() -> assertEquals (1 , numberOfEvents (ClusterHealthAction .NAME , event -> event .v1 () == false )));
142
145
143
146
resetTaskManagerListeners (ClusterHealthAction .NAME );
144
147
145
148
// Now run the health on a non-master node - should produce one task on master and one task on another node
146
149
internalCluster ().nonMasterClient ().admin ().cluster ().prepareHealth ().get ();
147
150
assertEquals (2 , numberOfEvents (ClusterHealthAction .NAME , Tuple ::v1 )); // counting only registration events
148
- assertEquals (2 , numberOfEvents (ClusterHealthAction .NAME , event -> event .v1 () == false )); // counting only unregistration events
151
+ // counting only unregistration events
152
+ assertBusy (() -> assertEquals (2 , numberOfEvents (ClusterHealthAction .NAME , event -> event .v1 () == false )));
149
153
List <TaskInfo > tasks = findEvents (ClusterHealthAction .NAME , Tuple ::v1 );
150
154
151
155
// Verify that one of these tasks is a parent of another task
0 commit comments