Skip to content

Commit

Permalink
Enable retry on validation (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
timja authored Oct 22, 2021
1 parent 2f5619b commit af9d7fb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private void validateData(Run<?, ?> run,

// Check if storage account credentials are valid
try {
AzureUtils.validateStorageAccount(storageAccountInfo);
AzureUtils.validateStorageAccount(storageAccountInfo, true);
} catch (Exception e) {
listener.getLogger().println(Messages.Client_SA_val_fail());
listener.getLogger().println(storageAccountInfo.getStorageAccName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ private boolean validateData(

// Check if storage account credentials are valid
try {
AzureUtils.validateStorageAccount(storageAccount);
AzureUtils.validateStorageAccount(storageAccount, true);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
listener.getLogger().println(Messages.Client_SA_val_fail());
Expand Down Expand Up @@ -663,7 +663,7 @@ public FormValidation doCheckAccount(
blobEndPointURL = Utils.getBlobEP(blobEndPointURL);
StorageAccountInfo storageAccount = new StorageAccountInfo(
was_storageAccName, was_storageAccountKey, blobEndPointURL);
AzureUtils.validateStorageAccount(storageAccount);
AzureUtils.validateStorageAccount(storageAccount, false);
} catch (Exception e) {
return FormValidation.error(e, "Error : " + e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public FormValidation doVerifyConfiguration(
try {
StorageAccountInfo storageAccount = new StorageAccountInfo(
storageAccountName, storageKey.getPlainText(), blobEndpointURL);
AzureUtils.validateStorageAccount(storageAccount);
AzureUtils.validateStorageAccount(storageAccount, false);
} catch (Exception e) {
return FormValidation.error(e, e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ public final class AzureUtils {
* @throws WAStorageException
*/
public static boolean validateStorageAccount(
final StorageAccountInfo storageAccount) throws WAStorageException {
final StorageAccountInfo storageAccount, final boolean allowRetry) throws WAStorageException {
try {
// Get container reference
final BlobContainerClient container = getBlobContainerReference(
storageAccount, TEST_CNT_NAME, false, false, null);
storageAccount, TEST_CNT_NAME, false, allowRetry, null);
container.exists();

} catch (Exception e) {
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/IntegrationTests/WAStorageClientUploadIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void setUp() throws IOException {
public void testValidateStorageAccount() throws Exception {
System.out.println("validateStorageAccount");
StorageAccountInfo storageAccount = testEnv.sampleStorageAccount;
boolean result = AzureUtils.validateStorageAccount(storageAccount);
boolean result = AzureUtils.validateStorageAccount(storageAccount, false);
assertEquals(true, result);
if (testEnv.container.exists()) {
testEnv.container.delete();
Expand All @@ -99,7 +99,7 @@ public void testValidateStorageAccount() throws Exception {
@Test(expected = WAStorageException.class)
public void testInvalidateStorageAccount1() throws Exception {
System.out.println("Testing Invalid StorageAccount");
AzureUtils.validateStorageAccount(new StorageAccountInfo(testEnv.azureStorageAccountName, "asdhasdh@asdas!@234=", testEnv.blobURL));
AzureUtils.validateStorageAccount(new StorageAccountInfo(testEnv.azureStorageAccountName, "asdhasdh@asdas!@234=", testEnv.blobURL), false);
if (testEnv.container.exists()) {
testEnv.container.delete();
}
Expand All @@ -111,7 +111,7 @@ public void testInvalidateStorageAccount1() throws Exception {
@Test(expected = WAStorageException.class)
public void testInvalidateStorageAccount2() throws Exception {
System.out.println("Testing Invalid StorageAccount");
AzureUtils.validateStorageAccount(new StorageAccountInfo("rfguthio123", testEnv.azureStorageAccountKey2, testEnv.blobURL));
AzureUtils.validateStorageAccount(new StorageAccountInfo("rfguthio123", testEnv.azureStorageAccountKey2, testEnv.blobURL), false);
if (testEnv.container.exists()) {
testEnv.container.delete();
}
Expand All @@ -123,7 +123,7 @@ public void testInvalidateStorageAccount2() throws Exception {
@Test(expected = WAStorageException.class)
public void testInvalidateStorageAccount3() throws Exception {
System.out.println("Testing Invalid StorageAccount");
AzureUtils.validateStorageAccount(new StorageAccountInfo(null, null, null));
AzureUtils.validateStorageAccount(new StorageAccountInfo(null, null, null), false);
if (testEnv.container.exists()) {
testEnv.container.delete();
}
Expand Down

0 comments on commit af9d7fb

Please sign in to comment.