-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shallow snapshot v2 - create snapshot validations in a cluster state …
…update (#15939) (#16102) --------- (cherry picked from commit e8b02c9) Signed-off-by: Gaurav Bafna <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
b41be86
commit 08c1932
Showing
7 changed files
with
1,133 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteSnapshotIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.remotestore; | ||
|
||
import org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest; | ||
import org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse; | ||
import org.opensearch.client.Client; | ||
import org.opensearch.cluster.metadata.IndexMetadata; | ||
import org.opensearch.cluster.metadata.RepositoryMetadata; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.index.IndexSettings; | ||
import org.opensearch.indices.RemoteStoreSettings; | ||
import org.opensearch.repositories.fs.ReloadableFsRepository; | ||
import org.opensearch.snapshots.AbstractSnapshotIntegTestCase; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
|
||
import java.nio.file.Path; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
import static org.opensearch.repositories.fs.ReloadableFsRepository.REPOSITORIES_FAILRATE_SETTING; | ||
|
||
public abstract class RemoteSnapshotIT extends AbstractSnapshotIntegTestCase { | ||
protected static final String BASE_REMOTE_REPO = "test-rs-repo" + TEST_REMOTE_STORE_REPO_SUFFIX; | ||
protected Path remoteRepoPath; | ||
|
||
@Before | ||
public void setup() { | ||
remoteRepoPath = randomRepoPath().toAbsolutePath(); | ||
} | ||
|
||
@After | ||
public void teardown() { | ||
clusterAdmin().prepareCleanupRepository(BASE_REMOTE_REPO).get(); | ||
} | ||
|
||
@Override | ||
protected Settings nodeSettings(int nodeOrdinal) { | ||
return Settings.builder() | ||
.put(super.nodeSettings(nodeOrdinal)) | ||
.put(remoteStoreClusterSettings(BASE_REMOTE_REPO, remoteRepoPath)) | ||
.build(); | ||
} | ||
|
||
protected Settings pinnedTimestampSettings() { | ||
Settings settings = Settings.builder() | ||
.put(RemoteStoreSettings.CLUSTER_REMOTE_STORE_PINNED_TIMESTAMP_ENABLED.getKey(), true) | ||
.build(); | ||
return settings; | ||
} | ||
|
||
protected Settings.Builder getIndexSettings(int numOfShards, int numOfReplicas) { | ||
Settings.Builder settingsBuilder = Settings.builder() | ||
.put(super.indexSettings()) | ||
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numOfShards) | ||
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numOfReplicas) | ||
.put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "300s"); | ||
return settingsBuilder; | ||
} | ||
|
||
protected void indexDocuments(Client client, String indexName, int numOfDocs) { | ||
indexDocuments(client, indexName, 0, numOfDocs); | ||
} | ||
|
||
void indexDocuments(Client client, String indexName, int fromId, int toId) { | ||
for (int i = fromId; i < toId; i++) { | ||
String id = Integer.toString(i); | ||
client.prepareIndex(indexName).setId(id).setSource("text", "sometext").get(); | ||
} | ||
client.admin().indices().prepareFlush(indexName).get(); | ||
} | ||
|
||
protected void setFailRate(String repoName, int value) throws ExecutionException, InterruptedException { | ||
GetRepositoriesRequest gr = new GetRepositoriesRequest(new String[] { repoName }); | ||
GetRepositoriesResponse res = client().admin().cluster().getRepositories(gr).get(); | ||
RepositoryMetadata rmd = res.repositories().get(0); | ||
Settings.Builder settings = Settings.builder() | ||
.put("location", rmd.settings().get("location")) | ||
.put(REPOSITORIES_FAILRATE_SETTING.getKey(), value); | ||
createRepository(repoName, ReloadableFsRepository.TYPE, settings); | ||
} | ||
|
||
} |
Oops, something went wrong.