use of org.elasticsearch.cloud.azure.storage.AzureStorageServiceImpl in project elasticsearch by elastic.
the class AzureSnapshotRestoreTests method testRemoveAndCreateContainer.
/**
* When a user remove a container you can not immediately create it again.
*/
public void testRemoveAndCreateContainer() throws Exception {
final String container = getContainerName().concat("-testremove");
final AzureStorageService storageService = new AzureStorageServiceImpl(internalCluster().getDefaultSettings());
// It could happen that we run this test really close to a previous one
// so we might need some time to be able to create the container
assertBusy(() -> {
try {
storageService.createContainer(null, LocationMode.PRIMARY_ONLY, container);
logger.debug(" -> container created...");
} catch (URISyntaxException e) {
// Incorrect URL. This should never happen.
fail();
} catch (StorageException e) {
// It could happen. Let's wait for a while.
logger.debug(" -> container is being removed. Let's wait a bit...");
fail();
}
}, 30, TimeUnit.SECONDS);
storageService.removeContainer(null, LocationMode.PRIMARY_ONLY, container);
ClusterAdminClient client = client().admin().cluster();
logger.info("--> creating azure repository while container is being removed");
try {
client.preparePutRepository("test-repo").setType("azure").setSettings(Settings.builder().put(Repository.CONTAINER_SETTING.getKey(), container)).get();
fail("we should get a RepositoryVerificationException");
} catch (RepositoryVerificationException e) {
// Fine we expect that
}
}
use of org.elasticsearch.cloud.azure.storage.AzureStorageServiceImpl in project elasticsearch by elastic.
the class AzureSnapshotRestoreTests method cleanRepositoryFiles.
/**
* Purge the test containers
*/
public void cleanRepositoryFiles(String... containers) throws StorageException, URISyntaxException {
Settings settings = readSettingsFromFile();
AzureStorageService client = new AzureStorageServiceImpl(settings);
for (String container : containers) {
client.removeContainer(null, LocationMode.PRIMARY_ONLY, container);
}
}
Aggregations