diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index bb88f9d094514..be4aa5dafa222 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -49,6 +49,7 @@ import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequestBuilder; import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.bulk.BulkResponse; +import org.elasticsearch.action.datastreams.GetDataStreamAction; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.ingest.DeletePipelineRequest; import org.elasticsearch.action.ingest.DeletePipelineTransportAction; @@ -81,6 +82,7 @@ import org.elasticsearch.cluster.InternalClusterInfoService; import org.elasticsearch.cluster.coordination.ElasticsearchNodeCommand; import org.elasticsearch.cluster.health.ClusterHealthStatus; +import org.elasticsearch.cluster.metadata.DataStream; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.node.DiscoveryNode; @@ -846,6 +848,22 @@ private static Settings.Builder getExcludeSettings(int num, Settings.Builder bui return builder; } + /** + * Returns a list of the data stream's backing index names. + */ + public List getDataStreamBackingIndexNames(String dataStreamName) { + GetDataStreamAction.Response response = safeGet( + client().execute( + GetDataStreamAction.INSTANCE, + new GetDataStreamAction.Request(TEST_REQUEST_TIMEOUT, new String[] { dataStreamName }) + ) + ); + assertThat(response.getDataStreams().size(), equalTo(1)); + DataStream dataStream = response.getDataStreams().getFirst().getDataStream(); + assertThat(dataStream.getName(), equalTo(dataStreamName)); + return dataStream.getIndices().stream().map(Index::getName).toList(); + } + /** * Waits until all nodes have no pending tasks. */ diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java index 490bfbea77fcf..6122a7f3e4863 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java @@ -2024,6 +2024,20 @@ protected static boolean aliasExists(String index, String alias) throws IOExcept return RestStatus.OK.getStatus() == response.getStatusLine().getStatusCode(); } + /** + * Returns a list of the data stream's backing index names. + */ + @SuppressWarnings("unchecked") + protected static List getDataStreamBackingIndexNames(String dataStreamName) throws IOException { + Map response = getAsMap(client(), "/_data_stream/" + dataStreamName); + List dataStreams = (List) response.get("data_streams"); + assertThat(dataStreams.size(), equalTo(1)); + Map dataStream = (Map) dataStreams.getFirst(); + assertThat(dataStream.get("name"), equalTo(dataStreamName)); + List indices = (List) dataStream.get("indices"); + return indices.stream().map(index -> ((Map) index).get("index_name")).toList(); + } + @SuppressWarnings("unchecked") protected static Map getAlias(final String index, final String alias) throws IOException { String endpoint = "/_alias"; diff --git a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/LifecycleLicenseIT.java b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/LifecycleLicenseIT.java index afaae559c1644..b907d3ab7978b 100644 --- a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/LifecycleLicenseIT.java +++ b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/LifecycleLicenseIT.java @@ -11,7 +11,6 @@ import org.elasticsearch.client.Request; import org.elasticsearch.client.Response; import org.elasticsearch.client.ResponseException; -import org.elasticsearch.cluster.metadata.DataStream; import org.elasticsearch.cluster.metadata.Template; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; @@ -30,6 +29,7 @@ import org.junit.Before; import java.io.IOException; +import java.util.List; import java.util.Locale; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -41,6 +41,7 @@ import static org.elasticsearch.xpack.TimeSeriesRestDriver.indexDocument; import static org.elasticsearch.xpack.TimeSeriesRestDriver.rolloverMaxOneDocCondition; import static org.hamcrest.CoreMatchers.containsStringIgnoringCase; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.is; @@ -107,7 +108,9 @@ public void testSearchableSnapshotActionErrorsOnInvalidLicense() throws Exceptio // rolling over the data stream so we can apply the searchable snapshot policy to a backing index that's not the write index rolloverMaxOneDocCondition(client(), dataStream); - String backingIndexName = DataStream.getDefaultBackingIndexName(dataStream, 1L); + List backingIndices = getDataStreamBackingIndexNames(dataStream); + assertThat(backingIndices.size(), equalTo(2)); + String backingIndexName = backingIndices.getFirst(); // the searchable_snapshot action should start failing (and retrying) due to invalid license assertBusy(() -> { Map explainIndex = explainIndex(client(), backingIndexName); diff --git a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesDataStreamsIT.java b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesDataStreamsIT.java index 1faf29b64fc4a..d37a253b68f80 100644 --- a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesDataStreamsIT.java +++ b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesDataStreamsIT.java @@ -40,7 +40,6 @@ import static org.elasticsearch.xpack.TimeSeriesRestDriver.createNewSingletonPolicy; import static org.elasticsearch.xpack.TimeSeriesRestDriver.createSnapshotRepo; import static org.elasticsearch.xpack.TimeSeriesRestDriver.explainIndex; -import static org.elasticsearch.xpack.TimeSeriesRestDriver.getBackingIndices; import static org.elasticsearch.xpack.TimeSeriesRestDriver.getOnlyIndexSettings; import static org.elasticsearch.xpack.TimeSeriesRestDriver.getStepKeyForIndex; import static org.elasticsearch.xpack.TimeSeriesRestDriver.getTemplate; @@ -81,12 +80,12 @@ public void testRolloverAction() throws Exception { indexDocument(client(), dataStream, true); assertBusy(() -> { - final var backingIndices = getBackingIndices(client(), dataStream); + final var backingIndices = getDataStreamBackingIndexNames(dataStream); assertEquals(2, backingIndices.size()); assertTrue(Boolean.parseBoolean((String) getIndexSettingsAsMap(backingIndices.getLast()).get("index.hidden"))); }); assertBusy(() -> { - final var backingIndices = getBackingIndices(client(), dataStream); + final var backingIndices = getDataStreamBackingIndexNames(dataStream); assertEquals(PhaseCompleteStep.finalStep("hot").getKey(), getStepKeyForIndex(client(), backingIndices.getFirst())); }); } @@ -98,7 +97,7 @@ public void testRolloverIsSkippedOnManualDataStreamRollover() throws Exception { indexDocument(client(), dataStream, true); - String firstGenerationIndex = getBackingIndices(client(), dataStream).getFirst(); + String firstGenerationIndex = getDataStreamBackingIndexNames(dataStream).getFirst(); assertBusy( () -> assertThat(getStepKeyForIndex(client(), firstGenerationIndex).name(), equalTo(WaitForRolloverReadyStep.NAME)), 30, @@ -107,7 +106,7 @@ public void testRolloverIsSkippedOnManualDataStreamRollover() throws Exception { rolloverMaxOneDocCondition(client(), dataStream); assertBusy(() -> { - final var backingIndices = getBackingIndices(client(), dataStream); + final var backingIndices = getDataStreamBackingIndexNames(dataStream); assertEquals(2, backingIndices.size()); }, 30, TimeUnit.SECONDS); @@ -125,7 +124,7 @@ public void testShrinkActionInPolicyWithoutHotPhase() throws Exception { createComposableTemplate(client(), template, dataStream + "*", getTemplate(policyName)); indexDocument(client(), dataStream, true); - String backingIndexName = getBackingIndices(client(), dataStream).getFirst(); + String backingIndexName = getDataStreamBackingIndexNames(dataStream).getFirst(); assertBusy( () -> assertThat( "original index must wait in the " + CheckNotDataStreamWriteIndexStep.NAME + " until it is not the write index anymore", @@ -140,7 +139,7 @@ public void testShrinkActionInPolicyWithoutHotPhase() throws Exception { rolloverMaxOneDocCondition(client(), dataStream); // Wait for rollover to happen assertBusy( - () -> assertEquals("the rollover action created the rollover index", 2, getBackingIndices(client(), dataStream).size()), + () -> assertEquals("the rollover action created the rollover index", 2, getDataStreamBackingIndexNames(dataStream).size()), 30, TimeUnit.SECONDS ); @@ -159,7 +158,7 @@ public void testSearchableSnapshotAction() throws Exception { createComposableTemplate(client(), template, dataStream + "*", getTemplate(policyName)); indexDocument(client(), dataStream, true); - String backingIndexName = getBackingIndices(client(), dataStream).getFirst(); + String backingIndexName = getDataStreamBackingIndexNames(dataStream).getFirst(); String restoredIndexName = SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX + backingIndexName; assertBusy( @@ -190,7 +189,7 @@ public void testReadOnlyAction() throws Exception { createComposableTemplate(client(), template, dataStream + "*", getTemplate(policyName)); indexDocument(client(), dataStream, true); - String backingIndexName = getBackingIndices(client(), dataStream).getFirst(); + String backingIndexName = getDataStreamBackingIndexNames(dataStream).getFirst(); assertBusy( () -> assertThat( "index must wait in the " + CheckNotDataStreamWriteIndexStep.NAME + " until it is not the write index anymore", @@ -225,7 +224,7 @@ public void testFreezeAction() throws Exception { indexDocument(client(), dataStream, true); // The freeze action is a noop action with only noop steps and should pass through to complete the phase asap. - String backingIndexName = getBackingIndices(client(), dataStream).getFirst(); + String backingIndexName = getDataStreamBackingIndexNames(dataStream).getFirst(); assertBusy(() -> { try { assertThat(explainIndex(client(), backingIndexName).get("step"), is(PhaseCompleteStep.NAME)); @@ -247,7 +246,7 @@ public void checkForceMergeAction(String codec) throws Exception { createComposableTemplate(client(), template, dataStream + "*", getTemplate(policyName)); indexDocument(client(), dataStream, true); - String backingIndexName = getBackingIndices(client(), dataStream).getFirst(); + String backingIndexName = getDataStreamBackingIndexNames(dataStream).getFirst(); assertBusy( () -> assertThat( "index must wait in the " + CheckNotDataStreamWriteIndexStep.NAME + " until it is not the write index anymore", @@ -321,7 +320,7 @@ public void testDataStreamWithMultipleIndicesAndWriteIndexInDeletePhase() throws client().performRequest(new Request("POST", dataStream + "/_rollover")); indexDocument(client(), dataStream, true); - String secondGenerationIndex = getBackingIndices(client(), dataStream).get(1); + String secondGenerationIndex = getDataStreamBackingIndexNames(dataStream).get(1); assertBusy(() -> { Request explainRequest = new Request("GET", "/_data_stream/" + dataStream); Response response = client().performRequest(explainRequest); diff --git a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java index 23a8dbd220118..c5ba16e883ef5 100644 --- a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java +++ b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/TimeSeriesLifecycleActionsIT.java @@ -15,7 +15,6 @@ import org.elasticsearch.client.Response; import org.elasticsearch.client.ResponseException; import org.elasticsearch.client.WarningFailureException; -import org.elasticsearch.cluster.metadata.DataStream; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; @@ -1231,7 +1230,7 @@ private void assertHistoryIsPresent( } // Finally, check that the history index is in a good state - String historyIndexName = DataStream.getDefaultBackingIndexName("ilm-history-7", 1); + String historyIndexName = getDataStreamBackingIndexNames("ilm-history-7").getFirst(); Response explainHistoryIndex = client().performRequest(new Request("GET", historyIndexName + "/_lifecycle/explain")); Map responseMap; try (InputStream is = explainHistoryIndex.getEntity().getContent()) { diff --git a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/DownsampleActionIT.java b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/DownsampleActionIT.java index d4ecff4238591..843a8ff8f4a42 100644 --- a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/DownsampleActionIT.java +++ b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/DownsampleActionIT.java @@ -11,7 +11,6 @@ import org.elasticsearch.client.Response; import org.elasticsearch.client.ResponseException; import org.elasticsearch.client.RestClient; -import org.elasticsearch.cluster.metadata.DataStream; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.IndexMetadata.DownsampleTaskStatus; import org.elasticsearch.common.Strings; @@ -49,7 +48,6 @@ import static org.elasticsearch.xpack.TimeSeriesRestDriver.createIndexWithSettings; import static org.elasticsearch.xpack.TimeSeriesRestDriver.createNewSingletonPolicy; import static org.elasticsearch.xpack.TimeSeriesRestDriver.explainIndex; -import static org.elasticsearch.xpack.TimeSeriesRestDriver.getBackingIndices; import static org.elasticsearch.xpack.TimeSeriesRestDriver.getOnlyIndexSettings; import static org.elasticsearch.xpack.TimeSeriesRestDriver.getStepKeyForIndex; import static org.elasticsearch.xpack.TimeSeriesRestDriver.index; @@ -318,7 +316,7 @@ public void testTsdbDataStreams() throws Exception { index(client(), dataStream, true, null, "@timestamp", "2020-01-01T05:10:00Z", "volume", 11.0, "metricset", randomAlphaOfLength(5)); - String backingIndexName = DataStream.getDefaultBackingIndexName(dataStream, 1); + String backingIndexName = getDataStreamBackingIndexNames(dataStream).getFirst(); assertBusy( () -> assertThat( "index must wait in the " + CheckNotDataStreamWriteIndexStep.NAME + " until it is not the write index anymore", @@ -365,7 +363,7 @@ public void testILMWaitsForTimeSeriesEndTimeToLapse() throws Exception { String now = DateFormatter.forPattern(FormatNames.STRICT_DATE_OPTIONAL_TIME.getName()).format(Instant.now()); index(client(), dataStream, true, null, "@timestamp", now, "volume", 11.0, "metricset", randomAlphaOfLength(5)); - String backingIndexName = getBackingIndices(client(), dataStream).get(0); + String backingIndexName = getDataStreamBackingIndexNames(dataStream).getFirst(); assertBusy( () -> assertThat( "index must wait in the " + CheckNotDataStreamWriteIndexStep.NAME + " until it is not the write index anymore", @@ -459,7 +457,7 @@ public void testDownsampleTwice() throws Exception { index(client(), dataStream, true, null, "@timestamp", "2020-01-01T05:10:00Z", "volume", 11.0, "metricset", randomAlphaOfLength(5)); - String firstBackingIndex = DataStream.getDefaultBackingIndexName(dataStream, 1); + String firstBackingIndex = getDataStreamBackingIndexNames(dataStream).getFirst(); logger.info("--> firstBackingIndex: {}", firstBackingIndex); assertBusy( () -> assertThat( @@ -540,7 +538,7 @@ public void testDownsampleTwiceSameInterval() throws Exception { index(client(), dataStream, true, null, "@timestamp", "2020-01-01T05:10:00Z", "volume", 11.0, "metricset", randomAlphaOfLength(5)); - String firstBackingIndex = getBackingIndices(client(), dataStream).get(0); + String firstBackingIndex = getDataStreamBackingIndexNames(dataStream).getFirst(); logger.info("--> firstBackingIndex: {}", firstBackingIndex); assertBusy( () -> assertThat( diff --git a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/SearchableSnapshotActionIT.java b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/SearchableSnapshotActionIT.java index 708c74960343a..4fe3a075ec03c 100644 --- a/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/SearchableSnapshotActionIT.java +++ b/x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/actions/SearchableSnapshotActionIT.java @@ -13,7 +13,6 @@ import org.elasticsearch.client.Response; import org.elasticsearch.client.ResponseException; import org.elasticsearch.client.WarningFailureException; -import org.elasticsearch.cluster.metadata.DataStream; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.Template; import org.elasticsearch.cluster.routing.allocation.DataTier; @@ -57,7 +56,6 @@ import static org.elasticsearch.xpack.TimeSeriesRestDriver.createPolicy; import static org.elasticsearch.xpack.TimeSeriesRestDriver.createSnapshotRepo; import static org.elasticsearch.xpack.TimeSeriesRestDriver.explainIndex; -import static org.elasticsearch.xpack.TimeSeriesRestDriver.getBackingIndices; import static org.elasticsearch.xpack.TimeSeriesRestDriver.getNumberOfPrimarySegments; import static org.elasticsearch.xpack.TimeSeriesRestDriver.getStepKeyForIndex; import static org.elasticsearch.xpack.TimeSeriesRestDriver.indexDocument; @@ -104,7 +102,9 @@ public void testSearchableSnapshotAction() throws Exception { // rolling over the data stream so we can apply the searchable snapshot policy to a backing index that's not the write index rolloverMaxOneDocCondition(client(), dataStream); - String backingIndexName = DataStream.getDefaultBackingIndexName(dataStream, 1L); + List backingIndices = getDataStreamBackingIndexNames(dataStream); + assertThat(backingIndices.size(), equalTo(2)); + String backingIndexName = backingIndices.getFirst(); String restoredIndexName = SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX + backingIndexName; assertTrue(waitUntil(() -> { try { @@ -135,7 +135,8 @@ public void testSearchableSnapshotForceMergesIndexToOneSegment() throws Exceptio indexDocument(client(), dataStream, true); } - String backingIndexName = DataStream.getDefaultBackingIndexName(dataStream, 1L); + List backingIndices = getDataStreamBackingIndexNames(dataStream); + String backingIndexName = backingIndices.getFirst(); Integer preLifecycleBackingIndexSegments = getNumberOfPrimarySegments(client(), backingIndexName); assertThat(preLifecycleBackingIndexSegments, greaterThanOrEqualTo(1)); @@ -209,7 +210,9 @@ public void testDeleteActionDeletesSearchableSnapshot() throws Exception { // rolling over the data stream so we can apply the searchable snapshot policy to a backing index that's not the write index rolloverMaxOneDocCondition(client(), dataStream); - String backingIndexName = DataStream.getDefaultBackingIndexName(dataStream, 1L); + List backingIndices = getDataStreamBackingIndexNames(dataStream); + assertThat(backingIndices.size(), equalTo(2)); + String backingIndexName = backingIndices.getFirst(); String restoredIndexName = SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX + backingIndexName; // let's wait for ILM to finish @@ -301,7 +304,7 @@ public void testUpdatePolicyToAddPhasesYieldsInvalidActionsToBeSkipped() throws // rolling over the data stream so we can apply the searchable snapshot policy to a backing index that's not the write index indexDocument(client(), dataStream, true); - var backingIndices = getBackingIndices(client(), dataStream); + var backingIndices = getDataStreamBackingIndexNames(dataStream); String restoredIndexName = SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX + backingIndices.get(0); assertTrue(waitUntil(() -> { try { @@ -380,10 +383,8 @@ public void testRestoredIndexManagedByLocalPolicySkipsIllegalActions() throws Ex // indexing only one document as we want only one rollover to be triggered indexDocument(client(), dataStream, true); - String searchableSnapMountedIndexName = SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX + DataStream.getDefaultBackingIndexName( - dataStream, - 1L - ); + String backingIndexName = getDataStreamBackingIndexNames(dataStream).getFirst(); + String searchableSnapMountedIndexName = SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX + backingIndexName; assertTrue(waitUntil(() -> { try { return indexExists(searchableSnapMountedIndexName); @@ -872,7 +873,7 @@ public void testSearchableSnapshotsInHotPhasePinnedToHotNodes() throws Exception // Create the data stream. assertOK(client().performRequest(new Request("PUT", "_data_stream/" + dataStream))); - var backingIndices = getBackingIndices(client(), dataStream); + var backingIndices = getDataStreamBackingIndexNames(dataStream); String firstGenIndex = backingIndices.get(0); Map indexSettings = getIndexSettingsAsMap(firstGenIndex); assertThat(indexSettings.get(DataTier.TIER_PREFERENCE), is("data_hot")); @@ -923,7 +924,9 @@ public void testSearchableSnapshotInvokesAsyncActionOnNewIndex() throws Exceptio // rolling over the data stream so we can apply the searchable snapshot policy to a backing index that's not the write index rolloverMaxOneDocCondition(client(), dataStream); - String backingIndexName = DataStream.getDefaultBackingIndexName(dataStream, 1L); + List backingIndices = getDataStreamBackingIndexNames(dataStream); + assertThat(backingIndices.size(), equalTo(2)); + String backingIndexName = backingIndices.getFirst(); String restoredIndexName = SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX + backingIndexName; assertTrue(waitUntil(() -> { try { @@ -1027,7 +1030,9 @@ public void testSearchableSnapshotReplicateFor() throws Exception { // rolling over the data stream so we can apply the searchable snapshot policy to a backing index that's not the write index rolloverMaxOneDocCondition(client(), dataStream); - String backingIndexName = DataStream.getDefaultBackingIndexName(dataStream, 1L); + List backingIndices = getDataStreamBackingIndexNames(dataStream); + assertThat(backingIndices.size(), equalTo(2)); + String backingIndexName = backingIndices.getFirst(); String restoredIndexName = SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX + backingIndexName; assertTrue(waitUntil(() -> { try { diff --git a/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/ILMMultiNodeIT.java b/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/ILMMultiNodeIT.java index 3f92abc7e3da2..a75bd0b09b2d5 100644 --- a/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/ILMMultiNodeIT.java +++ b/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/ILMMultiNodeIT.java @@ -9,7 +9,6 @@ import org.elasticsearch.action.admin.indices.template.put.TransportPutComposableIndexTemplateAction; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.metadata.DataStream; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.Template; import org.elasticsearch.common.Strings; @@ -105,7 +104,7 @@ public void testShrinkOnTiers() throws Exception { ).get(); logger.info("--> explain: {}", Strings.toString(explain)); - String backingIndexName = DataStream.getDefaultBackingIndexName(index, 1); + String backingIndexName = getDataStreamBackingIndexNames(index).getFirst(); IndexLifecycleExplainResponse indexResp = null; for (Map.Entry indexNameAndResp : explain.getIndexResponses().entrySet()) { if (indexNameAndResp.getKey().startsWith(SHRUNKEN_INDEX_PREFIX) && indexNameAndResp.getKey().contains(backingIndexName)) { diff --git a/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/ILMMultiNodeWithCCRDisabledIT.java b/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/ILMMultiNodeWithCCRDisabledIT.java index c695dc8f87b68..1655125c7696d 100644 --- a/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/ILMMultiNodeWithCCRDisabledIT.java +++ b/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/ILMMultiNodeWithCCRDisabledIT.java @@ -9,7 +9,6 @@ import org.elasticsearch.action.admin.indices.template.put.TransportPutComposableIndexTemplateAction; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; -import org.elasticsearch.cluster.metadata.DataStream; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.Template; import org.elasticsearch.common.Strings; @@ -105,7 +104,7 @@ public void testShrinkOnTiers() throws Exception { ).get(); logger.info("--> explain: {}", Strings.toString(explain)); - String backingIndexName = DataStream.getDefaultBackingIndexName(index, 1); + String backingIndexName = getDataStreamBackingIndexNames(index).getFirst(); IndexLifecycleExplainResponse indexResp = null; for (Map.Entry indexNameAndResp : explain.getIndexResponses().entrySet()) { if (indexNameAndResp.getKey().startsWith(SHRUNKEN_INDEX_PREFIX) && indexNameAndResp.getKey().contains(backingIndexName)) {