Skip to content

Commit fc3dee1

Browse files
authored
Adding a check that the test attribute name is not a role name (#84533) (#84537)
SetSingleNodeAllocateStepTests.testPerformActionAttrsRequestFails() randomly generates attribute names. In rare cases the attribute name happens to be a role name. This commit makes sure that test attribute names are not also role names.
1 parent e567318 commit fc3dee1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/SetSingleNodeAllocateStepTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.elasticsearch.cluster.metadata.IndexMetadata;
1717
import org.elasticsearch.cluster.metadata.Metadata;
1818
import org.elasticsearch.cluster.node.DiscoveryNode;
19+
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
1920
import org.elasticsearch.cluster.node.DiscoveryNodes;
2021
import org.elasticsearch.cluster.routing.IndexRoutingTable;
2122
import org.elasticsearch.cluster.routing.RoutingTable;
@@ -263,7 +264,10 @@ public void testPerformActionAttrsRequestFails() {
263264
Map<String, String> validAttributes = new HashMap<>();
264265
for (int i = 0; i < numAttrs; i++) {
265266
validAttributes.put(
266-
randomValueOtherThanMany(validAttributes::containsKey, () -> randomAlphaOfLengthBetween(1, 20)),
267+
randomValueOtherThanMany(
268+
attr -> validAttributes.containsKey(attr) || DiscoveryNodeRole.roleNames().contains(attr),
269+
() -> randomAlphaOfLengthBetween(1, 20)
270+
),
267271
randomAlphaOfLengthBetween(1, 20)
268272
);
269273
}

0 commit comments

Comments
 (0)