Skip to content

Commit

Permalink
Add recovery from snapshot to tests (#76535)
Browse files Browse the repository at this point in the history
Randomly add to use a snapshot for recovery to searchable snapshot and
snapshot tests to verify that recover from snapshot does not break other
features (those should not care about the flag).

Relates #76237
  • Loading branch information
henningandersen authored Aug 15, 2021
1 parent 58eefdd commit 51d524b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ public static Settings.Builder randomRepositorySettings() {
if (rarely()) {
settings.put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES);
}
if (randomBoolean()) {
settings.put(BlobStoreRepository.USE_FOR_PEER_RECOVERY_SETTING.getKey(), randomBoolean());
}
return settings;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.indices.recovery.RecoveryState;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
import org.elasticsearch.snapshots.AbstractSnapshotIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.threadpool.ThreadPool;
Expand Down Expand Up @@ -140,6 +141,15 @@ public void waitForBlobCacheFillsToComplete() {
}
}

@Override
protected void createRepository(String repoName, String type, Settings.Builder settings, boolean verify) {
// add use for peer recovery setting randomly to verify that these features work together.
Settings.Builder newSettings = randomBoolean()
? settings
: Settings.builder().put(BlobStoreRepository.USE_FOR_PEER_RECOVERY_SETTING.getKey(), true).put(settings.build());
super.createRepository(repoName, type, newSettings, verify);
}

protected String mountSnapshot(String repositoryName, String snapshotName, String indexName, Settings restoredIndexSettings)
throws Exception {
final String restoredIndexName = randomBoolean() ? indexName : randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
Expand Down

0 comments on commit 51d524b

Please sign in to comment.