diff --git a/src/integrationTest/java/org/opensearch/security/http/AsyncTests.java b/src/integrationTest/java/org/opensearch/security/http/AsyncTests.java index db6c940b1f..ee46fb3905 100644 --- a/src/integrationTest/java/org/opensearch/security/http/AsyncTests.java +++ b/src/integrationTest/java/org/opensearch/security/http/AsyncTests.java @@ -11,12 +11,8 @@ package org.opensearch.security.http; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import com.nimbusds.jose.util.StandardCharset; -import org.apache.hc.client5.http.classic.methods.HttpPost; -import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.HttpStatus; -import org.apache.hc.core5.http.io.entity.ByteArrayEntity; import org.junit.ClassRule; import org.junit.Test; import org.junit.runner.RunWith; @@ -29,7 +25,6 @@ import org.opensearch.test.framework.cluster.TestRestClient; import org.opensearch.test.framework.cluster.TestRestClient.HttpResponse; -import java.util.Collections; import java.util.Map; import java.util.List; import java.util.ArrayList; @@ -59,7 +54,7 @@ public void testBulkAndCacheInvalidationMixed() throws Exception { String indexName = "test-index"; final String invalidateCachePath = "_plugins/_security/api/cache"; final String nodesPath = "_nodes"; - final String bulkPath = "/_bulk"; + final String bulkPath = "_bulk"; final String document = ("{ \"index\": { \"_index\": \"" + indexName + "\" }}\n{ \"foo\": \"bar\" }\n").repeat(5); final int parallelism = 5; final int totalNumberOfRequests = 30; @@ -78,9 +73,7 @@ public void testBulkAndCacheInvalidationMixed() throws Exception { allRequests.addAll(AsyncActions.generate(() -> { countDownLatch.await(); - final HttpPost post = new HttpPost(client.getHttpServerUri() + bulkPath); - post.setEntity(new ByteArrayEntity(document.getBytes(StandardCharset.UTF_8), ContentType.APPLICATION_JSON)); - return client.executeRequest(post); + return client.postJson(bulkPath, document); }, parallelism, totalNumberOfRequests)); allRequests.addAll(AsyncActions.generate(() -> { @@ -90,7 +83,6 @@ public void testBulkAndCacheInvalidationMixed() throws Exception { // Make sure all requests start at the same time countDownLatch.countDown(); - Collections.shuffle(allRequests); AsyncActions.getAll(allRequests, 30, TimeUnit.SECONDS).forEach((response) -> { response.assertStatusCode(HttpStatus.SC_OK); }); }