|
@@ -37,6 +37,7 @@ import org.elasticsearch.common.SuppressForbidden;
|
|
|
import org.elasticsearch.common.blobstore.BlobContainer;
|
|
|
import org.elasticsearch.common.blobstore.BlobPath;
|
|
|
import org.elasticsearch.common.blobstore.BlobStore;
|
|
|
+import org.elasticsearch.common.blobstore.BlobStoreException;
|
|
|
import org.elasticsearch.common.bytes.BytesArray;
|
|
|
import org.elasticsearch.common.io.Streams;
|
|
|
import org.elasticsearch.common.regex.Regex;
|
|
@@ -49,6 +50,7 @@ import org.elasticsearch.env.Environment;
|
|
|
import org.elasticsearch.plugins.Plugin;
|
|
|
import org.elasticsearch.repositories.RepositoriesService;
|
|
|
import org.elasticsearch.repositories.Repository;
|
|
|
+import org.elasticsearch.repositories.RepositoryException;
|
|
|
import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
|
|
|
import org.elasticsearch.repositories.blobstore.ESMockAPIBasedRepositoryIntegTestCase;
|
|
|
import org.threeten.bp.Duration;
|
|
@@ -68,6 +70,8 @@ import static org.elasticsearch.repositories.gcs.GoogleCloudStorageClientSetting
|
|
|
import static org.elasticsearch.repositories.gcs.GoogleCloudStorageClientSettings.TOKEN_URI_SETTING;
|
|
|
import static org.elasticsearch.repositories.gcs.GoogleCloudStorageRepository.BUCKET;
|
|
|
import static org.elasticsearch.repositories.gcs.GoogleCloudStorageRepository.CLIENT_NAME;
|
|
|
+import static org.hamcrest.Matchers.instanceOf;
|
|
|
+import static org.hamcrest.Matchers.is;
|
|
|
|
|
|
@SuppressForbidden(reason = "this test uses a HttpServer to emulate a Google Cloud Storage endpoint")
|
|
|
public class GoogleCloudStorageBlobStoreRepositoryTests extends ESMockAPIBasedRepositoryIntegTestCase {
|
|
@@ -195,6 +199,16 @@ public class GoogleCloudStorageBlobStoreRepositoryTests extends ESMockAPIBasedRe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void testBucketDoesNotExist() {
|
|
|
+ RepositoryException ex = expectThrows(RepositoryException.class, () ->
|
|
|
+ client().admin().cluster().preparePutRepository("invalid")
|
|
|
+ .setType(repositoryType())
|
|
|
+ .setVerify(true)
|
|
|
+ .setSettings(Settings.builder().put(repositorySettings()).put("bucket", "missing")).get());
|
|
|
+ assertThat(ex.getCause(), instanceOf(BlobStoreException.class));
|
|
|
+ assertThat(ex.getCause().getMessage(), is("Bucket [missing] does not exist"));
|
|
|
+ }
|
|
|
+
|
|
|
public static class TestGoogleCloudStoragePlugin extends GoogleCloudStoragePlugin {
|
|
|
|
|
|
public TestGoogleCloudStoragePlugin(Settings settings) {
|
|
@@ -234,7 +248,8 @@ public class GoogleCloudStorageBlobStoreRepositoryTests extends ESMockAPIBasedRe
|
|
|
metadata -> new GoogleCloudStorageRepository(metadata, registry, this.storageService, clusterService) {
|
|
|
@Override
|
|
|
protected GoogleCloudStorageBlobStore createBlobStore() {
|
|
|
- return new GoogleCloudStorageBlobStore("bucket", "test", metadata.name(), storageService) {
|
|
|
+ return new GoogleCloudStorageBlobStore(
|
|
|
+ metadata.settings().get("bucket"), "test", metadata.name(), storageService) {
|
|
|
@Override
|
|
|
long getLargeBlobThresholdInBytes() {
|
|
|
return ByteSizeUnit.MB.toBytes(1);
|