Skip to content

Commit

Permalink
Merge remote-tracking branch 'elastic/master' into clone-snapshot-on-…
Browse files Browse the repository at this point in the history
…repo
  • Loading branch information
original-brownbear committed Aug 11, 2020
2 parents ddbcb23 + 19ebc5b commit f662c47
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1702,10 +1702,11 @@ public void testDeleteRepositoryWhileSnapshotting() throws Exception {
logger.info("--> execution was blocked on node [{}], trying to delete repository", blockedNode);

try {
client.admin().cluster().prepareDeleteRepository("test-repo").execute().get();
client.admin().cluster().prepareDeleteRepository(randomFrom("test-repo", "test-*", "*")).execute().actionGet();
fail("shouldn't be able to delete in-use repository");
} catch (Exception ex) {
logger.info("--> in-use repository deletion failed");
assertThat(ex.getMessage(), containsString("trying to modify or unregister repository that is currently used"));
}

logger.info("--> trying to move repository to another location");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ protected ClusterStateUpdateResponse newResponse(boolean acknowledged) {

@Override
public ClusterState execute(ClusterState currentState) {
ensureRepositoryNotInUse(currentState, request.name());
Metadata metadata = currentState.metadata();
Metadata.Builder mdBuilder = Metadata.builder(currentState.metadata());
RepositoriesMetadata repositories = metadata.custom(RepositoriesMetadata.TYPE);
Expand All @@ -214,6 +213,7 @@ public ClusterState execute(ClusterState currentState) {
boolean changed = false;
for (RepositoryMetadata repositoryMetadata : repositories.repositories()) {
if (Regex.simpleMatch(request.name(), repositoryMetadata.name())) {
ensureRepositoryNotInUse(currentState, repositoryMetadata.name());
logger.info("delete repository [{}]", repositoryMetadata.name());
changed = true;
} else {
Expand Down Expand Up @@ -465,7 +465,7 @@ private static void validate(final String repositoryName) {

private static void ensureRepositoryNotInUse(ClusterState clusterState, String repository) {
if (isRepositoryInUse(clusterState, repository)) {
throw new IllegalStateException("trying to modify or unregister repository that is currently used ");
throw new IllegalStateException("trying to modify or unregister repository that is currently used");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ private void assertTotalHits(String indexName, TotalHits originalAllHits, TotalH
private void assertRecoveryStats(String indexName, boolean preWarmEnabled) {
int shardCount = getNumShards(indexName).totalNumShards;
final RecoveryResponse recoveryResponse = client().admin().indices().prepareRecoveries(indexName).get();
assertThat(recoveryResponse.shardRecoveryStates().get(indexName).size(), equalTo(shardCount));
assertThat(recoveryResponse.toString(), recoveryResponse.shardRecoveryStates().get(indexName).size(), equalTo(shardCount));

for (List<RecoveryState> recoveryStates : recoveryResponse.shardRecoveryStates().values()) {
for (RecoveryState recoveryState : recoveryStates) {
Expand Down

0 comments on commit f662c47

Please sign in to comment.