Skip to content

Commit

Permalink
Remove additional waitOrThrow
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <cwperx@amazon.com>
  • Loading branch information
cwperks committed Jul 19, 2022
1 parent a110f18 commit 86af4c4
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
25 changes: 0 additions & 25 deletions src/test/java/org/opensearch/security/test/SingleClusterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,31 +138,6 @@ protected void setupGenericNodes(List<Settings> nodeOverride, List<Boolean> sslO
clusterConfiguration);
}

//Wait for the security plugin to load roles.
public void waitForInit(Client client) throws Exception {
int maxRetries = 3;
Optional<Exception> 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());
}
Expand Down

0 comments on commit 86af4c4

Please sign in to comment.