Don't use create static storage service
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 #26812. (cherry picked from commit eb6d714 for master branch)
This commit is contained in:
parent
aade2f6d63
commit
9ba5e168e4
|
@ -23,7 +23,6 @@ package org.elasticsearch.repositories.azure;
|
|||
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;
|
||||
|
@ -72,17 +71,16 @@ import static org.hamcrest.Matchers.lessThanOrEqualTo;
|
|||
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) {
|
||||
|
@ -125,7 +123,7 @@ public class AzureSnapshotRestoreTests extends ESBlobStoreRepositoryIntegTestCas
|
|||
// 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);
|
||||
}
|
||||
|
||||
|
@ -134,7 +132,7 @@ public class AzureSnapshotRestoreTests extends ESBlobStoreRepositoryIntegTestCas
|
|||
* @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
|
||||
|
|
Loading…
Reference in New Issue