mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-02 08:59:09 +00:00
There are currently half a dozen ways to add plugins and modules for test clusters to use. All of them require the calling project to peek into the plugin or module they want to use to grab its bundlePlugin task, and then both depend on that task, as well as extract the archive path the task will produce. This creates cross project dependencies that are difficult to detect, and if the dependent plugin/module has not yet been configured, the build will fail because the task does not yet exist. This commit makes the plugin and module methods for testclusters symmetetric, and simply adding a file provider directly, or a project path that will produce the plugin/module zip. Internally this new variant uses normal configuration/dependencies across projects to get the zip artifact. It also has the added benefit of no longer needing the caller to add to the test task a dependsOn for bundlePlugin task.
76 lines
2.7 KiB
Groovy
76 lines
2.7 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.info.BuildParams
|
|
import org.elasticsearch.gradle.test.AntFixture
|
|
|
|
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
|
|
|
|
apply plugin: 'elasticsearch.yaml-rest-test'
|
|
|
|
final int gceNumberOfNodes = 3
|
|
|
|
dependencies {
|
|
yamlRestTestImplementation project(':plugins:discovery-gce')
|
|
}
|
|
|
|
restResources {
|
|
restApi {
|
|
includeCore '_common', 'cluster', 'nodes'
|
|
}
|
|
}
|
|
|
|
/** A task to start the GCEFixture which emulates a GCE service **/
|
|
task gceFixture(type: AntFixture) {
|
|
dependsOn project.sourceSets.yamlRestTest.runtimeClasspath
|
|
env 'CLASSPATH', "${-> project.sourceSets.yamlRestTest.runtimeClasspath.asPath}"
|
|
executable = "${BuildParams.runtimeJavaHome}/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)
|
|
MavenFilteringHack.filter(it, expansions)
|
|
}
|
|
|
|
yamlRestTest {
|
|
dependsOn gceFixture
|
|
}
|
|
|
|
testClusters.yamlRestTest {
|
|
numberOfNodes = gceNumberOfNodes
|
|
plugin ':plugins:discovery-gce'
|
|
// use gce fixture for Auth calls instead of http://metadata.google.internal
|
|
environment 'GCE_METADATA_HOST', { "http://${gceFixture.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://${gceFixture.addressAndPort}" }, IGNORE_VALUE
|
|
// use gce fixture for API calls instead of https://www.googleapis.com
|
|
setting 'cloud.gce.root_url', { "http://${gceFixture.addressAndPort}" }, IGNORE_VALUE
|
|
}
|