Skip to content

Commit

Permalink
adding to upgrade test
Browse files Browse the repository at this point in the history
  • Loading branch information
masseyke committed Nov 22, 2024
1 parent 9d5ab65 commit da43acb
Showing 1 changed file with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,7 @@ private void performUpgradedClusterOperations(String dataStreamName) throws IOEx
}

private static void performOldClustertOperations(String templateName, String dataStreamName) throws IOException {
var bulkRequest = new Request("POST", "/" + dataStreamName + "/_bulk");
bulkRequest.setJsonEntity(BULK.replace("$now", formatInstant(Instant.now())));
bulkRequest.addParameter("refresh", "true");
var response = client().performRequest(bulkRequest);
assertOK(response);
var responseBody = entityAsMap(response);
assertThat("errors in response:\n " + responseBody, responseBody.get("errors"), equalTo(false));
bulkLoadData(dataStreamName);

var dataStreams = getDataStream(dataStreamName);
assertThat(ObjectPath.evaluate(dataStreams, "data_streams"), hasSize(1));
Expand All @@ -303,6 +297,28 @@ private static void performOldClustertOperations(String templateName, String dat
String firstBackingIndex = ObjectPath.evaluate(dataStreams, "data_streams.0.indices.0.index_name");
assertThat(firstBackingIndex, backingIndexEqualTo(dataStreamName, 1));
assertSearch(dataStreamName, 8);

for (int i = 0; i < 10; i++) {
rollover(dataStreamName);
bulkLoadData(dataStreamName);
}

}

private static void bulkLoadData(String dataStreamName) throws IOException {
var bulkRequest = new Request("POST", "/" + dataStreamName + "/_bulk");
bulkRequest.setJsonEntity(BULK.replace("$now", formatInstant(Instant.now())));
bulkRequest.addParameter("refresh", "true");
var response = client().performRequest(bulkRequest);
assertOK(response);
var responseBody = entityAsMap(response);
assertThat("errors in response:\n " + responseBody, responseBody.get("errors"), equalTo(false));
}

private static void rollover(String dataStreamName) throws IOException {
Request rolloverRequest = new Request("POST", "/" + dataStreamName + "/_rollover");
Response rolloverResponse = client().performRequest(rolloverRequest);
assertOK(rolloverResponse);
}

private static Map<String, Object> getDataStream(String dataStreamName) throws IOException {
Expand Down

0 comments on commit da43acb

Please sign in to comment.