mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-07 21:48:39 +00:00
Similarly to what has been done in for the repository-s3 plugin, this pull request moves the fixture test into a dedicated repository-azure/qa/microsoft-azure-storage project. It also exposes some environment variables which allows to execute the integration tests against the real Azure Storage service. When the environment variables are not defined, the integration tests are executed using the fixture added in #29347. Closes #29349
86 lines
3.2 KiB
Groovy
86 lines
3.2 KiB
Groovy
/*
|
|
* Licensed to Elasticsearch under one or more contributor
|
|
* license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright
|
|
* ownership. Elasticsearch licenses this file to you under
|
|
* the Apache License, Version 2.0 (the "License"); you may
|
|
* not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing,
|
|
* software distributed under the License is distributed on an
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
* KIND, either express or implied. See the License for the
|
|
* specific language governing permissions and limitations
|
|
* under the License.
|
|
*/
|
|
|
|
import org.elasticsearch.gradle.MavenFilteringHack
|
|
import org.elasticsearch.gradle.test.AntFixture
|
|
|
|
apply plugin: 'elasticsearch.standalone-rest-test'
|
|
apply plugin: 'elasticsearch.rest-test'
|
|
|
|
dependencies {
|
|
testCompile project(path: ':plugins:repository-azure', configuration: 'runtime')
|
|
}
|
|
|
|
integTestCluster {
|
|
plugin ':plugins:repository-azure'
|
|
}
|
|
|
|
forbiddenApisTest {
|
|
// we are using jdk-internal instead of jdk-non-portable to allow for com.sun.net.httpserver.* usage
|
|
bundledSignatures -= 'jdk-non-portable'
|
|
bundledSignatures += 'jdk-internal'
|
|
}
|
|
|
|
boolean useFixture = false
|
|
|
|
String azureAccount = System.getenv("azure_storage_account")
|
|
String azureKey = System.getenv("azure_storage_key")
|
|
String azureContainer = System.getenv("azure_storage_container")
|
|
String azureBasePath = System.getenv("azure_storage_base_path")
|
|
|
|
if (!azureAccount && !azureKey && !azureContainer && !azureBasePath) {
|
|
azureAccount = 'azure_integration_test_account'
|
|
azureKey = 'YXp1cmVfaW50ZWdyYXRpb25fdGVzdF9rZXk=' // The key is "azure_integration_test_key" encoded using base64
|
|
azureContainer = 'container_test'
|
|
azureBasePath = 'integration_test'
|
|
useFixture = true
|
|
}
|
|
|
|
/** A task to start the fixture which emulates an Azure Storage service **/
|
|
task azureStorageFixture(type: AntFixture) {
|
|
dependsOn compileTestJava
|
|
env 'CLASSPATH', "${ -> project.sourceSets.test.runtimeClasspath.asPath }"
|
|
executable = new File(project.runtimeJavaHome, 'bin/java')
|
|
args 'org.elasticsearch.repositories.azure.AzureStorageFixture', baseDir, azureContainer
|
|
}
|
|
|
|
Map<String, Object> expansions = [
|
|
'container': azureContainer,
|
|
'base_path': azureBasePath
|
|
]
|
|
processTestResources {
|
|
inputs.properties(expansions)
|
|
MavenFilteringHack.filter(it, expansions)
|
|
}
|
|
|
|
integTestCluster {
|
|
keystoreSetting 'azure.client.integration_test.account', azureAccount
|
|
keystoreSetting 'azure.client.integration_test.key', azureKey
|
|
|
|
if (useFixture) {
|
|
dependsOn azureStorageFixture
|
|
// Use a closure on the string to delay evaluation until tests are executed. The endpoint_suffix is used
|
|
// in a hacky way to change the protocol and endpoint. We must fix that.
|
|
setting 'azure.client.integration_test.endpoint_suffix',
|
|
"ignored;DefaultEndpointsProtocol=http;BlobEndpoint=http://${ -> azureStorageFixture.addressAndPort }"
|
|
} else {
|
|
println "Using an external service to test the repository-azure plugin"
|
|
}
|
|
}
|