Skip to content

Commit 88fc696

Browse files
Add aditional logging for ILM history store tests (elastic#50624)
These tests use the same index name, making it hard to read logs when diagnosing the failures. Additionally more information about the current state of the index could be retrieved when failing. This changes these two things in the hope of capturing more data about why this fails on some CI nodes but not others. Relates to elastic#50353 Co-authored-by: Elastic Machine <[email protected]>
1 parent f576aef commit 88fc696

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

x-pack/plugin/ilm/qa/multi-node/src/test/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,9 +1086,8 @@ public void testRolloverStepRetriesUntilRolledOverIndexIsDeleted() throws Except
10861086
assertBusy(() -> assertThat(getStepKeyForIndex(index), equalTo(TerminalPolicyStep.KEY)));
10871087
}
10881088

1089-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/50353")
10901089
public void testHistoryIsWrittenWithSuccess() throws Exception {
1091-
String index = "index";
1090+
String index = "success-index";
10921091

10931092
createNewSingletonPolicy("hot", new RolloverAction(null, null, 1L));
10941093
Request createIndexTemplate = new Request("PUT", "_template/rolling_indexes");
@@ -1130,9 +1129,8 @@ public void testHistoryIsWrittenWithSuccess() throws Exception {
11301129
}
11311130

11321131

1133-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/50353")
11341132
public void testHistoryIsWrittenWithFailure() throws Exception {
1135-
String index = "index";
1133+
String index = "failure-index";
11361134

11371135
createNewSingletonPolicy("hot", new RolloverAction(null, null, 1L));
11381136
Request createIndexTemplate = new Request("PUT", "_template/rolling_indexes");
@@ -1160,7 +1158,7 @@ public void testHistoryIsWrittenWithFailure() throws Exception {
11601158
}
11611159

11621160
public void testHistoryIsWrittenWithDeletion() throws Exception {
1163-
String index = "index";
1161+
String index = "delete-index";
11641162

11651163
createNewSingletonPolicy("delete", new DeleteAction());
11661164
Request createIndexTemplate = new Request("PUT", "_template/delete_indexes");
@@ -1239,8 +1237,37 @@ private void assertHistoryIsPresent(String policyName, String indexName, boolean
12391237
historyResponseMap = XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true);
12401238
}
12411239
logger.info("--> history response: {}", historyResponseMap);
1242-
assertThat((int)((Map<String, Object>) ((Map<String, Object>) historyResponseMap.get("hits")).get("total")).get("value"),
1243-
greaterThanOrEqualTo(1));
1240+
int hits = (int)((Map<String, Object>) ((Map<String, Object>) historyResponseMap.get("hits")).get("total")).get("value");
1241+
1242+
// For a failure, print out whatever history we *do* have for the index
1243+
if (hits == 0) {
1244+
final Request allResults = new Request("GET", "ilm-history*/_search");
1245+
allResults.setJsonEntity("{\n" +
1246+
" \"query\": {\n" +
1247+
" \"bool\": {\n" +
1248+
" \"must\": [\n" +
1249+
" {\n" +
1250+
" \"term\": {\n" +
1251+
" \"policy\": \"" + policyName + "\"\n" +
1252+
" }\n" +
1253+
" },\n" +
1254+
" {\n" +
1255+
" \"term\": {\n" +
1256+
" \"index\": \"" + indexName + "\"\n" +
1257+
" }\n" +
1258+
" }\n" +
1259+
" ]\n" +
1260+
" }\n" +
1261+
" }\n" +
1262+
"}");
1263+
final Response allResultsResp = client().performRequest(historySearchRequest);
1264+
Map<String, Object> allResultsMap;
1265+
try (InputStream is = allResultsResp.getEntity().getContent()) {
1266+
allResultsMap = XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true);
1267+
}
1268+
logger.info("--> expected at least 1 hit, got 0. All history for index [{}]: {}", index, allResultsMap);
1269+
}
1270+
assertThat(hits, greaterThanOrEqualTo(1));
12441271
} catch (ResponseException e) {
12451272
// Throw AssertionError instead of an exception if the search fails so that assertBusy works as expected
12461273
logger.error(e);

0 commit comments

Comments
 (0)