From ed7c4273c3e6901360d6163c949d4862441c0693 Mon Sep 17 00:00:00 2001 From: jaymode Date: Wed, 27 Jan 2016 09:25:59 -0500 Subject: [PATCH] test: remove check in ClearRolesCacheTests that is prone to failure This removes a check in the ClearRolesCacheTests that is prone to failure due to the possibility of the cache poller running while we modify documents and updating cached values prior to the test issuing the get roles call. See elastic/elasticsearch#1354 Original commit: elastic/x-pack-elasticsearch@ba0b80346682a18d5b5b88cfb3a227afc4edad36 --- .../integration/ClearRolesCacheTests.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/ClearRolesCacheTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/ClearRolesCacheTests.java index 29ea1dca777..0837cea2a7d 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/ClearRolesCacheTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/integration/ClearRolesCacheTests.java @@ -88,7 +88,7 @@ public class ClearRolesCacheTests extends ShieldIntegTestCase { logger.debug("--> created role [{}]", role); } - ensureYellow(ShieldTemplateService.SHIELD_ADMIN_INDEX_NAME); + ensureGreen(ShieldTemplateService.SHIELD_ADMIN_INDEX_NAME); // warm up the caches on every node for (ESNativeRolesStore rolesStore : internalCluster().getInstances(ESNativeRolesStore.class)) { @@ -127,7 +127,7 @@ public class ClearRolesCacheTests extends ShieldIntegTestCase { assertRolesAreCorrect(shieldClient, toModify); } - public void testModifyingDocumentsDirectlyAndClearingCache() throws Exception { + public void testModifyingDocumentsDirectly() throws Exception { Client client = internalCluster().transportClient(); int modifiedRolesCount = randomIntBetween(1, roles.length); @@ -142,14 +142,9 @@ public class ClearRolesCacheTests extends ShieldIntegTestCase { logger.debug("--> updated role [{}] with run_as", role); } + // in this test, the poller runs too frequently to check the cache still has roles without run as + // clear the cache and we should definitely see the latest values! ShieldClient shieldClient = new ShieldClient(client); - for (String role : roles) { - GetRolesResponse roleResponse = shieldClient.prepareGetRoles().roles(role).get(); - assertThat(roleResponse.isExists(), is(true)); - final String[] runAs = roleResponse.roles().get(0).getRunAs(); - assertThat("role [" + role + "] should be cached and no rules have run as set", runAs == null || runAs.length == 0, is(true)); - } - final boolean useHttp = randomBoolean(); final boolean clearAll = randomBoolean(); logger.debug("--> starting to clear roles. using http [{}] clearing all [{}]", useHttp, clearAll);