|
20 | 20 | package org.elasticsearch.repositories.azure;
|
21 | 21 |
|
22 | 22 | import com.microsoft.azure.storage.LocationMode;
|
23 |
| -import com.microsoft.azure.storage.StorageException; |
24 | 23 | import org.elasticsearch.cluster.metadata.RepositoryMetaData;
|
25 | 24 | import org.elasticsearch.common.settings.Settings;
|
26 | 25 | import org.elasticsearch.common.unit.ByteSizeUnit;
|
|
30 | 29 | import org.elasticsearch.env.TestEnvironment;
|
31 | 30 | import org.elasticsearch.test.ESTestCase;
|
32 | 31 |
|
33 |
| -import java.io.IOException; |
34 |
| -import java.net.URISyntaxException; |
35 |
| - |
36 | 32 | import static org.hamcrest.Matchers.is;
|
| 33 | +import static org.hamcrest.Matchers.nullValue; |
37 | 34 | import static org.mockito.Mockito.mock;
|
38 | 35 |
|
39 | 36 | public class AzureRepositorySettingsTests extends ESTestCase {
|
40 | 37 |
|
41 |
| - private AzureRepository azureRepository(Settings settings) throws StorageException, IOException, URISyntaxException { |
| 38 | + private AzureRepository azureRepository(Settings settings) { |
42 | 39 | Settings internalSettings = Settings.builder()
|
43 | 40 | .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toAbsolutePath())
|
44 | 41 | .putList(Environment.PATH_DATA_SETTING.getKey(), tmpPaths())
|
45 | 42 | .put(settings)
|
46 | 43 | .build();
|
47 |
| - return new AzureRepository(new RepositoryMetaData("foo", "azure", internalSettings), |
| 44 | + final AzureRepository azureRepository = new AzureRepository(new RepositoryMetaData("foo", "azure", internalSettings), |
48 | 45 | TestEnvironment.newEnvironment(internalSettings), NamedXContentRegistry.EMPTY, mock(AzureStorageService.class));
|
| 46 | + assertThat(azureRepository.getBlobStore(), is(nullValue())); |
| 47 | + return azureRepository; |
49 | 48 | }
|
50 | 49 |
|
51 |
| - public void testReadonlyDefault() throws StorageException, IOException, URISyntaxException { |
| 50 | + public void testReadonlyDefault() { |
52 | 51 | assertThat(azureRepository(Settings.EMPTY).isReadOnly(), is(false));
|
53 | 52 | }
|
54 | 53 |
|
55 |
| - public void testReadonlyDefaultAndReadonlyOn() throws StorageException, IOException, URISyntaxException { |
| 54 | + public void testReadonlyDefaultAndReadonlyOn() { |
56 | 55 | assertThat(azureRepository(Settings.builder()
|
57 | 56 | .put("readonly", true)
|
58 | 57 | .build()).isReadOnly(), is(true));
|
59 | 58 | }
|
60 | 59 |
|
61 |
| - public void testReadonlyWithPrimaryOnly() throws StorageException, IOException, URISyntaxException { |
| 60 | + public void testReadonlyWithPrimaryOnly() { |
62 | 61 | assertThat(azureRepository(Settings.builder()
|
63 | 62 | .put(AzureRepository.Repository.LOCATION_MODE_SETTING.getKey(), LocationMode.PRIMARY_ONLY.name())
|
64 | 63 | .build()).isReadOnly(), is(false));
|
65 | 64 | }
|
66 | 65 |
|
67 |
| - public void testReadonlyWithPrimaryOnlyAndReadonlyOn() throws StorageException, IOException, URISyntaxException { |
| 66 | + public void testReadonlyWithPrimaryOnlyAndReadonlyOn() { |
68 | 67 | assertThat(azureRepository(Settings.builder()
|
69 | 68 | .put(AzureRepository.Repository.LOCATION_MODE_SETTING.getKey(), LocationMode.PRIMARY_ONLY.name())
|
70 | 69 | .put("readonly", true)
|
71 | 70 | .build()).isReadOnly(), is(true));
|
72 | 71 | }
|
73 | 72 |
|
74 |
| - public void testReadonlyWithSecondaryOnlyAndReadonlyOn() throws StorageException, IOException, URISyntaxException { |
| 73 | + public void testReadonlyWithSecondaryOnlyAndReadonlyOn() { |
75 | 74 | assertThat(azureRepository(Settings.builder()
|
76 | 75 | .put(AzureRepository.Repository.LOCATION_MODE_SETTING.getKey(), LocationMode.SECONDARY_ONLY.name())
|
77 | 76 | .put("readonly", true)
|
78 | 77 | .build()).isReadOnly(), is(true));
|
79 | 78 | }
|
80 | 79 |
|
81 |
| - public void testReadonlyWithSecondaryOnlyAndReadonlyOff() throws StorageException, IOException, URISyntaxException { |
| 80 | + public void testReadonlyWithSecondaryOnlyAndReadonlyOff() { |
82 | 81 | assertThat(azureRepository(Settings.builder()
|
83 | 82 | .put(AzureRepository.Repository.LOCATION_MODE_SETTING.getKey(), LocationMode.SECONDARY_ONLY.name())
|
84 | 83 | .put("readonly", false)
|
85 | 84 | .build()).isReadOnly(), is(false));
|
86 | 85 | }
|
87 | 86 |
|
88 |
| - public void testReadonlyWithPrimaryAndSecondaryOnlyAndReadonlyOn() throws StorageException, IOException, URISyntaxException { |
| 87 | + public void testReadonlyWithPrimaryAndSecondaryOnlyAndReadonlyOn() { |
89 | 88 | assertThat(azureRepository(Settings.builder()
|
90 | 89 | .put(AzureRepository.Repository.LOCATION_MODE_SETTING.getKey(), LocationMode.PRIMARY_THEN_SECONDARY.name())
|
91 | 90 | .put("readonly", true)
|
92 | 91 | .build()).isReadOnly(), is(true));
|
93 | 92 | }
|
94 | 93 |
|
95 |
| - public void testReadonlyWithPrimaryAndSecondaryOnlyAndReadonlyOff() throws StorageException, IOException, URISyntaxException { |
| 94 | + public void testReadonlyWithPrimaryAndSecondaryOnlyAndReadonlyOff() { |
96 | 95 | assertThat(azureRepository(Settings.builder()
|
97 | 96 | .put(AzureRepository.Repository.LOCATION_MODE_SETTING.getKey(), LocationMode.PRIMARY_THEN_SECONDARY.name())
|
98 | 97 | .put("readonly", false)
|
99 | 98 | .build()).isReadOnly(), is(false));
|
100 | 99 | }
|
101 | 100 |
|
102 |
| - public void testChunkSize() throws StorageException, IOException, URISyntaxException { |
| 101 | + public void testChunkSize() { |
103 | 102 | // default chunk size
|
104 | 103 | AzureRepository azureRepository = azureRepository(Settings.EMPTY);
|
105 | 104 | assertEquals(AzureStorageService.MAX_CHUNK_SIZE, azureRepository.chunkSize());
|
|
0 commit comments