elasticsearch/plugins/discovery-gce/qa/gce/build.gradle
Rene Groeschke 13c8aaeffa
[Gradle] Remove static use of BuildParams (#115122)
Static fields dont do well in Gradle with configuration cache enabled.

- Use buildParams extension in build scripts
- Keep BuildParams.ci for now for easy serverless migration
-  Tweak testing doc
2024-11-15 17:58:57 +01:00

65 lines
2.6 KiB
Groovy

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import org.apache.tools.ant.filters.ReplaceTokens
import org.elasticsearch.gradle.internal.info.BuildParams
import org.elasticsearch.gradle.internal.test.AntFixture
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
apply plugin: 'elasticsearch.legacy-yaml-rest-test'
final int gceNumberOfNodes = 3
dependencies {
yamlRestTestImplementation project(':plugins:discovery-gce')
}
restResources {
restApi {
include '_common', 'cluster', 'nodes'
}
}
/** A task to start the GCEFixture which emulates a GCE service **/
def gceFixtureProvider = tasks.register("gceFixture", AntFixture) {
dependsOn project.sourceSets.yamlRestTest.runtimeClasspath
env 'CLASSPATH', "${-> project.sourceSets.yamlRestTest.runtimeClasspath.asPath}"
executable = "${buildParams.runtimeJavaHome.get()}/bin/java"
args 'org.elasticsearch.cloud.gce.GCEFixture', baseDir, "${buildDir}/testclusters/yamlRestTest-1/config/unicast_hosts.txt"
}
Map<String, Object> expansions = [
'expected_nodes': gceNumberOfNodes
]
tasks.named("processYamlRestTestResources").configure {
inputs.properties(expansions)
filter("tokens" : expansions.collectEntries {k, v -> [k, v.toString()]} /* must be a map of strings */, ReplaceTokens.class)
}
tasks.named("yamlRestTest").configure {
dependsOn gceFixtureProvider
}
testClusters.matching { it.name == "yamlRestTest" }.configureEach {
numberOfNodes = gceNumberOfNodes
plugin ':plugins:discovery-gce'
// use gce fixture for Auth calls instead of http://metadata.google.internal
environment 'GCE_METADATA_HOST', { "http://${gceFixtureProvider.get().addressAndPort}" }, IGNORE_VALUE
// allows to configure hidden settings (`cloud.gce.host` and `cloud.gce.root_url`)
systemProperty 'es.allow_reroute_gce_settings', 'true'
setting 'discovery.seed_providers', 'gce'
// use gce fixture for metadata server calls instead of http://metadata.google.internal
setting 'cloud.gce.host', { "http://${gceFixtureProvider.get().addressAndPort}" }, IGNORE_VALUE
// use gce fixture for API calls instead of https://www.googleapis.com
setting 'cloud.gce.root_url', { "http://${gceFixtureProvider.get().addressAndPort}" }, IGNORE_VALUE
}