Skip to content

Commit 3960460

Browse files
committed
Merge pull request #15453 from brwe/snaphshots-wildcards-bwc
fix SnapshotBackwardsCompatibilityIT to not use wildcards with 2.0
2 parents 5790335 + a36ddbe commit 3960460

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

core/src/test/java/org/elasticsearch/snapshots/SnapshotSharedTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,14 @@ public static void testBasicWorkflow(ESLogger logger, ESIntegTestCase testCase,
114114
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
115115
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
116116

117+
String snapshotName;
118+
if (ESIntegTestCase.getMinimumVersionInCluster().onOrAfter(Version.V_2_2_0)) {
119+
snapshotName = randomFrom("test-snap", "_all", "*", "*-snap", "test*");
120+
} else {
121+
snapshotName = "test-snap";
122+
}
117123
SnapshotInfo snapshotInfo = client().admin().cluster().prepareGetSnapshots("test-repo")
118-
.setSnapshots(randomFrom("test-snap", "_all", "*", "*-snap", "test*")).get().getSnapshots().get(0);
124+
.setSnapshots(snapshotName).get().getSnapshots().get(0);
119125
assertThat(snapshotInfo.state(), equalTo(SnapshotState.SUCCESS));
120126
assertThat(snapshotInfo.version(), snapshotVersion);
121127

core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.apache.lucene.util.TestUtil;
3434
import org.elasticsearch.ElasticsearchException;
3535
import org.elasticsearch.ExceptionsHelper;
36+
import org.elasticsearch.Version;
3637
import org.elasticsearch.action.ActionListener;
3738
import org.elasticsearch.action.ShardOperationFailedException;
3839
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
@@ -1914,6 +1915,18 @@ public Set<String> assertAllShardsOnNodes(String index, String... pattern) {
19141915
return nodes;
19151916
}
19161917

1918+
// returns the minimum Version of all nodes in the current cluster
1919+
public static Version getMinimumVersionInCluster() {
1920+
NodesInfoResponse nodesInfoResponse = client().admin().cluster().prepareNodesInfo().get();
1921+
Version minimumVersionInCluster = Version.CURRENT;
1922+
for (NodeInfo nodeInfo : nodesInfoResponse) {
1923+
if (nodeInfo.getVersion().before(minimumVersionInCluster)) {
1924+
minimumVersionInCluster = nodeInfo.getVersion();
1925+
}
1926+
}
1927+
return minimumVersionInCluster;
1928+
}
1929+
19171930
protected static class NumShards {
19181931
public final int numPrimaries;
19191932
public final int numReplicas;

0 commit comments

Comments
 (0)