Skip to content

Commit

Permalink
Update test for metadata
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Kurait <[email protected]>
  • Loading branch information
AndreKurait committed Dec 10, 2024
1 parent 9a2edba commit 3511cad
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ private void migrationDocumentsWithClusters(
// So we explicitly set it.
String body = String.format(
"{" +
" \"settings\": {" +
" \"index\": {" +
" \"number_of_shards\": %d," +
" \"number_of_replicas\": 0" +
" }" +
" }" +
"}",
" \"settings\": {" +
" \"index\": {" +
" \"number_of_shards\": %d," +
" \"number_of_replicas\": 0" +
" }" +
" }" +
"}",
numberOfShards
);
sourceClusterOperations.createIndex(indexName, body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ public void es5_doesNotAllow_multiTypeConflicts() {
" }" +
" }" +
"}";
var res = clusterOperations.attemptCreateIndex(originalIndexName, body);
assertThat(res, containsString("mapper [field1] cannot be changed from type [long] to [float]"));
var res = clusterOperations.put("/" + originalIndexName, body);
assertThat(res.getKey(), equalTo(400));
assertThat(res.getValue(), containsString("mapper [field1] cannot be changed from type [long] to [float]"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,15 @@ public void createIndex(final String index, final String body) {
}

@SneakyThrows
public String attemptCreateIndex(final String index, final String body) {
var createIndexRequest = new HttpPut(clusterUrl + "/" + index);
createIndexRequest.setEntity(new StringEntity(body));
createIndexRequest.setHeader("Content-Type", "application/json");

try (var response = httpClient.execute(createIndexRequest)) {
return EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
public Map.Entry<Integer, String> put(final String path, final String body) {
final var putRequest = new HttpPut(clusterUrl + path);
if (body != null) {
putRequest.setEntity(new StringEntity(body));
putRequest.setHeader("Content-Type", "application/json");
}
try (var response = httpClient.execute(putRequest)) {
var responseBody = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
return Map.entry(response.getCode(), responseBody);
}
}

Expand Down

0 comments on commit 3511cad

Please sign in to comment.