[TEST] Fix race condition in ZenDiscoveryIT.testDiscoveryStats
With #24236, the master now uses the pending queue when publishing to itself. This means that a cluster state update is put into the pending queue, then sent to the ClusterApplierService to be applied. After it has been applied, it is marked as processed and removed from the pending queue. ensureGreen is implemented as a cluster health action that waits on certain conditions, which will lead to a cluster state update task to be submitted on the master. When this task gets to run and the conditions are not satisfied yet, it register a cluster state observer. This observer is registered on the ClusterApplierService and waits on cluster state change events. ClusterApplierService first notifies the observer and then the discovery layer. This means that there is a small time frame where ensureGreen can complete and call the node stats to find the pending queue still containing the last cluster state update. Closes #24388
This commit is contained in:
parent
9c55bca8fb
commit
86aab98fde
|
@ -248,7 +248,7 @@ public class ZenDiscoveryIT extends ESIntegTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testDiscoveryStats() throws IOException {
|
||||
public void testDiscoveryStats() throws Exception {
|
||||
String expectedStatsJsonResponse = "{\n" +
|
||||
" \"discovery\" : {\n" +
|
||||
" \"cluster_state_queue\" : {\n" +
|
||||
|
@ -261,6 +261,9 @@ public class ZenDiscoveryIT extends ESIntegTestCase {
|
|||
|
||||
internalCluster().startNode();
|
||||
ensureGreen(); // ensures that all events are processed (in particular state recovery fully completed)
|
||||
assertBusy(() ->
|
||||
assertThat(internalCluster().clusterService(internalCluster().getMasterName()).getMasterService().numberOfPendingTasks(),
|
||||
equalTo(0))); // see https://github.com/elastic/elasticsearch/issues/24388
|
||||
|
||||
logger.info("--> request node discovery stats");
|
||||
NodesStatsResponse statsResponse = client().admin().cluster().prepareNodesStats().clear().setDiscovery(true).get();
|
||||
|
|
Loading…
Reference in New Issue