Skip to content

Commit

Permalink
Merge remote-tracking branch 'elastic/master' into consistent-cs-for-…
Browse files Browse the repository at this point in the history
…snapshot-status-apis
  • Loading branch information
original-brownbear committed Jan 27, 2020
2 parents f2efe16 + 4e95c8a commit bb2ded5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,14 @@ public void testMoveToRolloverStep() throws Exception {
// asserts that rollover was called
assertBusy(() -> assertTrue(indexExists(secondIndex)));
// asserts that shrink deleted the original index
assertBusy(() -> assertFalse(indexExists(originalIndex)), 20, TimeUnit.SECONDS);
assertBusy(() -> assertFalse(indexExists(originalIndex)), 30, TimeUnit.SECONDS);
// asserts that the delete phase completed for the managed shrunken index
assertBusy(() -> assertFalse(indexExists(shrunkenOriginalIndex)));
}

public void testRetryFailedShrinkAction() throws Exception {
int numShards = 6;
int divisor = randomFrom(2, 3, 6);
int numShards = 4;
int divisor = randomFrom(2, 4);
int expectedFinalShards = numShards / divisor;
String shrunkenIndex = ShrinkAction.SHRUNKEN_INDEX_PREFIX + index;
createIndexWithSettings(index, Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numShards)
Expand All @@ -227,12 +227,11 @@ public void testRetryFailedShrinkAction() throws Exception {
assertOK(client().performRequest(retryRequest));

// assert corrected policy is picked up and index is shrunken
assertBusy(() -> assertTrue(indexExists(shrunkenIndex)), 30, TimeUnit.SECONDS);
assertBusy(() -> assertTrue(aliasExists(shrunkenIndex, index)));
assertBusy(() -> assertThat(getStepKeyForIndex(shrunkenIndex), equalTo(TerminalPolicyStep.KEY)));
assertBusy(() -> {
logger.error(explainIndex(index));
assertTrue(indexExists(shrunkenIndex));
assertTrue(aliasExists(shrunkenIndex, index));
Map<String, Object> settings = getOnlyIndexSettings(shrunkenIndex);
assertThat(getStepKeyForIndex(shrunkenIndex), equalTo(TerminalPolicyStep.KEY));
assertThat(settings.get(IndexMetaData.SETTING_NUMBER_OF_SHARDS), equalTo(String.valueOf(expectedFinalShards)));
assertThat(settings.get(IndexMetaData.INDEX_BLOCKS_WRITE_SETTING.getKey()), equalTo("true"));
assertThat(settings.get(IndexMetaData.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + "_id"), nullValue());
Expand Down Expand Up @@ -493,19 +492,19 @@ public void testForceMergeAction() throws Exception {
}

public void testShrinkAction() throws Exception {
int numShards = 6;
int divisor = randomFrom(2, 3, 6);
int numShards = 4;
int divisor = randomFrom(2, 4);
int expectedFinalShards = numShards / divisor;
String shrunkenIndex = ShrinkAction.SHRUNKEN_INDEX_PREFIX + index;
createIndexWithSettings(index, Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numShards)
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0));
createNewSingletonPolicy("warm", new ShrinkAction(expectedFinalShards));
updatePolicy(index, policy);
assertBusy(() -> assertTrue(indexExists(shrunkenIndex)), 30, TimeUnit.SECONDS);
assertBusy(() -> assertTrue(aliasExists(shrunkenIndex, index)));
assertBusy(() -> assertThat(getStepKeyForIndex(shrunkenIndex), equalTo(TerminalPolicyStep.KEY)));
assertBusy(() -> {
assertTrue(indexExists(shrunkenIndex));
assertTrue(aliasExists(shrunkenIndex, index));
Map<String, Object> settings = getOnlyIndexSettings(shrunkenIndex);
assertThat(getStepKeyForIndex(shrunkenIndex), equalTo(TerminalPolicyStep.KEY));
assertThat(settings.get(IndexMetaData.SETTING_NUMBER_OF_SHARDS), equalTo(String.valueOf(expectedFinalShards)));
assertThat(settings.get(IndexMetaData.INDEX_BLOCKS_WRITE_SETTING.getKey()), equalTo("true"));
assertThat(settings.get(IndexMetaData.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + "_id"), nullValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ protected boolean waitForAllSnapshotsWiped() {
return true;
}

// as we are testing the SLM history entries we'll preserve the "slm-history-ilm-policy" policy as it'll be associated with the
// .slm-history-* indices and we won't be able to delete it when we wipe out the cluster
@Override
protected boolean preserveILMPoliciesUponCompletion() {
return true;
}

public void testMissingRepo() throws Exception {
SnapshotLifecyclePolicy policy = new SnapshotLifecyclePolicy("missing-repo-policy", "snap",
"*/1 * * * * ?", "missing-repo", Collections.emptyMap(), SnapshotRetentionConfiguration.EMPTY);
Expand Down

0 comments on commit bb2ded5

Please sign in to comment.