Search in sources :

Example 6 with MockRepository

use of org.opensearch.snapshots.mockstore.MockRepository in project OpenSearch by opensearch-project.

the class SharedClusterSnapshotRestoreIT method testIndexLatestFailuresIgnored.

public void testIndexLatestFailuresIgnored() throws Exception {
    final String repoName = "test-repo";
    final Path repoPath = randomRepoPath();
    createRepository(repoName, "mock", repoPath);
    final MockRepository repository = (MockRepository) internalCluster().getCurrentMasterNodeInstance(RepositoriesService.class).repository(repoName);
    repository.setFailOnIndexLatest(true);
    createFullSnapshot(repoName, "snapshot-1");
    repository.setFailOnIndexLatest(false);
    createFullSnapshot(repoName, "snapshot-2");
    final long repoGenInIndexLatest = Numbers.bytesToLong(new BytesRef(Files.readAllBytes(repoPath.resolve(BlobStoreRepository.INDEX_LATEST_BLOB))));
    assertEquals(getRepositoryData(repoName).getGenId(), repoGenInIndexLatest);
    createRepository(repoName, "fs", Settings.builder().put("location", repoPath).put(BlobStoreRepository.SUPPORT_URL_REPO.getKey(), false));
    createFullSnapshot(repoName, "snapshot-3");
    final long repoGenInIndexLatest2 = Numbers.bytesToLong(new BytesRef(Files.readAllBytes(repoPath.resolve(BlobStoreRepository.INDEX_LATEST_BLOB))));
    assertEquals("index.latest should not have been written to", repoGenInIndexLatest, repoGenInIndexLatest2);
    createRepository(repoName, "fs", repoPath);
    createFullSnapshot(repoName, "snapshot-4");
    final long repoGenInIndexLatest3 = Numbers.bytesToLong(new BytesRef(Files.readAllBytes(repoPath.resolve(BlobStoreRepository.INDEX_LATEST_BLOB))));
    assertEquals(getRepositoryData(repoName).getGenId(), repoGenInIndexLatest3);
}
Also used : Path(java.nio.file.Path) MockRepository(org.opensearch.snapshots.mockstore.MockRepository) Matchers.containsString(org.hamcrest.Matchers.containsString) BytesRef(org.apache.lucene.util.BytesRef)

Aggregations

MockRepository (org.opensearch.snapshots.mockstore.MockRepository)6 RepositoriesService (org.opensearch.repositories.RepositoriesService)4 Path (java.nio.file.Path)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 BytesRef (org.apache.lucene.util.BytesRef)1 Client (org.opensearch.client.Client)1