Skip to content

Commit

Permalink
Merge pull request #15453 from brwe/snaphshots-wildcards-bwc
Browse files Browse the repository at this point in the history
fix SnapshotBackwardsCompatibilityIT to not use wildcards with 2.0
  • Loading branch information
brwe committed Dec 16, 2015
2 parents 5790335 + a36ddbe commit 3960460
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,14 @@ public static void testBasicWorkflow(ESLogger logger, ESIntegTestCase testCase,
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));

String snapshotName;
if (ESIntegTestCase.getMinimumVersionInCluster().onOrAfter(Version.V_2_2_0)) {
snapshotName = randomFrom("test-snap", "_all", "*", "*-snap", "test*");
} else {
snapshotName = "test-snap";
}
SnapshotInfo snapshotInfo = client().admin().cluster().prepareGetSnapshots("test-repo")
.setSnapshots(randomFrom("test-snap", "_all", "*", "*-snap", "test*")).get().getSnapshots().get(0);
.setSnapshots(snapshotName).get().getSnapshots().get(0);
assertThat(snapshotInfo.state(), equalTo(SnapshotState.SUCCESS));
assertThat(snapshotInfo.version(), snapshotVersion);

Expand Down
13 changes: 13 additions & 0 deletions core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.lucene.util.TestUtil;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
Expand Down Expand Up @@ -1914,6 +1915,18 @@ public Set<String> assertAllShardsOnNodes(String index, String... pattern) {
return nodes;
}

// returns the minimum Version of all nodes in the current cluster
public static Version getMinimumVersionInCluster() {
NodesInfoResponse nodesInfoResponse = client().admin().cluster().prepareNodesInfo().get();
Version minimumVersionInCluster = Version.CURRENT;
for (NodeInfo nodeInfo : nodesInfoResponse) {
if (nodeInfo.getVersion().before(minimumVersionInCluster)) {
minimumVersionInCluster = nodeInfo.getVersion();
}
}
return minimumVersionInCluster;
}

protected static class NumShards {
public final int numPrimaries;
public final int numReplicas;
Expand Down

0 comments on commit 3960460

Please sign in to comment.