use of org.opensearch.client.Response in project OpenSearch by opensearch-project.
the class IndexingIT method assertCount.
private void assertCount(String index, int count) throws IOException {
Request searchTestIndexRequest = new Request("POST", "/" + index + "/_search");
searchTestIndexRequest.addParameter(TOTAL_HITS_AS_INT_PARAM, "true");
searchTestIndexRequest.addParameter("filter_path", "hits.total");
Response searchTestIndexResponse = client().performRequest(searchTestIndexRequest);
assertEquals("{\"hits\":{\"total\":" + count + "}}", EntityUtils.toString(searchTestIndexResponse.getEntity(), StandardCharsets.UTF_8));
}
use of org.opensearch.client.Response in project OpenSearch by opensearch-project.
the class JodaCompatibilityIT method testJodaBackedDocValueAndDateFields.
public void testJodaBackedDocValueAndDateFields() throws Exception {
switch(CLUSTER_TYPE) {
case OLD:
Request createTestIndex = indexWithDateField("joda_time", "YYYY-MM-dd'T'HH:mm:ssZZ");
createTestIndex.setOptions(ignoreWarnings());
Response resp = client().performRequest(createTestIndex);
assertEquals(HttpStatus.SC_OK, resp.getStatusLine().getStatusCode());
postNewDoc("joda_time", 1);
break;
case MIXED:
int minute = Booleans.parseBoolean(System.getProperty("tests.first_round")) ? 2 : 3;
postNewDoc("joda_time", minute);
Request search = dateRangeSearch("joda_time");
search.setOptions(ignoreWarnings());
performOnAllNodes(search, r -> assertEquals(HttpStatus.SC_OK, r.getStatusLine().getStatusCode()));
break;
case UPGRADED:
postNewDoc("joda_time", 4);
search = searchWithAgg("joda_time");
search.setOptions(ignoreWarnings());
// making sure all nodes were used for search
performOnAllNodes(search, r -> assertResponseHasAllDocuments(r));
break;
}
}
use of org.opensearch.client.Response in project OpenSearch by opensearch-project.
the class JodaCompatibilityIT method postNewDoc.
private void postNewDoc(String endpoint, int minute) throws IOException {
Request putDoc = new Request("POST", endpoint + "/_doc");
putDoc.addParameter("refresh", "true");
putDoc.addParameter("wait_for_active_shards", "all");
putDoc.setJsonEntity("{\n" + " \"datetime\": \"2020-01-01T00:00:0" + minute + "+01:00\"\n" + "}");
Response resp = client().performRequest(putDoc);
assertEquals(HttpStatus.SC_CREATED, resp.getStatusLine().getStatusCode());
}
use of org.opensearch.client.Response in project OpenSearch by opensearch-project.
the class JodaCompatibilityIT method testJavaBackedDocValueAndDateFields.
public void testJavaBackedDocValueAndDateFields() throws Exception {
switch(CLUSTER_TYPE) {
case OLD:
Request createTestIndex = indexWithDateField("java_time", "8yyyy-MM-dd'T'HH:mm:ssXXX");
Response resp = client().performRequest(createTestIndex);
assertEquals(HttpStatus.SC_OK, resp.getStatusLine().getStatusCode());
postNewDoc("java_time", 1);
break;
case MIXED:
int minute = Booleans.parseBoolean(System.getProperty("tests.first_round")) ? 2 : 3;
postNewDoc("java_time", minute);
Request search = dateRangeSearch("java_time");
Response searchResp = client().performRequest(search);
assertEquals(HttpStatus.SC_OK, searchResp.getStatusLine().getStatusCode());
break;
case UPGRADED:
postNewDoc("java_time", 4);
search = searchWithAgg("java_time");
// making sure all nodes were used for search
performOnAllNodes(search, r -> assertResponseHasAllDocuments(r));
break;
}
}
use of org.opensearch.client.Response in project OpenSearch by opensearch-project.
the class RecoveryIT method testHistoryUUIDIsGenerated.
public void testHistoryUUIDIsGenerated() throws Exception {
final String index = "index_history_uuid";
if (CLUSTER_TYPE == ClusterType.OLD) {
Settings.Builder settings = Settings.builder().put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1).put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 1).put(INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "100ms");
createIndex(index, settings.build());
} else if (CLUSTER_TYPE == ClusterType.UPGRADED) {
ensureGreen(index);
Request shardStatsRequest = new Request("GET", index + "/_stats");
shardStatsRequest.addParameter("level", "shards");
Response response = client().performRequest(shardStatsRequest);
ObjectPath objectPath = ObjectPath.createFromResponse(response);
List<Object> shardStats = objectPath.evaluate("indices." + index + ".shards.0");
assertThat(shardStats, hasSize(2));
String expectHistoryUUID = null;
for (int shard = 0; shard < 2; shard++) {
String nodeID = objectPath.evaluate("indices." + index + ".shards.0." + shard + ".routing.node");
String historyUUID = objectPath.evaluate("indices." + index + ".shards.0." + shard + ".commit.user_data.history_uuid");
assertThat("no history uuid found for shard on " + nodeID, historyUUID, notNullValue());
if (expectHistoryUUID == null) {
expectHistoryUUID = historyUUID;
} else {
assertThat("different history uuid found for shard on " + nodeID, historyUUID, equalTo(expectHistoryUUID));
}
}
}
}
Aggregations