Skip to content

Commit 2dbc444

Browse files
authored
Tests: fix testMoveToStepRereadsPolicy flakiness (#64466) (#64593)
testMoveToStepRereadsPolicy relied on an updated ILM policy that had a rollover condition that enabled the index to be rolled after one second. This changes the test to use a `max_doc`:1 condition so it's under the test's control to trigger the condition. (cherry picked from commit 73ab35a) Signed-off-by: Andrei Dan <[email protected]>
1 parent 275626e commit 2dbc444

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeseriesMoveToStepIT.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import static org.elasticsearch.xpack.TimeSeriesRestDriver.createNewSingletonPolicy;
3232
import static org.elasticsearch.xpack.TimeSeriesRestDriver.getStepKeyForIndex;
3333
import static org.elasticsearch.xpack.TimeSeriesRestDriver.index;
34+
import static org.elasticsearch.xpack.TimeSeriesRestDriver.indexDocument;
3435
import static org.hamcrest.Matchers.containsStringIgnoringCase;
3536
import static org.hamcrest.Matchers.equalTo;
3637

@@ -158,7 +159,6 @@ public void testMoveToInjectedStep() throws Exception {
158159
}, 30, TimeUnit.SECONDS);
159160
}
160161

161-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/53612")
162162
public void testMoveToStepRereadsPolicy() throws Exception {
163163
createNewSingletonPolicy(client(), policy, "hot", new RolloverAction(null, TimeValue.timeValueHours(1), null), TimeValue.ZERO);
164164

@@ -170,9 +170,9 @@ public void testMoveToStepRereadsPolicy() throws Exception {
170170
true);
171171

172172
assertBusy(() -> assertThat(getStepKeyForIndex(client(), "test-1"),
173-
equalTo(new StepKey("hot", "rollover", "check-rollover-ready"))));
173+
equalTo(new StepKey("hot", "rollover", "check-rollover-ready"))), 30, TimeUnit.SECONDS);
174174

175-
createNewSingletonPolicy(client(), policy, "hot", new RolloverAction(null, TimeValue.timeValueSeconds(1), null), TimeValue.ZERO);
175+
createNewSingletonPolicy(client(), policy, "hot", new RolloverAction(null, null, 1L), TimeValue.ZERO);
176176

177177
// Move to the same step, which should re-read the policy
178178
Request moveToStepRequest = new Request("POST", "_ilm/move/test-1");
@@ -188,7 +188,12 @@ public void testMoveToStepRereadsPolicy() throws Exception {
188188
" \"name\": \"check-rollover-ready\"\n" +
189189
" }\n" +
190190
"}");
191-
assertOK(client().performRequest(moveToStepRequest));
191+
// busy asserting here as ILM moves the index from the `check-rollover-ready` step into the `error` step and back into the
192+
// `check-rollover-ready` when retrying. the `_ilm/move` api might fail when the as the `current_step` of the index might be
193+
// the `error` step at execution time.
194+
assertBusy(() -> client().performRequest(moveToStepRequest), 30, TimeUnit.SECONDS);
195+
196+
indexDocument(client(), "test-1", true);
192197

193198
// Make sure we actually rolled over
194199
assertBusy(() -> {

0 commit comments

Comments
 (0)