OpenSearch/x-pack/plugin/searchable-snapshots/qa/s3/build.gradle

83 lines
2.7 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'
apply plugin: 'elasticsearch.rest-resources'
final Project fixture = project(':test:fixtures:s3-fixture')
final Project repositoryPlugin = project(':plugins:repository-s3')
dependencies {
testImplementation project(path: xpackModule('searchable-snapshots'), configuration: 'testArtifacts')
testImplementation 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 = null
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
nonInputProperties.systemProperty 'test.s3.base_path', s3BasePath ? s3BasePath + "_searchable_snapshots_tests" + BuildParams.testSeed : 'base_path'
}
}
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
}
}
tasks.register("s3ThirdPartyTest") {
dependsOn "integTest"
}