Skip to content

Commit cf1f3ef

Browse files
authored
Fix testCannotShrinkLeaderIndex (#38529)
This test should no longer pass when the functionality it is intended to test is broken, as it now indexes a number of documents and verifies that the index is staying on the same step until after indexing and replication of those documents is finished. This prevents the test from passing if the leader index progresses in its lifecycle during that time.
1 parent 3c812d9 commit cf1f3ef

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

x-pack/plugin/ilm/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/indexlifecycle/CCRIndexLifecycleIT.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,7 @@ public void testCannotShrinkLeaderIndex() throws Exception {
358358
changePolicyRequest.setEntity(changePolicyEntity);
359359
assertOK(leaderClient.performRequest(changePolicyRequest));
360360

361-
index(leaderClient, indexName, "1");
362-
assertDocumentExists(leaderClient, indexName, "1");
363-
364361
assertBusy(() -> {
365-
assertDocumentExists(client(), indexName, "1");
366362
// Sanity check that following_index setting has been set, so that we can verify later that this setting has been unset:
367363
assertThat(getIndexSetting(client(), indexName, "index.xpack.ccr.following_index"), equalTo("true"));
368364

@@ -371,6 +367,20 @@ public void testCannotShrinkLeaderIndex() throws Exception {
371367
assertILMPolicy(client(), indexName, policyName, "hot", "unfollow", "wait-for-indexing-complete");
372368
});
373369

370+
// Index a bunch of documents and wait for them to be replicated
371+
for (int i = 0; i < 50; i++) {
372+
index(leaderClient, indexName, Integer.toString(i));
373+
}
374+
assertBusy(() -> {
375+
for (int i = 0; i < 50; i++) {
376+
assertDocumentExists(client(), indexName, Integer.toString(i));
377+
}
378+
});
379+
380+
// Then make sure both leader and follower are still both waiting
381+
assertILMPolicy(leaderClient, indexName, policyName, "warm", "shrink", "wait-for-shard-history-leases");
382+
assertILMPolicy(client(), indexName, policyName, "hot", "unfollow", "wait-for-indexing-complete");
383+
374384
// Manually set this to kick the process
375385
updateIndexSettings(leaderClient, indexName, Settings.builder()
376386
.put("index.lifecycle.indexing_complete", true)

0 commit comments

Comments
 (0)