From 7c0df3c0dc300b306299165641cf74dcc4c7708b Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Mon, 17 Nov 2025 19:54:25 +1100 Subject: [PATCH 1/2] [Test] Fix NodeShutdownIT testStalledShardMigrationProperlyDetected Ensure shards for testing are allocated on a spare node so that migration status is for the test shards only. Resolves: #115697 --- muted-tests.yml | 3 --- .../xpack/shutdown/NodeShutdownIT.java | 19 ++++++++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/muted-tests.yml b/muted-tests.yml index 181601d3df3f8..c3b35905c35d7 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -465,9 +465,6 @@ tests: - class: org.elasticsearch.index.store.DirectIOIT method: testDirectIOUsed {p0=bbq_disk} issue: https://github.com/elastic/elasticsearch/issues/138104 -- class: org.elasticsearch.xpack.shutdown.NodeShutdownIT - method: testStalledShardMigrationProperlyDetected - issue: https://github.com/elastic/elasticsearch/issues/115697 - class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeIT method: test issue: https://github.com/elastic/elasticsearch/issues/137909 diff --git a/x-pack/plugin/shutdown/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownIT.java b/x-pack/plugin/shutdown/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownIT.java index 58a51aa3efdd8..ddd88992844d5 100644 --- a/x-pack/plugin/shutdown/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownIT.java +++ b/x-pack/plugin/shutdown/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownIT.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.containsString; @@ -307,7 +308,15 @@ public void testShardsCanBeAllocatedAfterShutdownDeleted() throws Exception { } public void testStalledShardMigrationProperlyDetected() throws Exception { - String nodeIdToShutdown = getRandomNodeId(); + ensureHealth(r -> {}); + final var clusterState = assertOKAndCreateObjectPath(client().performRequest(new Request("GET", "_cluster/state"))); + + final Set nodeIdsForSecurityIndex = Set.of( + clusterState.evaluate("routing_table.indices.\\.security-7.shards.0.0.node"), + clusterState.evaluate("routing_table.indices.\\.security-7.shards.0.1.node") + ); + + String nodeIdToShutdown = getRandomNodeId(nodeIdsForSecurityIndex); int numberOfShards = randomIntBetween(1, 5); // Create an index, pin the allocation to the node we're about to shut down @@ -484,13 +493,17 @@ private void putNodeShutdown( assertOK(client().performRequest(putShutdown)); } - @SuppressWarnings("unchecked") private String getRandomNodeId() throws IOException { + return getRandomNodeId(Set.of()); + } + + @SuppressWarnings("unchecked") + private String getRandomNodeId(Set excludes) throws IOException { Request nodesRequest = new Request("GET", "_nodes"); Map nodesResponse = responseAsMap(client().performRequest(nodesRequest)); Map nodesObject = (Map) nodesResponse.get("nodes"); - return randomFrom(nodesObject.keySet()); + return randomValueOtherThanMany(excludes::contains, () -> randomFrom(nodesObject.keySet())); } @Override From eafa437e788e373cf1e6068e323d1eea1ec5b702 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Mon, 17 Nov 2025 20:30:07 +1100 Subject: [PATCH 2/2] different fix --- .../shutdown/qa/multi-node/build.gradle | 1 + .../xpack/shutdown/NodeShutdownIT.java | 19 +++---------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/x-pack/plugin/shutdown/qa/multi-node/build.gradle b/x-pack/plugin/shutdown/qa/multi-node/build.gradle index 74dbfeb5cbefd..13644921fc72e 100644 --- a/x-pack/plugin/shutdown/qa/multi-node/build.gradle +++ b/x-pack/plugin/shutdown/qa/multi-node/build.gradle @@ -11,4 +11,5 @@ testClusters.configureEach { testDistribution = 'DEFAULT' numberOfNodes = 4 readinessEnabled = true + systemProperty 'es.queryable_built_in_roles_enabled', 'false' } diff --git a/x-pack/plugin/shutdown/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownIT.java b/x-pack/plugin/shutdown/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownIT.java index ddd88992844d5..58a51aa3efdd8 100644 --- a/x-pack/plugin/shutdown/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownIT.java +++ b/x-pack/plugin/shutdown/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownIT.java @@ -27,7 +27,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.Set; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.containsString; @@ -308,15 +307,7 @@ public void testShardsCanBeAllocatedAfterShutdownDeleted() throws Exception { } public void testStalledShardMigrationProperlyDetected() throws Exception { - ensureHealth(r -> {}); - final var clusterState = assertOKAndCreateObjectPath(client().performRequest(new Request("GET", "_cluster/state"))); - - final Set nodeIdsForSecurityIndex = Set.of( - clusterState.evaluate("routing_table.indices.\\.security-7.shards.0.0.node"), - clusterState.evaluate("routing_table.indices.\\.security-7.shards.0.1.node") - ); - - String nodeIdToShutdown = getRandomNodeId(nodeIdsForSecurityIndex); + String nodeIdToShutdown = getRandomNodeId(); int numberOfShards = randomIntBetween(1, 5); // Create an index, pin the allocation to the node we're about to shut down @@ -493,17 +484,13 @@ private void putNodeShutdown( assertOK(client().performRequest(putShutdown)); } - private String getRandomNodeId() throws IOException { - return getRandomNodeId(Set.of()); - } - @SuppressWarnings("unchecked") - private String getRandomNodeId(Set excludes) throws IOException { + private String getRandomNodeId() throws IOException { Request nodesRequest = new Request("GET", "_nodes"); Map nodesResponse = responseAsMap(client().performRequest(nodesRequest)); Map nodesObject = (Map) nodesResponse.get("nodes"); - return randomValueOtherThanMany(excludes::contains, () -> randomFrom(nodesObject.keySet())); + return randomFrom(nodesObject.keySet()); } @Override