Skip to content

Commit d64460e

Browse files
authored
[9.1] Fix testRoleMigration race condition (#138742) (#138746)
* Fix testRoleMigration race condition (#138742) * Remove mute
1 parent e7bfe2d commit d64460e

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,6 @@ tests:
377377
- class: org.elasticsearch.threadpool.ThreadPoolTests
378378
method: testDetailedUtilizationMetric
379379
issue: https://github.com/elastic/elasticsearch/issues/138242
380-
- class: org.elasticsearch.upgrades.SecurityIndexRolesMetadataMigrationIT
381-
method: testRoleMigration
382-
issue: https://github.com/elastic/elasticsearch/issues/138731
383380

384381
# Examples:
385382
#

x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/SecurityIndexRolesMetadataMigrationIT.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ public void testRoleMigration() throws Exception {
5454
assertMigratedDocInSecurityIndex(mixed1TestRole, "meta", "test");
5555
assertMigratedDocInSecurityIndex(mixed2TestRole, "meta", "test");
5656
assertMigratedDocInSecurityIndex(upgradedTestRole, "meta", "test");
57-
// queries all roles by metadata
58-
assertAllRoles(client(), "mixed1-test-role", "mixed2-test-role", "old-test-role", "upgraded-test-role");
57+
// query all roles by metadata - use assertBusy to handle the case where the node handling the query is not yet aware of the
58+
// successful migration
59+
assertBusy(() -> assertAllRoles(client(), "mixed1-test-role", "mixed2-test-role", "old-test-role", "upgraded-test-role"));
5960
}
6061
}
6162

@@ -175,7 +176,13 @@ private void assertAllRoles(RestClient client, String... roleNames) throws IOExc
175176
{"query":{"bool":{"must":[{"exists":{"field":"metadata.meta"}}]}},"sort":["name"]}""";
176177
Request request = new Request(randomFrom("POST", "GET"), "/_security/_query/role");
177178
request.setJsonEntity(metadataQuery);
178-
Response response = client.performRequest(request);
179+
Response response = null;
180+
try {
181+
response = client.performRequest(request);
182+
} catch (ResponseException e) {
183+
fail(e);
184+
}
185+
assertNotNull(response);
179186
assertOK(response);
180187
Map<String, Object> responseMap = responseAsMap(response);
181188
assertThat(responseMap.get("total"), is(roleNames.length));

0 commit comments

Comments
 (0)