Skip to content

Commit 60f9b63

Browse files
authored
Unmute DataStreamsSnapshotsIT#testRestoreDataStreamAliasWithConflictingIndicesAlias() test (#81142)
and fix the test problem, which is that testRestoreDataStreamAliasWithConflictingDataStream() test needs to remove the composable index template that it adds. The base test class doesn't remove any composable index templates and this template interferes with the testRestoreDataStreamAliasWithConflictingIndicesAlias() test. Relates to #81040
1 parent 63d710d commit 60f9b63

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

x-pack/plugin/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamsSnapshotsIT.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
2424
import org.elasticsearch.action.admin.indices.rollover.RolloverRequest;
2525
import org.elasticsearch.action.admin.indices.rollover.RolloverResponse;
26+
import org.elasticsearch.action.admin.indices.template.delete.DeleteComposableIndexTemplateAction;
2627
import org.elasticsearch.action.index.IndexResponse;
2728
import org.elasticsearch.action.support.IndicesOptions;
2829
import org.elasticsearch.action.support.master.AcknowledgedResponse;
@@ -1083,17 +1084,23 @@ public void testRestoreDataStreamAliasWithConflictingDataStream() throws Excepti
10831084
createFullSnapshot(REPO, snapshotName);
10841085
client.execute(DeleteDataStreamAction.INSTANCE, new DeleteDataStreamAction.Request("*")).actionGet();
10851086
DataStreamIT.putComposableIndexTemplate("my-template", List.of("my-*"));
1086-
var request = new CreateDataStreamAction.Request("my-alias");
1087-
assertAcked(client.execute(CreateDataStreamAction.INSTANCE, request).actionGet());
1088-
1089-
var e = expectThrows(
1090-
IllegalStateException.class,
1091-
() -> client.admin().cluster().prepareRestoreSnapshot(REPO, snapshotName).setWaitForCompletion(true).get()
1092-
);
1093-
assertThat(e.getMessage(), containsString("data stream alias and data stream have the same name (my-alias)"));
1087+
try {
1088+
var request = new CreateDataStreamAction.Request("my-alias");
1089+
assertAcked(client.execute(CreateDataStreamAction.INSTANCE, request).actionGet());
1090+
var e = expectThrows(
1091+
IllegalStateException.class,
1092+
() -> client.admin().cluster().prepareRestoreSnapshot(REPO, snapshotName).setWaitForCompletion(true).get()
1093+
);
1094+
assertThat(e.getMessage(), containsString("data stream alias and data stream have the same name (my-alias)"));
1095+
} finally {
1096+
// Need to remove data streams in order to remove template
1097+
client.execute(DeleteDataStreamAction.INSTANCE, new DeleteDataStreamAction.Request("*")).actionGet();
1098+
// Need to remove template, because base class doesn't remove composable index templates after each test (only legacy templates)
1099+
client.execute(DeleteComposableIndexTemplateAction.INSTANCE, new DeleteComposableIndexTemplateAction.Request("my-template"))
1100+
.actionGet();
1101+
}
10941102
}
10951103

1096-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/pull/81040")
10971104
public void testRestoreDataStreamAliasWithConflictingIndicesAlias() throws Exception {
10981105
var snapshotName = "test-snapshot";
10991106
createFullSnapshot(REPO, snapshotName);

0 commit comments

Comments
 (0)