-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: kkewwei <[email protected]>
- Loading branch information
Showing
4 changed files
with
230 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
qa/smoke-test-http/src/test/java/org/opensearch/http/HttpCatIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.http; | ||
|
||
import org.apache.hc.core5.http.ParseException; | ||
import org.apache.hc.core5.http.io.entity.EntityUtils; | ||
import org.junit.BeforeClass; | ||
import org.opensearch.client.Request; | ||
import org.opensearch.client.Response; | ||
import org.opensearch.client.ResponseException; | ||
import org.opensearch.client.RestClient; | ||
import org.opensearch.test.OpenSearchIntegTestCase; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.apache.hc.core5.http.HttpStatus.SC_OK; | ||
import static org.hamcrest.Matchers.containsString; | ||
|
||
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.SUITE, supportsDedicatedMasters = false, numDataNodes = 5, numClientNodes = 0) | ||
public class HttpCatIT extends HttpSmokeTestCase { | ||
|
||
@BeforeClass | ||
public static void doNotSetAvailableProcessors() { | ||
System.setProperty("opensearch.set.netty.runtime.available.processors", "false"); | ||
} | ||
|
||
public void testdoCatRequest() throws IOException, ParseException { | ||
try (RestClient restClient = getRestClient()) { | ||
int nodesCount = restClient.getNodes().size(); | ||
for (int i = 0; i < 20; i++) { | ||
Request nodesRequest = new Request("GET", "/_cat/nodes?timeout=" + randomInt(300) + "ms"); | ||
try { | ||
Response response = restClient.performRequest(nodesRequest); | ||
assertEquals(SC_OK, response.getStatusLine().getStatusCode()); | ||
String result = EntityUtils.toString(response.getEntity()); | ||
String[] NodeInfos = result.split("\n"); | ||
assertEquals(nodesCount, NodeInfos.length); | ||
} catch (ResponseException e) { | ||
// it means that it costs too long to get ClusterState from the master. | ||
assertThat(e.getMessage(), containsString("costs too long to get ClusterState from the master")); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters