|
35 | 35 | import org.elasticsearch.common.settings.Settings;
|
36 | 36 | import org.elasticsearch.repositories.RepositoryException;
|
37 | 37 | import org.elasticsearch.repositories.RepositoryMissingException;
|
| 38 | +import org.elasticsearch.snapshots.SnapshotMissingException; |
38 | 39 | import org.elasticsearch.snapshots.SnapshotState;
|
39 | 40 | import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
40 | 41 | import org.elasticsearch.test.store.MockDirectoryHelper;
|
|
44 | 45 |
|
45 | 46 | import java.net.URISyntaxException;
|
46 | 47 |
|
47 |
| -import static org.hamcrest.Matchers.equalTo; |
48 |
| -import static org.hamcrest.Matchers.greaterThan; |
49 |
| -import static org.hamcrest.Matchers.is; |
| 48 | +import static org.hamcrest.Matchers.*; |
50 | 49 |
|
51 | 50 | /**
|
52 | 51 | * This test needs Azure to run and -Dtests.azure=true to be set
|
@@ -268,6 +267,30 @@ private void checkContainerName(String container, boolean correct) {
|
268 | 267 | }
|
269 | 268 | }
|
270 | 269 |
|
| 270 | + /** |
| 271 | + * Test case for issue #23: https://github.com/elasticsearch/elasticsearch-cloud-azure/issues/23 |
| 272 | + */ |
| 273 | + @Test |
| 274 | + public void testNonExistingRepo_23() { |
| 275 | + Client client = client(); |
| 276 | + logger.info("--> creating azure repository with path [{}]", basePath); |
| 277 | + PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo") |
| 278 | + .setType("azure").setSettings(ImmutableSettings.settingsBuilder() |
| 279 | + .put(AzureStorageService.Fields.CONTAINER, "elasticsearch-integration") |
| 280 | + .put(AzureStorageService.Fields.BASE_PATH, basePath) |
| 281 | + .put(AzureStorageService.Fields.CHUNK_SIZE, randomIntBetween(1000, 10000)) |
| 282 | + ).get(); |
| 283 | + assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true)); |
| 284 | + |
| 285 | + logger.info("--> restore non existing snapshot"); |
| 286 | + try { |
| 287 | + client.admin().cluster().prepareRestoreSnapshot("test-repo", "no-existing-snapshot").setWaitForCompletion(true).execute().actionGet(); |
| 288 | + fail("Shouldn't be here"); |
| 289 | + } catch (SnapshotMissingException ex) { |
| 290 | + // Expected |
| 291 | + } |
| 292 | + } |
| 293 | + |
271 | 294 | /**
|
272 | 295 | * Deletes repositories, supports wildcard notation.
|
273 | 296 | */
|
|
0 commit comments