Skip to content

Commit 524af67

Browse files
adjust bwc Tests
1 parent 064d9f2 commit 524af67

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

qa/repository-multi-version/src/test/java/org/elasticsearch/upgrades/MultiVersionRepositoryAccessIT.java

+25-6
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,20 @@ public void testCreateAndRestoreSnapshot() throws IOException {
129129
deleteSnapshot(client, repoName, snapshotToDeleteName);
130130
final List<Map<String, Object>> snapshots = listSnapshots(repoName);
131131
assertThat(snapshots, hasSize(TEST_STEP.ordinal() + 1));
132-
assertSnapshotStatusSuccessful(client, repoName, snapshots);
132+
switch (TEST_STEP) {
133+
case STEP2_NEW_CLUSTER:
134+
case STEP4_NEW_CLUSTER:
135+
assertSnapshotStatusSuccessful(client, repoName,
136+
snapshots.stream().map(sn -> (String) sn.get("snapshot")).toArray(String[]::new));
137+
break;
138+
case STEP1_OLD_CLUSTER:
139+
assertSnapshotStatusSuccessful(client, repoName, "snapshot-" + TEST_STEP);
140+
break;
141+
case STEP3_OLD_CLUSTER:
142+
assertSnapshotStatusSuccessful(
143+
client, repoName, "snapshot-" + TEST_STEP, "snapshot-" + TestStep.STEP3_OLD_CLUSTER);
144+
break;
145+
}
133146
if (TEST_STEP == TestStep.STEP3_OLD_CLUSTER) {
134147
ensureSnapshotRestoreWorks(client, repoName, "snapshot-" + TestStep.STEP1_OLD_CLUSTER, shards);
135148
} else if (TEST_STEP == TestStep.STEP4_NEW_CLUSTER) {
@@ -163,7 +176,12 @@ public void testReadOnlyRepo() throws IOException {
163176
assertThat(snapshots, hasSize(2));
164177
break;
165178
}
166-
assertSnapshotStatusSuccessful(client, repoName, snapshots);
179+
if (TEST_STEP == TestStep.STEP1_OLD_CLUSTER || TEST_STEP == TestStep.STEP3_OLD_CLUSTER) {
180+
assertSnapshotStatusSuccessful(client, repoName, "snapshot-" + TestStep.STEP1_OLD_CLUSTER);
181+
} else {
182+
assertSnapshotStatusSuccessful(client, repoName,
183+
"snapshot-" + TestStep.STEP1_OLD_CLUSTER, "snapshot-" + TestStep.STEP2_NEW_CLUSTER);
184+
}
167185
if (TEST_STEP == TestStep.STEP3_OLD_CLUSTER) {
168186
ensureSnapshotRestoreWorks(client, repoName, "snapshot-" + TestStep.STEP1_OLD_CLUSTER, shards);
169187
} else if (TEST_STEP == TestStep.STEP4_NEW_CLUSTER) {
@@ -187,7 +205,8 @@ public void testUpgradeMovesRepoToNewMetaVersion() throws IOException {
187205
final List<Map<String, Object>> snapshots = listSnapshots(repoName);
188206
// Every step creates one snapshot
189207
assertThat(snapshots, hasSize(TEST_STEP.ordinal() + 1));
190-
assertSnapshotStatusSuccessful(client, repoName, snapshots);
208+
assertSnapshotStatusSuccessful(client, repoName,
209+
snapshots.stream().map(sn -> (String) sn.get("snapshot")).toArray(String[]::new));
191210
if (TEST_STEP == TestStep.STEP1_OLD_CLUSTER) {
192211
ensureSnapshotRestoreWorks(client, repoName, "snapshot-" + TestStep.STEP1_OLD_CLUSTER, shards);
193212
} else {
@@ -205,9 +224,9 @@ public void testUpgradeMovesRepoToNewMetaVersion() throws IOException {
205224
}
206225

207226
private static void assertSnapshotStatusSuccessful(RestHighLevelClient client, String repoName,
208-
List<Map<String, Object>> snapshots) throws IOException {
209-
final SnapshotsStatusResponse statusResponse = client.snapshot().status(new SnapshotsStatusRequest(repoName,
210-
snapshots.stream().map(sn -> (String) sn.get("snapshot")).toArray(String[]::new)), RequestOptions.DEFAULT);
227+
String... snapshots) throws IOException {
228+
final SnapshotsStatusResponse statusResponse = client.snapshot()
229+
.status(new SnapshotsStatusRequest(repoName, snapshots), RequestOptions.DEFAULT);
211230
for (SnapshotStatus status : statusResponse.getSnapshots()) {
212231
assertThat(status.getShardsStats().getFailedShards(), is(0));
213232
}

0 commit comments

Comments
 (0)