From 86af4c4b2a05f458139489fd73ae6379558fa82f Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Tue, 19 Jul 2022 11:02:34 -0400 Subject: [PATCH] Remove additional waitOrThrow Signed-off-by: Craig Perkins --- .../dlic/dlsfls/CCReplicationTest.java | 18 ------------- .../dlic/rest/api/TenantInfoActionTest.java | 5 ---- .../security/test/SingleClusterTest.java | 25 ------------------- 3 files changed, 48 deletions(-) diff --git a/src/test/java/org/opensearch/security/dlic/dlsfls/CCReplicationTest.java b/src/test/java/org/opensearch/security/dlic/dlsfls/CCReplicationTest.java index 2e582daf88..9a659853a4 100644 --- a/src/test/java/org/opensearch/security/dlic/dlsfls/CCReplicationTest.java +++ b/src/test/java/org/opensearch/security/dlic/dlsfls/CCReplicationTest.java @@ -156,24 +156,6 @@ protected void doExecute(Task task, MockReplicationRequest request, ActionListen } } - //Wait for the security plugin to load roles. - private void waitOrThrow(Client client, String index) throws Exception { - int failures = 0; - while(failures < 5) { - try { - client.execute(MockReplicationAction.INSTANCE, new MockReplicationRequest(index)).actionGet(); - break; - } catch (OpenSearchSecurityException ex) { - if (ex.getMessage().contains("OpenSearch Security not initialized")) { - Thread.sleep(500); - failures++; - } else { - throw ex; - } - } - } - } - void populateData(Client tc) { tc.index(new IndexRequest("hr-dls").id("0").setRefreshPolicy(RefreshPolicy.IMMEDIATE) .source("{\"User\": \"testuser\",\"Date\":\"2021-01-18T17:27:20Z\",\"Designation\":\"HR\"}", XContentType.JSON)).actionGet(); diff --git a/src/test/java/org/opensearch/security/dlic/rest/api/TenantInfoActionTest.java b/src/test/java/org/opensearch/security/dlic/rest/api/TenantInfoActionTest.java index d647d56a55..01004faba7 100644 --- a/src/test/java/org/opensearch/security/dlic/rest/api/TenantInfoActionTest.java +++ b/src/test/java/org/opensearch/security/dlic/rest/api/TenantInfoActionTest.java @@ -16,7 +16,6 @@ import org.junit.Assert; import org.junit.Test; -import org.opensearch.client.Client; import org.opensearch.common.settings.Settings; import org.opensearch.security.support.ConfigConstants; import org.opensearch.security.test.helper.rest.RestHelper; @@ -42,9 +41,6 @@ public TenantInfoActionTest(){ public void testTenantInfoAPIAccess() throws Exception { Settings settings = Settings.builder().put(ConfigConstants.SECURITY_UNSUPPORTED_RESTAPI_ALLOW_SECURITYCONFIG_MODIFICATION, true).build(); setup(settings); - try (Client tc = getClient()) { - waitForInit(tc); - } rh.keystore = "restapi/kirk-keystore.jks"; rh.sendAdminCertificate = true; @@ -64,7 +60,6 @@ public void testTenantInfoAPIAccess() throws Exception { public void testTenantInfoAPIUpdate() throws Exception { Settings settings = Settings.builder().put(ConfigConstants.SECURITY_UNSUPPORTED_RESTAPI_ALLOW_SECURITYCONFIG_MODIFICATION, true).build(); setup(settings); - rh.keystore = "restapi/kirk-keystore.jks"; rh.sendHTTPClientCredentials = true; rh.sendAdminCertificate = true; diff --git a/src/test/java/org/opensearch/security/test/SingleClusterTest.java b/src/test/java/org/opensearch/security/test/SingleClusterTest.java index ed1f4e9148..e7e2f42052 100644 --- a/src/test/java/org/opensearch/security/test/SingleClusterTest.java +++ b/src/test/java/org/opensearch/security/test/SingleClusterTest.java @@ -138,31 +138,6 @@ protected void setupGenericNodes(List nodeOverride, List sslO clusterConfiguration); } - //Wait for the security plugin to load roles. - public void waitForInit(Client client) throws Exception { - int maxRetries = 3; - Optional retainedException = Optional.empty(); - for (int i = 0; i < maxRetries; i++) { - try { - client.admin().cluster().health(new ClusterHealthRequest()).actionGet(); - retainedException = Optional.empty(); - return; - } catch (OpenSearchSecurityException ex) { - if(ex.getMessage().contains("OpenSearch Security not initialized")) { - retainedException = Optional.of(ex); - Thread.sleep(500); - } else { - // plugin is initialized, but another error received. - // Example could be user does not have permissions for cluster:monitor/health - retainedException = Optional.empty(); - } - } - } - if (retainedException.isPresent()) { - throw retainedException.get(); - } - } - protected RestHelper restHelper() { return new RestHelper(clusterInfo, getResourceFolder()); }