|
23 | 23 | import com.amazonaws.services.s3.model.DeleteObjectsRequest;
|
24 | 24 | import com.amazonaws.services.s3.model.ObjectListing;
|
25 | 25 | import com.amazonaws.services.s3.model.S3ObjectSummary;
|
26 |
| - |
27 | 26 | import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse;
|
28 | 27 | import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
|
29 | 28 | import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
|
30 | 29 | import org.elasticsearch.client.Client;
|
| 30 | +import org.elasticsearch.client.ClusterAdminClient; |
31 | 31 | import org.elasticsearch.cloud.aws.AbstractAwsTest;
|
32 | 32 | import org.elasticsearch.cloud.aws.AbstractAwsTest.AwsTest;
|
33 | 33 | import org.elasticsearch.cloud.aws.AwsS3Service;
|
|
37 | 37 | import org.elasticsearch.common.util.concurrent.UncategorizedExecutionException;
|
38 | 38 | import org.elasticsearch.plugins.PluginsService;
|
39 | 39 | import org.elasticsearch.repositories.RepositoryMissingException;
|
| 40 | +import org.elasticsearch.snapshots.SnapshotMissingException; |
40 | 41 | import org.elasticsearch.snapshots.SnapshotState;
|
41 | 42 | import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope;
|
42 | 43 | import org.elasticsearch.test.ElasticsearchIntegrationTest.Scope;
|
|
45 | 46 | import org.junit.Before;
|
46 | 47 | import org.junit.Test;
|
47 | 48 |
|
48 |
| -import java.util.List; |
49 | 49 | import java.util.ArrayList;
|
| 50 | +import java.util.List; |
50 | 51 |
|
51 | 52 | import static org.hamcrest.Matchers.*;
|
52 | 53 |
|
@@ -317,7 +318,57 @@ public void testRepositoryInRemoteRegion() {
|
317 | 318 | assertRepositoryIsOperational(client, "test-repo");
|
318 | 319 | }
|
319 | 320 |
|
320 |
| - private void assertRepositoryIsOperational(Client client, String repository) { |
| 321 | + /** |
| 322 | + * Test case for issue #86: https://github.com/elasticsearch/elasticsearch-cloud-aws/issues/86 |
| 323 | + */ |
| 324 | + @Test |
| 325 | + public void testNonExistingRepo_86() { |
| 326 | + Client client = client(); |
| 327 | + logger.info("--> creating s3 repository with bucket[{}] and path [{}]", internalCluster().getInstance(Settings.class).get("repositories.s3.bucket"), basePath); |
| 328 | + PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo") |
| 329 | + .setType("s3").setSettings(ImmutableSettings.settingsBuilder() |
| 330 | + .put("base_path", basePath) |
| 331 | + ).get(); |
| 332 | + assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true)); |
| 333 | + |
| 334 | + logger.info("--> restore non existing snapshot"); |
| 335 | + try { |
| 336 | + client.admin().cluster().prepareRestoreSnapshot("test-repo", "no-existing-snapshot").setWaitForCompletion(true).execute().actionGet(); |
| 337 | + fail("Shouldn't be here"); |
| 338 | + } catch (SnapshotMissingException ex) { |
| 339 | + // Expected |
| 340 | + } |
| 341 | + } |
| 342 | + |
| 343 | + /** |
| 344 | + * For issue #86: https://github.com/elasticsearch/elasticsearch-cloud-aws/issues/86 |
| 345 | + */ |
| 346 | + @Test |
| 347 | + public void testGetDeleteNonExistingSnapshot_86() { |
| 348 | + ClusterAdminClient client = client().admin().cluster(); |
| 349 | + logger.info("--> creating azure repository without any path"); |
| 350 | + PutRepositoryResponse putRepositoryResponse = client.preparePutRepository("test-repo").setType("azure") |
| 351 | + .setType("s3").setSettings(ImmutableSettings.settingsBuilder() |
| 352 | + .put("base_path", basePath) |
| 353 | + ).get(); |
| 354 | + assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true)); |
| 355 | + |
| 356 | + try { |
| 357 | + client.prepareGetSnapshots("test-repo").addSnapshots("no-existing-snapshot").get(); |
| 358 | + fail("Shouldn't be here"); |
| 359 | + } catch (SnapshotMissingException ex) { |
| 360 | + // Expected |
| 361 | + } |
| 362 | + |
| 363 | + try { |
| 364 | + client.prepareDeleteSnapshot("test-repo", "no-existing-snapshot").get(); |
| 365 | + fail("Shouldn't be here"); |
| 366 | + } catch (SnapshotMissingException ex) { |
| 367 | + // Expected |
| 368 | + } |
| 369 | + } |
| 370 | + |
| 371 | + private void assertRepositoryIsOperational(Client client, String repository) { |
321 | 372 | createIndex("test-idx-1");
|
322 | 373 | ensureGreen();
|
323 | 374 |
|
|
0 commit comments