|
| 1 | +import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE |
| 2 | + |
| 3 | +apply plugin: 'elasticsearch.standalone-rest-test' |
| 4 | +apply plugin: 'elasticsearch.rest-test' |
| 5 | + |
| 6 | +final Project fixture = project(':test:fixtures:s3-fixture') |
| 7 | +final Project repositoryPlugin = project(':plugins:repository-s3') |
| 8 | + |
| 9 | +dependencies { |
| 10 | + testCompile project(path: xpackModule('searchable-snapshots'), configuration: 'testArtifacts') |
| 11 | + testCompile repositoryPlugin |
| 12 | +} |
| 13 | + |
| 14 | +boolean useFixture = false |
| 15 | +String s3AccessKey = System.getenv("amazon_s3_access_key") |
| 16 | +String s3SecretKey = System.getenv("amazon_s3_secret_key") |
| 17 | +String s3Bucket = System.getenv("amazon_s3_bucket") |
| 18 | +String s3BasePath = System.getenv("amazon_s3_base_path") |
| 19 | + |
| 20 | +if (!s3AccessKey && !s3SecretKey && !s3Bucket && !s3BasePath) { |
| 21 | + s3AccessKey = 'access_key' |
| 22 | + s3SecretKey = 'secret_key' |
| 23 | + s3Bucket = 'bucket' |
| 24 | + s3BasePath = 'base_path' |
| 25 | + useFixture = true |
| 26 | + |
| 27 | +} else if (!s3AccessKey || !s3SecretKey || !s3Bucket || !s3BasePath) { |
| 28 | + throw new IllegalArgumentException("not all options specified to run against external S3 service are present") |
| 29 | +} |
| 30 | + |
| 31 | +if (useFixture) { |
| 32 | + apply plugin: 'elasticsearch.test.fixtures' |
| 33 | + testFixtures.useFixture(fixture.path, 's3-fixture-other') |
| 34 | +} |
| 35 | + |
| 36 | +integTest { |
| 37 | + dependsOn repositoryPlugin.bundlePlugin |
| 38 | + runner { |
| 39 | + systemProperty 'test.s3.bucket', s3Bucket |
| 40 | + systemProperty 'test.s3.base_path', s3BasePath + "/searchable_snapshots_tests" |
| 41 | + } |
| 42 | +} |
| 43 | + |
| 44 | +testClusters.integTest { |
| 45 | + testDistribution = 'DEFAULT' |
| 46 | + plugin file(repositoryPlugin.bundlePlugin.archiveFile) |
| 47 | + |
| 48 | + keystore 's3.client.searchable_snapshots.access_key', s3AccessKey |
| 49 | + keystore 's3.client.searchable_snapshots.secret_key', s3SecretKey |
| 50 | + |
| 51 | + if (useFixture) { |
| 52 | + def fixtureAddress = { fixtureName -> |
| 53 | + assert useFixture: 'closure should not be used without a fixture' |
| 54 | + int ephemeralPort = fixture.postProcessFixture.ext."test.fixtures.${fixtureName}.tcp.80" |
| 55 | + assert ephemeralPort > 0 |
| 56 | + '127.0.0.1:' + ephemeralPort |
| 57 | + } |
| 58 | + |
| 59 | + setting 's3.client.searchable_snapshots.protocol', 'http' |
| 60 | + setting 's3.client.searchable_snapshots.endpoint', { "${-> fixtureAddress('s3-fixture-other')}" }, IGNORE_VALUE |
| 61 | +
|
| 62 | + } else { |
| 63 | + println "Using an external service to test " + project.name |
| 64 | + } |
| 65 | +} |
| 66 | +
|
0 commit comments