Merge branch 'pr/azure-repo-no-secondary'

This commit is contained in:
David Pilato 2016-01-14 14:06:30 +01:00
commit 5c9bc37450
2 changed files with 13 additions and 3 deletions

View File

@ -90,8 +90,8 @@ public class AzureStorageServiceImpl extends AbstractLifecycleComponent<AzureSto
logger.trace("selecting a client for account [{}], mode [{}]", account, mode.name());
AzureStorageSettings azureStorageSettings = null;
if (this.primaryStorageSettings == null || this.secondariesStorageSettings.isEmpty()) {
throw new IllegalArgumentException("No azure storage can be found. Check your elasticsearch.yml.");
if (this.primaryStorageSettings == null) {
throw new IllegalArgumentException("No primary azure storage can be found. Check your elasticsearch.yml.");
}
if (account != null) {

View File

@ -47,10 +47,20 @@ public class AzureStorageServiceTest extends ESTestCase {
azureStorageService.getSelectedClient("whatever", LocationMode.PRIMARY_ONLY);
fail("we should have raised an IllegalArgumentException");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), is("No azure storage can be found. Check your elasticsearch.yml."));
assertThat(e.getMessage(), is("No primary azure storage can be found. Check your elasticsearch.yml."));
}
}
public void testGetSelectedClientWithNoSecondary() {
AzureStorageServiceImpl azureStorageService = new AzureStorageServiceMock(Settings.builder()
.put("cloud.azure.storage.azure1.account", "myaccount1")
.put("cloud.azure.storage.azure1.key", "mykey1")
.build());
azureStorageService.doStart();
CloudBlobClient client = azureStorageService.getSelectedClient("azure1", LocationMode.PRIMARY_ONLY);
assertThat(client.getEndpoint(), is(URI.create("https://azure1")));
}
public void testGetSelectedClientPrimary() {
AzureStorageServiceImpl azureStorageService = new AzureStorageServiceMock(settings);
azureStorageService.doStart();