Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.cluster.metadata.DataStream;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.metadata.Template;
import org.elasticsearch.common.xcontent.XContentHelper;
Expand Down Expand Up @@ -80,20 +79,15 @@ public void testRolloverAction() throws Exception {

indexDocument(client(), dataStream, true);

assertBusy(() -> assertTrue(indexExists(DataStream.getDefaultBackingIndexName(dataStream, 2))));
assertBusy(
() -> assertTrue(
Boolean.parseBoolean(
(String) getIndexSettingsAsMap(DataStream.getDefaultBackingIndexName(dataStream, 2)).get("index.hidden")
)
)
);
assertBusy(
() -> assertThat(
getStepKeyForIndex(client(), DataStream.getDefaultBackingIndexName(dataStream, 1)),
equalTo(PhaseCompleteStep.finalStep("hot").getKey())
)
);
assertBusy(() -> {
final var backingIndices = getBackingIndices(client(), dataStream);
assertEquals(2, backingIndices.size());
assertTrue(Boolean.parseBoolean((String) getIndexSettingsAsMap(backingIndices.get(1)).get("index.hidden")));
});
assertBusy(() -> {
final var backingIndices = getBackingIndices(client(), dataStream);
assertEquals(PhaseCompleteStep.finalStep("hot").getKey(), getStepKeyForIndex(client(), backingIndices.get(0)));
});
}

public void testRolloverIsSkippedOnManualDataStreamRollover() throws Exception {
Expand All @@ -103,15 +97,18 @@ public void testRolloverIsSkippedOnManualDataStreamRollover() throws Exception {

indexDocument(client(), dataStream, true);

String firstGenerationIndex = DataStream.getDefaultBackingIndexName(dataStream, 1);
String firstGenerationIndex = getBackingIndices(client(), dataStream).get(0);
assertBusy(
() -> assertThat(getStepKeyForIndex(client(), firstGenerationIndex).name(), equalTo(WaitForRolloverReadyStep.NAME)),
30,
TimeUnit.SECONDS
);

rolloverMaxOneDocCondition(client(), dataStream);
assertBusy(() -> assertThat(indexExists(DataStream.getDefaultBackingIndexName(dataStream, 2)), is(true)), 30, TimeUnit.SECONDS);
assertBusy(() -> {
final var backingIndices = getBackingIndices(client(), dataStream);
assertEquals(2, backingIndices.size());
}, 30, TimeUnit.SECONDS);

// even though the first index doesn't have 2 documents to fulfill the rollover condition, it should complete the rollover action
// because it's not the write index anymore
Expand All @@ -128,7 +125,7 @@ public void testShrinkActionInPolicyWithoutHotPhase() throws Exception {
createComposableTemplate(client(), template, dataStream + "*", getTemplate(policyName));
indexDocument(client(), dataStream, true);

String backingIndexName = DataStream.getDefaultBackingIndexName(dataStream, 1);
String backingIndexName = getBackingIndices(client(), dataStream).get(0);
assertBusy(
() -> assertThat(
"original index must wait in the " + CheckNotDataStreamWriteIndexStep.NAME + " until it is not the write index anymore",
Expand All @@ -142,8 +139,11 @@ public void testShrinkActionInPolicyWithoutHotPhase() throws Exception {
// Manual rollover the original index such that it's not the write index in the data stream anymore
rolloverMaxOneDocCondition(client(), dataStream);
// Wait for rollover to happen
String rolloverIndex = DataStream.getDefaultBackingIndexName(dataStream, 2);
assertBusy(() -> assertTrue("the rollover action created the rollover index", indexExists(rolloverIndex)), 30, TimeUnit.SECONDS);
assertBusy(
() -> assertEquals("the rollover action created the rollover index", 2, getBackingIndices(client(), dataStream).size()),
30,
TimeUnit.SECONDS
);

String shrunkenIndex = waitAndGetShrinkIndexName(client(), backingIndexName);
assertBusy(() -> assertTrue(indexExists(shrunkenIndex)), 30, TimeUnit.SECONDS);
Expand All @@ -159,7 +159,7 @@ public void testSearchableSnapshotAction() throws Exception {
createComposableTemplate(client(), template, dataStream + "*", getTemplate(policyName));
indexDocument(client(), dataStream, true);

String backingIndexName = DataStream.getDefaultBackingIndexName(dataStream, 1);
String backingIndexName = getBackingIndices(client(), dataStream).get(0);
String restoredIndexName = SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX + backingIndexName;

assertBusy(
Expand Down Expand Up @@ -190,7 +190,7 @@ public void testReadOnlyAction() throws Exception {
createComposableTemplate(client(), template, dataStream + "*", getTemplate(policyName));
indexDocument(client(), dataStream, true);

String backingIndexName = DataStream.getDefaultBackingIndexName(dataStream, 1);
String backingIndexName = getBackingIndices(client(), dataStream).get(0);
assertBusy(
() -> assertThat(
"index must wait in the " + CheckNotDataStreamWriteIndexStep.NAME + " until it is not the write index anymore",
Expand Down Expand Up @@ -220,7 +220,7 @@ public void testFreezeAction() throws Exception {
createComposableTemplate(client(), template, dataStream + "*", getTemplate(policyName));
indexDocument(client(), dataStream, true);

String backingIndexName = DataStream.getDefaultBackingIndexName(dataStream, 1);
String backingIndexName = getBackingIndices(client(), dataStream).get(0);
assertBusy(
() -> assertThat(
"index must wait in the " + CheckNotDataStreamWriteIndexStep.NAME + " until it is not the write index anymore",
Expand Down Expand Up @@ -249,7 +249,7 @@ public void checkForceMergeAction(String codec) throws Exception {
createComposableTemplate(client(), template, dataStream + "*", getTemplate(policyName));
indexDocument(client(), dataStream, true);

String backingIndexName = DataStream.getDefaultBackingIndexName(dataStream, 1);
String backingIndexName = getBackingIndices(client(), dataStream).get(0);
assertBusy(
() -> assertThat(
"index must wait in the " + CheckNotDataStreamWriteIndexStep.NAME + " until it is not the write index anymore",
Expand Down