mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 15:17:30 -04:00
This tweaks the AntFixture handling to make it compliant with the task avoidance api. Tasks of type StandaloneRestTestTask are now generally finalised by using the typed ant stop task which allows us to remove of errorprone dependsOn overrides in StandaloneRestTestTask. As a result we also ported more task definitions in the build to task avoidance api. Next work item regarding AntFixture handling is porting AntFixture to a plain Gradle task and remove Groovy AntBuilder will allow us to port more build logic from Groovy to Java but is out of the scope of This PR.
This commit is contained in:
parent
a779f61531
commit
8e5f7365e6
11 changed files with 182 additions and 123 deletions
|
@ -44,13 +44,15 @@ Map<String, Object> expansions = [
|
|||
'expected_nodes': ec2NumberOfNodes
|
||||
]
|
||||
|
||||
processYamlRestTestResources {
|
||||
tasks.named("processYamlRestTestResources").configure {
|
||||
inputs.properties(expansions)
|
||||
MavenFilteringHack.filter(it, expansions)
|
||||
}
|
||||
|
||||
// disable default yamlRestTest task, use spezialized ones below
|
||||
yamlRestTest.enabled = false
|
||||
tasks.named("yamlRestTest").configure {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
/*
|
||||
* Test using various credential providers (see also https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/credentials.html):
|
||||
|
@ -64,61 +66,66 @@ yamlRestTest.enabled = false
|
|||
* custom Java security policy to work.
|
||||
*/
|
||||
['KeyStore', 'EnvVariables', 'SystemProperties', 'ContainerCredentials', 'InstanceProfile'].forEach { action ->
|
||||
AntFixture fixture = tasks.create(name: "ec2Fixture${action}", type: AntFixture) {
|
||||
TaskProvider<AntFixture> fixture = tasks.register("ec2Fixture${action}", AntFixture) {
|
||||
dependsOn project.sourceSets.yamlRestTest.runtimeClasspath
|
||||
env 'CLASSPATH', "${-> project.sourceSets.yamlRestTest.runtimeClasspath.asPath}"
|
||||
executable = "${BuildParams.runtimeJavaHome}/bin/java"
|
||||
args 'org.elasticsearch.discovery.ec2.AmazonEC2Fixture', baseDir, "${buildDir}/testclusters/yamlRestTest${action}-1/config/unicast_hosts.txt"
|
||||
}
|
||||
|
||||
tasks.create(name: "yamlRestTest${action}", type: RestIntegTestTask) {
|
||||
def yamlRestTestTask = tasks.register("yamlRestTest${action}", RestIntegTestTask) {
|
||||
dependsOn fixture
|
||||
SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
|
||||
SourceSet yamlRestTestSourceSet = sourceSets.getByName(YamlRestTestPlugin.SOURCE_SET_NAME)
|
||||
testClassesDirs = yamlRestTestSourceSet.getOutput().getClassesDirs()
|
||||
classpath = yamlRestTestSourceSet.getRuntimeClasspath()
|
||||
}
|
||||
SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
|
||||
SourceSet yamlRestTestSourceSet = sourceSets.getByName(YamlRestTestPlugin.SOURCE_SET_NAME)
|
||||
"yamlRestTest${action}" {
|
||||
setTestClassesDirs(yamlRestTestSourceSet.getOutput().getClassesDirs())
|
||||
setClasspath(yamlRestTestSourceSet.getRuntimeClasspath())
|
||||
}
|
||||
check.dependsOn("yamlRestTest${action}")
|
||||
|
||||
testClusters."yamlRestTest${action}" {
|
||||
tasks.named("check").configure {
|
||||
dependsOn(yamlRestTestTask)
|
||||
}
|
||||
|
||||
testClusters.matching { it.name == yamlRestTestTask.name}.configureEach {
|
||||
numberOfNodes = ec2NumberOfNodes
|
||||
plugin ':plugins:discovery-ec2'
|
||||
|
||||
setting 'discovery.seed_providers', 'ec2'
|
||||
setting 'network.host', '_ec2_'
|
||||
setting 'discovery.ec2.endpoint', { "http://${-> fixture.addressAndPort}" }, IGNORE_VALUE
|
||||
setting 'discovery.ec2.endpoint', { "http://${-> fixture.get().addressAndPort}" }, IGNORE_VALUE
|
||||
|
||||
systemProperty "com.amazonaws.sdk.ec2MetadataServiceEndpointOverride", { "http://${-> fixture.addressAndPort}" }, IGNORE_VALUE
|
||||
systemProperty "com.amazonaws.sdk.ec2MetadataServiceEndpointOverride", { "http://${-> fixture.get().addressAndPort}" }, IGNORE_VALUE
|
||||
}
|
||||
}
|
||||
|
||||
// Extra config for KeyStore
|
||||
testClusters.yamlRestTestKeyStore {
|
||||
testClusters.matching { it.name == "yamlRestTestKeyStore" }.configureEach {
|
||||
keystore 'discovery.ec2.access_key', 'ec2_integration_test_access_key'
|
||||
keystore 'discovery.ec2.secret_key', 'ec2_integration_test_secret_key'
|
||||
}
|
||||
|
||||
// Extra config for EnvVariables
|
||||
testClusters.yamlRestTestEnvVariables {
|
||||
testClusters.matching { it.name == "yamlRestTestEnvVariables" }.configureEach {
|
||||
environment 'AWS_ACCESS_KEY_ID', 'ec2_integration_test_access_key'
|
||||
environment 'AWS_SECRET_ACCESS_KEY', 'ec2_integration_test_secret_key'
|
||||
}
|
||||
|
||||
// Extra config for SystemProperties
|
||||
testClusters.yamlRestTestSystemProperties {
|
||||
testClusters.matching { it.name == "yamlRestTestSystemProperties" }.configureEach {
|
||||
systemProperty 'aws.accessKeyId', 'ec2_integration_test_access_key'
|
||||
systemProperty 'aws.secretKey', 'ec2_integration_test_secret_key'
|
||||
}
|
||||
|
||||
// Extra config for ContainerCredentials
|
||||
ec2FixtureContainerCredentials.env 'ACTIVATE_CONTAINER_CREDENTIALS', true
|
||||
tasks.named("ec2FixtureContainerCredentials").configure {
|
||||
env 'ACTIVATE_CONTAINER_CREDENTIALS', true
|
||||
}
|
||||
|
||||
testClusters.yamlRestTestContainerCredentials {
|
||||
testClusters.matching { it.name == "yamlRestTestContainerCredentials" }.configureEach {
|
||||
environment 'AWS_CONTAINER_CREDENTIALS_FULL_URI',
|
||||
{ "http://${-> tasks.findByName("ec2FixtureContainerCredentials").addressAndPort}/ecs_credentials_endpoint" }, IGNORE_VALUE
|
||||
}
|
||||
|
||||
// Extra config for InstanceProfile
|
||||
ec2FixtureInstanceProfile.env 'ACTIVATE_INSTANCE_PROFILE', true
|
||||
tasks.named("ec2FixtureInstanceProfile").configure {
|
||||
env 'ACTIVATE_INSTANCE_PROFILE', true
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue