use of org.opensearch.client.core.MainResponse in project OpenSearch by opensearch-project.
the class RestHighLevelClientTests method testInfo.
public void testInfo() throws IOException {
MainResponse testInfo = new MainResponse("nodeName", new MainResponse.Version("number", "buildType", "buildHash", "buildDate", true, "luceneVersion", "minimumWireCompatibilityVersion", "minimumIndexCompatibilityVersion"), "clusterName", "clusterUuid");
mockResponse((ToXContentFragment) (builder, params) -> {
// taken from the server side MainResponse
builder.field("name", testInfo.getNodeName());
builder.field("cluster_name", testInfo.getClusterName());
builder.field("cluster_uuid", testInfo.getClusterUuid());
builder.startObject("version").field("number", testInfo.getVersion().getNumber()).field("build_type", testInfo.getVersion().getBuildType()).field("build_hash", testInfo.getVersion().getBuildHash()).field("build_date", testInfo.getVersion().getBuildDate()).field("build_snapshot", testInfo.getVersion().isSnapshot()).field("lucene_version", testInfo.getVersion().getLuceneVersion()).field("minimum_wire_compatibility_version", testInfo.getVersion().getMinimumWireCompatibilityVersion()).field("minimum_index_compatibility_version", testInfo.getVersion().getMinimumIndexCompatibilityVersion()).endObject();
return builder;
});
MainResponse receivedInfo = restHighLevelClient.info(RequestOptions.DEFAULT);
assertEquals(testInfo, receivedInfo);
}
use of org.opensearch.client.core.MainResponse in project OpenSearch by opensearch-project.
the class PingAndInfoIT method testInfo.
public void testInfo() throws IOException {
MainResponse info = highLevelClient().info(RequestOptions.DEFAULT);
// compare with what the low level client outputs
Map<String, Object> infoAsMap = entityAsMap(adminClient().performRequest(new Request(HttpGet.METHOD_NAME, "/")));
assertEquals(infoAsMap.get("cluster_name"), info.getClusterName());
assertEquals(infoAsMap.get("cluster_uuid"), info.getClusterUuid());
// only check node name existence, might be a different one from what was hit by low level client in multi-node cluster
assertNotNull(info.getNodeName());
@SuppressWarnings("unchecked") Map<String, Object> versionMap = (Map<String, Object>) infoAsMap.get("version");
assertEquals(versionMap.get("build_type"), info.getVersion().getBuildType());
assertEquals(versionMap.get("build_hash"), info.getVersion().getBuildHash());
assertEquals(versionMap.get("build_date"), info.getVersion().getBuildDate());
assertEquals(versionMap.get("build_snapshot"), info.getVersion().isSnapshot());
assertTrue(versionMap.get("number").toString().startsWith(info.getVersion().getNumber()));
assertEquals(versionMap.get("lucene_version"), info.getVersion().getLuceneVersion());
}
use of org.opensearch.client.core.MainResponse in project OpenSearch by opensearch-project.
the class PingAndInfoIT method testInfo_overrideResponseVersion.
public void testInfo_overrideResponseVersion() throws IOException {
Request overrideResponseVersionRequest = new Request("PUT", "/_cluster/settings");
overrideResponseVersionRequest.setOptions(expectWarnings(TransportMainAction.OVERRIDE_MAIN_RESPONSE_VERSION_DEPRECATION_MESSAGE));
overrideResponseVersionRequest.setJsonEntity("{\"persistent\":{\"compatibility\": {\"override_main_response_version\":true}}}");
client().performRequest(overrideResponseVersionRequest);
MainResponse info = highLevelClient().info(RequestOptions.DEFAULT);
assertEquals("7.10.2", info.getVersion().getNumber());
// Set back to default version.
Request resetResponseVersionRequest = new Request("PUT", "/_cluster/settings");
resetResponseVersionRequest.setJsonEntity("{\"persistent\":{\"compatibility\": {\"override_main_response_version\":null}}}");
client().performRequest(resetResponseVersionRequest);
Map<String, Object> infoAsMap = entityAsMap(adminClient().performRequest(new Request(HttpGet.METHOD_NAME, "/")));
@SuppressWarnings("unchecked") Map<String, Object> versionMap = (Map<String, Object>) infoAsMap.get("version");
info = highLevelClient().info(RequestOptions.DEFAULT);
assertTrue(versionMap.get("number").toString().startsWith(info.getVersion().getNumber()));
}
Aggregations