Skip to content

Commit 6249b08

Browse files
lktsmridula-s109
authored andcommitted
Tighten asserts in FullClusterRestartSystemIndexCompatibilityIT and provide more context for failures (elastic#134754)
1 parent bed2527 commit 6249b08

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

qa/lucene-index-compatibility/src/javaRestTest/java/org/elasticsearch/lucene/FullClusterRestartSystemIndexCompatibilityIT.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void testAsyncSearchIndexMigration() throws Exception {
6767
String asyncId = searchAsyncAndStoreId(asyncSearchRequest, "n-2_id");
6868
ensureGreen(asyncSearchIndex);
6969

70-
assertAsyncSearchHitCount(asyncId, numDocs);
70+
assertBusy(() -> assertAsyncSearchHitCount(asyncId, numDocs));
7171
assertBusy(() -> assertDocCountNoWarnings(client(), asyncSearchIndex, 1));
7272
assertThat(indexVersion(asyncSearchIndex, true), equalTo(VERSION_MINUS_2));
7373
return;
@@ -103,7 +103,7 @@ public void testAsyncSearchIndexMigration() throws Exception {
103103

104104
// perform new async search and check its readable
105105
String asyncId = searchAsyncAndStoreId(asyncSearchRequest, "n-1_id");
106-
assertAsyncSearchHitCount(asyncId, numDocs);
106+
assertBusy(() -> assertAsyncSearchHitCount(asyncId, numDocs));
107107
assertBusy(() -> assertDocCountNoWarnings(client(), asyncSearchIndex, 2));
108108

109109
// in order to move to current version we need write block for n-2 index
@@ -117,7 +117,7 @@ public void testAsyncSearchIndexMigration() throws Exception {
117117

118118
// check system index is still writeable
119119
String asyncId = searchAsyncAndStoreId(asyncSearchRequest, "n_id");
120-
assertAsyncSearchHitCount(asyncId, numDocs);
120+
assertBusy(() -> assertAsyncSearchHitCount(asyncId, numDocs));
121121
assertBusy(() -> assertDocCountNoWarnings(client(), asyncSearchIndex, 3));
122122
}
123123

@@ -134,7 +134,13 @@ private static String searchAsyncAndStoreId(Request asyncSearchRequest, String a
134134
private static void assertAsyncSearchHitCount(String asyncId, int numDocs) throws IOException {
135135
var asyncGet = new Request("GET", "/_async_search/" + asyncId);
136136
ObjectPath resp = ObjectPath.createFromResponse(client().performRequest(asyncGet));
137-
assertEquals(Integer.valueOf(numDocs), resp.evaluate("response.hits.total.value"));
137+
assertFalse("Async search is not complete", resp.evaluate("is_running"));
138+
assertFalse("Async search has partial results", resp.evaluate("is_partial"));
139+
assertEquals(
140+
"Unexpected number of hits in search response. Response: \n" + resp.evaluate("response"),
141+
Integer.valueOf(numDocs),
142+
resp.evaluate("response.hits.total.value")
143+
);
138144
}
139145

140146
/**

0 commit comments

Comments
 (0)