diff --git a/muted-tests.yml b/muted-tests.yml index 8382e7c81556b..e4b251b5dc80d 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -377,9 +377,6 @@ tests: - class: org.elasticsearch.threadpool.ThreadPoolTests method: testDetailedUtilizationMetric issue: https://github.com/elastic/elasticsearch/issues/138242 -- class: org.elasticsearch.upgrades.SecurityIndexRolesMetadataMigrationIT - method: testRoleMigration - issue: https://github.com/elastic/elasticsearch/issues/138731 # Examples: # diff --git a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/SecurityIndexRolesMetadataMigrationIT.java b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/SecurityIndexRolesMetadataMigrationIT.java index afec1812baaa7..5bc332efc07b5 100644 --- a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/SecurityIndexRolesMetadataMigrationIT.java +++ b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/SecurityIndexRolesMetadataMigrationIT.java @@ -54,8 +54,9 @@ public void testRoleMigration() throws Exception { assertMigratedDocInSecurityIndex(mixed1TestRole, "meta", "test"); assertMigratedDocInSecurityIndex(mixed2TestRole, "meta", "test"); assertMigratedDocInSecurityIndex(upgradedTestRole, "meta", "test"); - // queries all roles by metadata - assertAllRoles(client(), "mixed1-test-role", "mixed2-test-role", "old-test-role", "upgraded-test-role"); + // query all roles by metadata - use assertBusy to handle the case where the node handling the query is not yet aware of the + // successful migration + assertBusy(() -> assertAllRoles(client(), "mixed1-test-role", "mixed2-test-role", "old-test-role", "upgraded-test-role")); } } @@ -175,7 +176,13 @@ private void assertAllRoles(RestClient client, String... roleNames) throws IOExc {"query":{"bool":{"must":[{"exists":{"field":"metadata.meta"}}]}},"sort":["name"]}"""; Request request = new Request(randomFrom("POST", "GET"), "/_security/_query/role"); request.setJsonEntity(metadataQuery); - Response response = client.performRequest(request); + Response response = null; + try { + response = client.performRequest(request); + } catch (ResponseException e) { + fail(e); + } + assertNotNull(response); assertOK(response); Map responseMap = responseAsMap(response); assertThat(responseMap.get("total"), is(roleNames.length));