From c7f6de9656d33d8f00079fc07b845a739ce731ee Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Fri, 10 Jan 2020 13:01:28 +0100 Subject: [PATCH] Fix MultiVersionRepositoryAccessIT Tests (#50848) We need the same fix we did in `7.x` (#50797) and only get snapshot status for the current version or older. Otherwise these tests break for e.g.`7.0.1` due to the same index metadata incompatibility. Closes #50819 --- .../MultiVersionRepositoryAccessIT.java | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/qa/repository-multi-version/src/test/java/org/elasticsearch/upgrades/MultiVersionRepositoryAccessIT.java b/qa/repository-multi-version/src/test/java/org/elasticsearch/upgrades/MultiVersionRepositoryAccessIT.java index f3effc8c01bec..ec2a70c6f84cd 100644 --- a/qa/repository-multi-version/src/test/java/org/elasticsearch/upgrades/MultiVersionRepositoryAccessIT.java +++ b/qa/repository-multi-version/src/test/java/org/elasticsearch/upgrades/MultiVersionRepositoryAccessIT.java @@ -129,7 +129,20 @@ public void testCreateAndRestoreSnapshot() throws IOException { deleteSnapshot(client, repoName, snapshotToDeleteName); final List> snapshots = listSnapshots(repoName); assertThat(snapshots, hasSize(TEST_STEP.ordinal() + 1)); - assertSnapshotStatusSuccessful(client, repoName, snapshots); + switch (TEST_STEP) { + case STEP2_NEW_CLUSTER: + case STEP4_NEW_CLUSTER: + assertSnapshotStatusSuccessful(client, repoName, + snapshots.stream().map(sn -> (String) sn.get("snapshot")).toArray(String[]::new)); + break; + case STEP1_OLD_CLUSTER: + assertSnapshotStatusSuccessful(client, repoName, "snapshot-" + TEST_STEP); + break; + case STEP3_OLD_CLUSTER: + assertSnapshotStatusSuccessful( + client, repoName, "snapshot-" + TEST_STEP, "snapshot-" + TestStep.STEP3_OLD_CLUSTER); + break; + } if (TEST_STEP == TestStep.STEP3_OLD_CLUSTER) { ensureSnapshotRestoreWorks(client, repoName, "snapshot-" + TestStep.STEP1_OLD_CLUSTER, shards); } else if (TEST_STEP == TestStep.STEP4_NEW_CLUSTER) { @@ -163,7 +176,12 @@ public void testReadOnlyRepo() throws IOException { assertThat(snapshots, hasSize(2)); break; } - assertSnapshotStatusSuccessful(client, repoName, snapshots); + if (TEST_STEP == TestStep.STEP1_OLD_CLUSTER || TEST_STEP == TestStep.STEP3_OLD_CLUSTER) { + assertSnapshotStatusSuccessful(client, repoName, "snapshot-" + TestStep.STEP1_OLD_CLUSTER); + } else { + assertSnapshotStatusSuccessful(client, repoName, + "snapshot-" + TestStep.STEP1_OLD_CLUSTER, "snapshot-" + TestStep.STEP2_NEW_CLUSTER); + } if (TEST_STEP == TestStep.STEP3_OLD_CLUSTER) { ensureSnapshotRestoreWorks(client, repoName, "snapshot-" + TestStep.STEP1_OLD_CLUSTER, shards); } else if (TEST_STEP == TestStep.STEP4_NEW_CLUSTER) { @@ -187,7 +205,8 @@ public void testUpgradeMovesRepoToNewMetaVersion() throws IOException { final List> snapshots = listSnapshots(repoName); // Every step creates one snapshot assertThat(snapshots, hasSize(TEST_STEP.ordinal() + 1)); - assertSnapshotStatusSuccessful(client, repoName, snapshots); + assertSnapshotStatusSuccessful(client, repoName, + snapshots.stream().map(sn -> (String) sn.get("snapshot")).toArray(String[]::new)); if (TEST_STEP == TestStep.STEP1_OLD_CLUSTER) { ensureSnapshotRestoreWorks(client, repoName, "snapshot-" + TestStep.STEP1_OLD_CLUSTER, shards); } else { @@ -205,9 +224,9 @@ public void testUpgradeMovesRepoToNewMetaVersion() throws IOException { } private static void assertSnapshotStatusSuccessful(RestHighLevelClient client, String repoName, - List> snapshots) throws IOException { - final SnapshotsStatusResponse statusResponse = client.snapshot().status(new SnapshotsStatusRequest(repoName, - snapshots.stream().map(sn -> (String) sn.get("snapshot")).toArray(String[]::new)), RequestOptions.DEFAULT); + String... snapshots) throws IOException { + final SnapshotsStatusResponse statusResponse = client.snapshot() + .status(new SnapshotsStatusRequest(repoName, snapshots), RequestOptions.DEFAULT); for (SnapshotStatus status : statusResponse.getSnapshots()) { assertThat(status.getShardsStats().getFailedShards(), is(0)); }