Skip to content

Fix X-Pack Indices Breaking Repository BwC Tests (#51120) #51125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2020
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 @@ -113,13 +113,14 @@ public void testCreateAndRestoreSnapshot() throws IOException {
final String repoName = getTestName();
try (RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(adminClient().getNodes().toArray(new Node[0])))) {
final int shards = 3;
createIndex(client, "test-index", shards);
final String index = "test-index";
createIndex(client, index, shards);
createRepository(client, repoName, false);
createSnapshot(client, repoName, "snapshot-" + TEST_STEP);
createSnapshot(client, repoName, "snapshot-" + TEST_STEP, index);
final String snapshotToDeleteName = "snapshot-to-delete";
// Create a snapshot and delete it right away again to test the impact of each version's cleanup functionality that is run
// as part of the snapshot delete
createSnapshot(client, repoName, snapshotToDeleteName);
createSnapshot(client, repoName, snapshotToDeleteName, index);
final List<Map<String, Object>> snapshotsIncludingToDelete = listSnapshots(repoName);
// Every step creates one snapshot and we have to add one more for the temporary snapshot
assertThat(snapshotsIncludingToDelete, hasSize(TEST_STEP.ordinal() + 1 + 1));
Expand Down Expand Up @@ -160,9 +161,10 @@ public void testReadOnlyRepo() throws IOException {
final int shards = 3;
final boolean readOnly = TEST_STEP.ordinal() > 1; // only restore from read-only repo in steps 3 and 4
createRepository(client, repoName, readOnly);
final String index = "test-index";
if (readOnly == false) {
createIndex(client, "test-index", shards);
createSnapshot(client, repoName, "snapshot-" + TEST_STEP);
createIndex(client, index, shards);
createSnapshot(client, repoName, "snapshot-" + TEST_STEP, index);
}
final List<Map<String, Object>> snapshots = listSnapshots(repoName);
switch (TEST_STEP) {
Expand Down Expand Up @@ -194,11 +196,12 @@ public void testUpgradeMovesRepoToNewMetaVersion() throws IOException {
final String repoName = getTestName();
try (RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(adminClient().getNodes().toArray(new Node[0])))) {
final int shards = 3;
createIndex(client, "test-index", shards);
final String index= "test-index";
createIndex(client, index, shards);
createRepository(client, repoName, false);
// only create some snapshots in the first two steps
if (TEST_STEP == TestStep.STEP1_OLD_CLUSTER || TEST_STEP == TestStep.STEP2_NEW_CLUSTER) {
createSnapshot(client, repoName, "snapshot-" + TEST_STEP);
createSnapshot(client, repoName, "snapshot-" + TEST_STEP, index);
final List<Map<String, Object>> snapshots = listSnapshots(repoName);
// Every step creates one snapshot
assertThat(snapshots, hasSize(TEST_STEP.ordinal() + 1));
Expand All @@ -209,10 +212,10 @@ public void testUpgradeMovesRepoToNewMetaVersion() throws IOException {
} else {
deleteSnapshot(client, repoName, "snapshot-" + TestStep.STEP1_OLD_CLUSTER);
ensureSnapshotRestoreWorks(repoName, "snapshot-" + TestStep.STEP2_NEW_CLUSTER, shards);
createSnapshot(client, repoName, "snapshot-1");
createSnapshot(client, repoName, "snapshot-1", index);
ensureSnapshotRestoreWorks(repoName, "snapshot-1", shards);
deleteSnapshot(client, repoName, "snapshot-" + TestStep.STEP2_NEW_CLUSTER);
createSnapshot(client, repoName, "snapshot-2");
createSnapshot(client, repoName, "snapshot-2", index);
ensureSnapshotRestoreWorks(repoName, "snapshot-2", shards);
}
} else {
Expand All @@ -223,7 +226,7 @@ public void testUpgradeMovesRepoToNewMetaVersion() throws IOException {
expectThrowsAnyOf(expectedExceptions, () -> listSnapshots(repoName));
expectThrowsAnyOf(expectedExceptions, () -> deleteSnapshot(client, repoName, "snapshot-1"));
expectThrowsAnyOf(expectedExceptions, () -> deleteSnapshot(client, repoName, "snapshot-2"));
expectThrowsAnyOf(expectedExceptions, () -> createSnapshot(client, repoName, "snapshot-impossible"));
expectThrowsAnyOf(expectedExceptions, () -> createSnapshot(client, repoName, "snapshot-impossible", index));
} else {
assertThat(listSnapshots(repoName), hasSize(2));
if (TEST_STEP == TestStep.STEP4_NEW_CLUSTER) {
Expand Down Expand Up @@ -287,8 +290,8 @@ private static void createRepository(RestHighLevelClient client, String repoName
is(true));
}

private static void createSnapshot(RestHighLevelClient client, String repoName, String name) throws IOException {
client.snapshot().create(new CreateSnapshotRequest(repoName, name).waitForCompletion(true), RequestOptions.DEFAULT);
private static void createSnapshot(RestHighLevelClient client, String repoName, String name, String index) throws IOException {
client.snapshot().create(new CreateSnapshotRequest(repoName, name).waitForCompletion(true).indices(index), RequestOptions.DEFAULT);
}

private void createIndex(RestHighLevelClient client, String name, int shards) throws IOException {
Expand Down