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

76 lines
2.5 KiB
Groovy
Raw Normal View History

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'
7.x - Create plugin for yamlTest task (#56841) (#59090) This commit creates a new Gradle plugin to provide a separate task name and source set for running YAML based REST tests. The only project converted to use the new plugin in this PR is distribution/archives/integ-test-zip. For which the testing has been moved to :rest-api-spec since it makes the most sense and it avoids a small but awkward change to the distribution plugin. The remaining cases in modules, plugins, and x-pack will be handled in followups. This plugin is distinctly different from the plugin introduced in #55896 since the YAML REST tests are intended to be black box tests over HTTP. As such they should not (by default) have access to the classpath for that which they are testing. The YAML based REST tests will be moved to separate source sets (yamlRestTest). The which source is the target for the test resources is dependent on if this new plugin is applied. If it is not applied, it will default to the test source set. Further, this introduces a breaking change for plugin developers that use the YAML testing framework. They will now need to either use the new source set and matching task, or configure the rest resources to use the old "test" source set that matches the old integTest task. (The former should be preferred). As part of this change (which is also breaking for plugin developers) the rest resources plugin has been removed from the build plugin and now requires either explicit application or application via the new YAML REST test plugin. Plugin developers should be able to fix the breaking changes to the YAML tests by adding apply plugin: 'elasticsearch.yaml-rest-test' and moving the YAML tests under a yamlRestTest folder (instead of test)
2020-07-06 15:16:26 -04:00
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 {
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.path
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"
}