Skip to content

Commit

Permalink
Fix testCannotShrinkLeaderIndex (#38529)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gwbrown authored Feb 22, 2019
1 parent c899f63 commit c571a24
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,7 @@ public void testCannotShrinkLeaderIndex() throws Exception {
changePolicyRequest.setEntity(changePolicyEntity);
assertOK(leaderClient.performRequest(changePolicyRequest));

index(leaderClient, indexName, "1");
assertDocumentExists(leaderClient, indexName, "1");

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

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

// Index a bunch of documents and wait for them to be replicated
for (int i = 0; i < 50; i++) {
index(leaderClient, indexName, Integer.toString(i));
}
assertBusy(() -> {
for (int i = 0; i < 50; i++) {
assertDocumentExists(client(), indexName, Integer.toString(i));
}
});

// Then make sure both leader and follower are still both waiting
assertILMPolicy(leaderClient, indexName, policyName, "warm", "shrink", "wait-for-shard-history-leases");
assertILMPolicy(client(), indexName, policyName, "hot", "unfollow", "wait-for-indexing-complete");

// Manually set this to kick the process
updateIndexSettings(leaderClient, indexName, Settings.builder()
.put("index.lifecycle.indexing_complete", true)
Expand Down

0 comments on commit c571a24

Please sign in to comment.