Skip to content

Commit 4be2f35

Browse files
committed
Fix tests depending on _ilm/status API
Since elastic#129367 we run the `_ilm/status` API on the local node, which could cause issues in tests that assume the API runs on the master node - i.e. they assumed that once the assertion passed, all nodes in the cluster would have that cluster state, which is not true.
1 parent 4daf983 commit 4be2f35

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ private void wipeCluster() throws Exception {
10561056
deleteAllNodeShutdownMetadata();
10571057
}
10581058

1059-
private void waitForClusterUpdates() throws Exception {
1059+
public void waitForClusterUpdates() throws Exception {
10601060
logger.info("Waiting for all cluster updates up to this moment to be processed");
10611061

10621062
try {

x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/MigrateToDataTiersIT.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ public void testMigrateToDataTiersAction() throws Exception {
169169
Response response = client().performRequest(new Request("GET", "_ilm/status"));
170170
assertThat(EntityUtils.toString(response.getEntity()), containsString(OperationMode.STOPPED.toString()));
171171
});
172+
// Wait for cluster state to be published to all nodes.
173+
waitForClusterUpdates();
172174

173175
String indexWithDataWarmRouting = "indexwithdatawarmrouting";
174176
Settings.Builder settings = Settings.builder()
@@ -340,6 +342,8 @@ public void testIndexTemplatesMigration() throws Exception {
340342
Response response = client().performRequest(new Request("GET", "_ilm/status"));
341343
assertThat(EntityUtils.toString(response.getEntity()), containsString(OperationMode.STOPPED.toString()));
342344
});
345+
// Wait for cluster state to be published to all nodes.
346+
waitForClusterUpdates();
343347
}
344348

345349
Request migrateRequest = new Request("POST", "_ilm/migrate_to_data_tiers");

x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ public void testCanStopILMWithPolicyUsingNonexistentPolicy() throws Exception {
766766
String status = (String) statusResponseMap.get("operation_mode");
767767
assertEquals("STOPPED", status);
768768
});
769+
// Wait for cluster state to be published to all nodes.
770+
waitForClusterUpdates();
769771

770772
// Re-start ILM so that subsequent tests don't fail
771773
Request startILMRequest = new Request("POST", "_ilm/start");

0 commit comments

Comments
 (0)