Skip to content

Commit

Permalink
Don't use create static storage service
Browse files Browse the repository at this point in the history
Even though you annotate the Test class with `@ThirdParty` the static
code is initialized.

In that case it fails with:

```
==> Test Info: seed=529C3C6977F695FC; jvms=3; suites=6
Suite: org.elasticsearch.repositories.azure.AzureSnapshotRestoreTests
ERROR   0.00s J2 | AzureSnapshotRestoreTests (suite) <<< FAILURES!
   > Throwable #1: java.lang.IllegalStateException: to run integration tests, you need to set -Dtests.thirdparty=true and -Dtests.azure.account=azure-account -Dtests.azure.key=azure-key
   >    at org.elasticsearch.cloud.azure.AzureTestUtils.generateMockSecureSettings(AzureTestUtils.java:37)
   >    at org.elasticsearch.repositories.azure.AzureSnapshotRestoreTests.generateMockSettings(AzureSnapshotRestoreTests.java:81)
   >    at org.elasticsearch.repositories.azure.AzureSnapshotRestoreTests.<clinit>(AzureSnapshotRestoreTests.java:84)
   >    at java.lang.Class.forName0(Native Method)
   >    at java.lang.Class.forName(Class.java:348)
Completed [1/6] on J2 in 2.21s, 0 tests, 1 error <<< FAILURES!
```

Closes elastic#26812.
  • Loading branch information
dadoonet committed Sep 28, 2017
1 parent 4aec42b commit eb6d714
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.carrotsearch.randomizedtesting.RandomizedTest;
import com.microsoft.azure.storage.LocationMode;
import com.microsoft.azure.storage.StorageException;
import org.apache.lucene.util.LuceneTestCase.AwaitsFix;
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse;
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
Expand Down Expand Up @@ -76,17 +75,16 @@
supportsDedicatedMasters = false, numDataNodes = 1,
transportClientRatio = 0.0)
@ThirdParty
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/26812")
public class AzureSnapshotRestoreTests extends ESBlobStoreRepositoryIntegTestCase {

private static Settings.Builder generateMockSettings() {
return Settings.builder().setSecureSettings(generateMockSecureSettings());
}

// disabled for https://github.com/elastic/elasticsearch/issues/26812
private static final AzureStorageService azureStorageService = null;
//private static final AzureStorageService azureStorageService = new AzureStorageServiceImpl(generateMockSettings().build(),
// AzureStorageSettings.load(generateMockSettings().build()));
private static AzureStorageService getAzureStorageService() {
return new AzureStorageServiceImpl(generateMockSettings().build(),
AzureStorageSettings.load(generateMockSettings().build()));
}

@Override
protected Settings nodeSettings(int nodeOrdinal) {
Expand Down Expand Up @@ -129,7 +127,7 @@ private static void createTestContainer(String containerName) throws Exception {
// It could happen that we run this test really close to a previous one
// so we might need some time to be able to create the container
assertBusy(() -> {
azureStorageService.createContainer("default", LocationMode.PRIMARY_ONLY, containerName);
getAzureStorageService().createContainer("default", LocationMode.PRIMARY_ONLY, containerName);
}, 30, TimeUnit.SECONDS);
}

Expand All @@ -138,7 +136,7 @@ private static void createTestContainer(String containerName) throws Exception {
* @param containerName container name to use
*/
private static void removeTestContainer(String containerName) throws URISyntaxException, StorageException {
azureStorageService.removeContainer("default", LocationMode.PRIMARY_ONLY, containerName);
getAzureStorageService().removeContainer("default", LocationMode.PRIMARY_ONLY, containerName);
}

@Override
Expand Down

0 comments on commit eb6d714

Please sign in to comment.