Search in sources :

Example 6 with RepositoryVerificationException

use of org.elasticsearch.repositories.RepositoryVerificationException in project elasticsearch by elastic.

the class AbstractS3SnapshotRestoreTest method testRepositoryInRemoteRegionIsRemote.

/**
     * This test verifies that the test configuration is set up in a manner that
     * does not make the test {@link #testRepositoryInRemoteRegion()} pointless.
     */
public void testRepositoryInRemoteRegionIsRemote() {
    Client client = client();
    Settings bucketSettings = internalCluster().getInstance(Settings.class).getByPrefix("repositories.s3.remote-bucket.");
    logger.info("-->  creating s3 repository with bucket[{}] and path [{}]", bucketSettings.get("bucket"), basePath);
    try {
        client.admin().cluster().preparePutRepository("test-repo").setType("s3").setSettings(Settings.builder().put(S3Repository.Repository.BASE_PATH_SETTING.getKey(), basePath).put(S3Repository.Repository.BUCKET_SETTING.getKey(), bucketSettings.get("bucket"))).get();
        fail("repository verification should have raise an exception!");
    } catch (RepositoryVerificationException e) {
    }
}
Also used : RepositoryVerificationException(org.elasticsearch.repositories.RepositoryVerificationException) Client(org.elasticsearch.client.Client) ClusterAdminClient(org.elasticsearch.client.ClusterAdminClient) Settings(org.elasticsearch.common.settings.Settings)

Example 7 with RepositoryVerificationException

use of org.elasticsearch.repositories.RepositoryVerificationException in project elasticsearch by elastic.

the class RepositoriesIT method testRepositoryVerificationTimeout.

public void testRepositoryVerificationTimeout() throws Exception {
    Client client = client();
    Settings settings = Settings.builder().put("location", randomRepoPath()).put("random_control_io_exception_rate", 1.0).build();
    logger.info("-->  creating repository that cannot write any files - should fail");
    assertThrows(client.admin().cluster().preparePutRepository("test-repo-1").setType("mock").setSettings(settings), RepositoryVerificationException.class);
    logger.info("-->  creating repository that cannot write any files, but suppress verification - should be acked");
    assertAcked(client.admin().cluster().preparePutRepository("test-repo-1").setType("mock").setSettings(settings).setVerify(false));
    logger.info("-->  verifying repository");
    assertThrows(client.admin().cluster().prepareVerifyRepository("test-repo-1"), RepositoryVerificationException.class);
    Path location = randomRepoPath();
    logger.info("-->  creating repository");
    try {
        client.admin().cluster().preparePutRepository("test-repo-1").setType("mock").setSettings(Settings.builder().put("location", location).put("localize_location", true)).get();
        fail("RepositoryVerificationException wasn't generated");
    } catch (RepositoryVerificationException ex) {
        assertThat(ex.getMessage(), containsString("is not shared"));
    }
}
Also used : Path(java.nio.file.Path) RepositoryVerificationException(org.elasticsearch.repositories.RepositoryVerificationException) Client(org.elasticsearch.client.Client) Settings(org.elasticsearch.common.settings.Settings)

Aggregations

RepositoryVerificationException (org.elasticsearch.repositories.RepositoryVerificationException)7 Client (org.elasticsearch.client.Client)4 Settings (org.elasticsearch.common.settings.Settings)4 ClusterAdminClient (org.elasticsearch.client.ClusterAdminClient)3 StorageException (com.microsoft.azure.storage.StorageException)2 URISyntaxException (java.net.URISyntaxException)2 Path (java.nio.file.Path)2 FilterInputStream (java.io.FilterInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 PutRepositoryResponse (org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse)1 AzureStorageService (org.elasticsearch.cloud.azure.storage.AzureStorageService)1 AzureStorageServiceImpl (org.elasticsearch.cloud.azure.storage.AzureStorageServiceImpl)1 BlobContainer (org.elasticsearch.common.blobstore.BlobContainer)1 BytesArray (org.elasticsearch.common.bytes.BytesArray)1 RateLimitingInputStream (org.elasticsearch.index.snapshots.blobstore.RateLimitingInputStream)1 SlicedInputStream (org.elasticsearch.index.snapshots.blobstore.SlicedInputStream)1