Skip to content

Commit 1598136

Browse files
Add recovery from snapshot to tests
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 #elastic#76237
1 parent 245ba38 commit 1598136

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

test/framework/src/main/java/org/elasticsearch/snapshots/AbstractSnapshotIntegTestCase.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,9 @@ public static Settings.Builder randomRepositorySettings() {
338338
if (rarely()) {
339339
settings.put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES);
340340
}
341+
if (randomBoolean()) {
342+
settings.put(BlobStoreRepository.USE_FOR_PEER_RECOVERY_SETTING.getKey(), randomBoolean());
343+
}
341344
return settings;
342345
}
343346

x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/BaseSearchableSnapshotsIntegTestCase.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.elasticsearch.indices.IndicesService;
4141
import org.elasticsearch.indices.recovery.RecoveryState;
4242
import org.elasticsearch.plugins.Plugin;
43+
import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
4344
import org.elasticsearch.snapshots.AbstractSnapshotIntegTestCase;
4445
import org.elasticsearch.test.ESIntegTestCase;
4546
import org.elasticsearch.threadpool.ThreadPool;
@@ -140,6 +141,13 @@ public void waitForBlobCacheFillsToComplete() {
140141
}
141142
}
142143

144+
@Override
145+
protected void createRepository(String repoName, String type, Settings.Builder settings, boolean verify) {
146+
// add use for peer recovery setting randomly to verify that these features work together.
147+
Settings.Builder newSettings = randomBoolean() ? settings : Settings.builder().put(BlobStoreRepository.USE_FOR_PEER_RECOVERY_SETTING.getKey(), true).put(settings.build());
148+
super.createRepository(repoName, type, newSettings, verify);
149+
}
150+
143151
protected String mountSnapshot(String repositoryName, String snapshotName, String indexName, Settings restoredIndexSettings)
144152
throws Exception {
145153
final String restoredIndexName = randomBoolean() ? indexName : randomAlphaOfLength(10).toLowerCase(Locale.ROOT);

0 commit comments

Comments
 (0)