Skip to content

Commit 3e4791a

Browse files
authored
Add docker-compose based test fixture for Azure (#48636)
This commit adds a new :test:fixtures:azure-fixture project which provides a docker-compose based container that runs a AzureHttpFixture Java class that emulates an Azure Storage service. The logic to emulate the service is extracted from existing tests and placed in AzureHttpHandler into the new project so that it can be easily reused. The :plugins:repository-azure project is an example of such utilization. The AzureHttpFixture fixture is just a wrapper around AzureHttpHandler and is now executed within the docker container. The :plugins:repository-azure:qa:microsoft-azure project uses the new test fixture and the existing AzureStorageFixture has been removed.
1 parent 5251088 commit 3e4791a

File tree

12 files changed

+353
-570
lines changed

12 files changed

+353
-570
lines changed

plugins/repository-azure/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ dependencies {
2727
compile 'com.microsoft.azure:azure-keyvault-core:1.0.0'
2828
compile 'com.google.guava:guava:20.0'
2929
compile 'org.apache.commons:commons-lang3:3.4'
30+
testCompile project(':test:fixtures:azure-fixture')
3031
}
3132

3233
dependencyLicenses {

plugins/repository-azure/qa/microsoft-azure-storage/build.gradle

+11-12
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
2626

2727
apply plugin: 'elasticsearch.standalone-rest-test'
2828
apply plugin: 'elasticsearch.rest-test'
29+
apply plugin: 'elasticsearch.test.fixtures'
30+
31+
testFixtures.useFixture ":test:fixtures:azure-fixture", "azure-fixture"
2932

3033
boolean useFixture = false
3134

@@ -38,20 +41,12 @@ String azureSasToken = System.getenv("azure_storage_sas_token")
3841
if (!azureAccount && !azureKey && !azureContainer && !azureBasePath && !azureSasToken) {
3942
azureAccount = 'azure_integration_test_account'
4043
azureKey = 'YXp1cmVfaW50ZWdyYXRpb25fdGVzdF9rZXk=' // The key is "azure_integration_test_key" encoded using base64
41-
azureContainer = 'container_test'
42-
azureBasePath = 'integration_test'
44+
azureContainer = 'container'
45+
azureBasePath = ''
4346
azureSasToken = ''
4447
useFixture = true
4548
}
4649

47-
/** A task to start the fixture which emulates an Azure Storage service **/
48-
task azureStorageFixture(type: AntFixture) {
49-
dependsOn testClasses
50-
env 'CLASSPATH', "${ -> project.sourceSets.test.runtimeClasspath.asPath }"
51-
executable = new File(project.runtimeJavaHome, 'bin/java')
52-
args 'org.elasticsearch.repositories.azure.AzureStorageFixture', baseDir, azureContainer
53-
}
54-
5550
Map<String, Object> expansions = [
5651
'container': azureContainer,
5752
'base_path': azureBasePath + "_integration_tests"
@@ -77,11 +72,15 @@ testClusters.integTest {
7772
}
7873

7974
if (useFixture) {
80-
tasks.integTest.dependsOn azureStorageFixture
75+
def azureAddress = {
76+
int ephemeralPort = project(':test:fixtures:azure-fixture').postProcessFixture.ext."test.fixtures.azure-fixture.tcp.8091"
77+
assert ephemeralPort > 0
78+
'http://127.0.0.1:' + ephemeralPort
79+
}
8180
// Use a closure on the string to delay evaluation until tests are executed. The endpoint_suffix is used
8281
// in a hacky way to change the protocol and endpoint. We must fix that.
8382
setting 'azure.client.integration_test.endpoint_suffix',
84-
{ "ignored;DefaultEndpointsProtocol=http;BlobEndpoint=http://${azureStorageFixture.addressAndPort }" }, IGNORE_VALUE
83+
{ "ignored;DefaultEndpointsProtocol=http;BlobEndpoint=${ -> azureAddress() }" }, IGNORE_VALUE
8584
String firstPartOfSeed = project.rootProject.testSeed.tokenize(':').get(0)
8685
setting 'thread_pool.repository_azure.max', (Math.abs(Long.parseUnsignedLong(firstPartOfSeed, 16) % 10) + 1).toString(), System.getProperty('ignore.tests.seed') == null ? DEFAULT : IGNORE_VALUE
8786
}

0 commit comments

Comments
 (0)