mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-19 03:15:15 +00:00
This change converts the module and plugin parameters for testClusters to be lazy. Meaning that the values are not resolved until they are actually used. This removes the requirement to use project.afterEvaluate to be able to resolve the bundle artifact. Note - this does not completely remove the need for afterEvaluate since it is still needed for the custom resource extension.
80 lines
2.5 KiB
Groovy
80 lines
2.5 KiB
Groovy
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
|
|
import org.elasticsearch.gradle.info.BuildParams
|
|
|
|
apply plugin: 'elasticsearch.standalone-rest-test'
|
|
apply plugin: 'elasticsearch.rest-test'
|
|
|
|
final Project fixture = project(':test:fixtures:s3-fixture')
|
|
final Project repositoryPlugin = project(':plugins:repository-s3')
|
|
|
|
dependencies {
|
|
testCompile project(path: xpackModule('searchable-snapshots'), configuration: 'testArtifacts')
|
|
testCompile repositoryPlugin
|
|
}
|
|
|
|
restResources {
|
|
restApi {
|
|
includeCore 'indices', 'search', 'bulk', 'snapshot', 'nodes', '_common'
|
|
includeXpack 'searchable_snapshots'
|
|
}
|
|
}
|
|
|
|
boolean useFixture = false
|
|
String s3AccessKey = System.getenv("amazon_s3_access_key")
|
|
String s3SecretKey = System.getenv("amazon_s3_secret_key")
|
|
String s3Bucket = System.getenv("amazon_s3_bucket")
|
|
String s3BasePath = System.getenv("amazon_s3_base_path")
|
|
|
|
if (!s3AccessKey && !s3SecretKey && !s3Bucket && !s3BasePath) {
|
|
s3AccessKey = 'access_key'
|
|
s3SecretKey = 'secret_key'
|
|
s3Bucket = 'bucket'
|
|
s3BasePath = 'base_path'
|
|
useFixture = true
|
|
|
|
} else if (!s3AccessKey || !s3SecretKey || !s3Bucket || !s3BasePath) {
|
|
throw new IllegalArgumentException("not all options specified to run against external S3 service are present")
|
|
}
|
|
|
|
if (useFixture) {
|
|
apply plugin: 'elasticsearch.test.fixtures'
|
|
testFixtures.useFixture(fixture.path, 's3-fixture-other')
|
|
}
|
|
|
|
integTest {
|
|
dependsOn repositoryPlugin.bundlePlugin
|
|
runner {
|
|
systemProperty 'test.s3.bucket', s3Bucket
|
|
systemProperty 'test.s3.base_path', s3BasePath + "/searchable_snapshots_tests"
|
|
}
|
|
}
|
|
|
|
testClusters.integTest {
|
|
testDistribution = 'DEFAULT'
|
|
plugin repositoryPlugin.bundlePlugin.archiveFile
|
|
|
|
if (BuildParams.isSnapshotBuild() == false) {
|
|
systemProperty 'es.searchable_snapshots_feature_enabled', 'true'
|
|
}
|
|
|
|
keystore 's3.client.searchable_snapshots.access_key', s3AccessKey
|
|
keystore 's3.client.searchable_snapshots.secret_key', s3SecretKey
|
|
setting 'xpack.license.self_generated.type', 'trial'
|
|
|
|
if (useFixture) {
|
|
def fixtureAddress = { fixtureName ->
|
|
assert useFixture: 'closure should not be used without a fixture'
|
|
int ephemeralPort = fixture.postProcessFixture.ext."test.fixtures.${fixtureName}.tcp.80"
|
|
assert ephemeralPort > 0
|
|
'127.0.0.1:' + ephemeralPort
|
|
}
|
|
|
|
setting 's3.client.searchable_snapshots.protocol', 'http'
|
|
setting 's3.client.searchable_snapshots.endpoint', { "${-> fixtureAddress('s3-fixture-other')}" }, IGNORE_VALUE
|
|
|
|
} else {
|
|
println "Using an external service to test " + project.name
|
|
}
|
|
}
|
|
|