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 committed Aug 15, 2021
1 parent f115524 commit a680400
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 @@ -333,6 +333,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 @@ -38,6 +38,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.threadpool.ThreadPool;
import org.elasticsearch.xpack.core.XPackSettings;
Expand Down Expand Up @@ -141,6 +142,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 a680400

Please sign in to comment.