|
| 1 | +import org.elasticsearch.gradle.MavenFilteringHack |
| 2 | +import org.elasticsearch.gradle.test.AntFixture |
| 3 | + |
1 | 4 | /*
|
2 | 5 | * Licensed to Elasticsearch under one or more contributor
|
3 | 6 | * license agreements. See the NOTICE file distributed with
|
@@ -64,14 +67,50 @@ test {
|
64 | 67 | exclude '**/*CredentialsTests.class'
|
65 | 68 | }
|
66 | 69 |
|
67 |
| -check { |
68 |
| - // also execute the QA tests when testing the plugin |
69 |
| - dependsOn 'qa:amazon-s3:check' |
| 70 | +boolean useFixture = false |
| 71 | + |
| 72 | +String s3AccessKey = System.getenv("amazon_s3_access_key") |
| 73 | +String s3SecretKey = System.getenv("amazon_s3_secret_key") |
| 74 | +String s3Bucket = System.getenv("amazon_s3_bucket") |
| 75 | +String s3BasePath = System.getenv("amazon_s3_base_path") |
| 76 | + |
| 77 | +if (!s3AccessKey && !s3SecretKey && !s3Bucket && !s3BasePath) { |
| 78 | + s3AccessKey = 's3_integration_test_access_key' |
| 79 | + s3SecretKey = 's3_integration_test_secret_key' |
| 80 | + s3Bucket = 'bucket_test' |
| 81 | + s3BasePath = 'integration_test' |
| 82 | + useFixture = true |
| 83 | +} |
| 84 | + |
| 85 | +/** A task to start the AmazonS3Fixture which emulates an S3 service **/ |
| 86 | +task s3Fixture(type: AntFixture) { |
| 87 | + dependsOn testClasses |
| 88 | + env 'CLASSPATH', "${ -> project.sourceSets.test.runtimeClasspath.asPath }" |
| 89 | + executable = new File(project.runtimeJavaHome, 'bin/java') |
| 90 | + args 'org.elasticsearch.repositories.s3.AmazonS3Fixture', baseDir, s3Bucket |
| 91 | +} |
| 92 | + |
| 93 | +Map<String, Object> expansions = [ |
| 94 | + 'bucket': s3Bucket, |
| 95 | + 'base_path': s3BasePath |
| 96 | +] |
| 97 | + |
| 98 | +processTestResources { |
| 99 | + inputs.properties(expansions) |
| 100 | + MavenFilteringHack.filter(it, expansions) |
70 | 101 | }
|
71 | 102 |
|
72 | 103 | integTestCluster {
|
73 |
| - keystoreSetting 's3.client.integration_test.access_key', "s3_integration_test_access_key" |
74 |
| - keystoreSetting 's3.client.integration_test.secret_key', "s3_integration_test_secret_key" |
| 104 | + keystoreSetting 's3.client.integration_test.access_key', s3AccessKey |
| 105 | + keystoreSetting 's3.client.integration_test.secret_key', s3SecretKey |
| 106 | + |
| 107 | + if (useFixture) { |
| 108 | + dependsOn s3Fixture |
| 109 | + /* Use a closure on the string to delay evaluation until tests are executed */ |
| 110 | + setting 's3.client.integration_test.endpoint', "http://${-> s3Fixture.addressAndPort}" |
| 111 | + } else { |
| 112 | + println "Using an external service to test the repository-s3 plugin" |
| 113 | + } |
75 | 114 | }
|
76 | 115 |
|
77 | 116 | thirdPartyAudit.excludes = [
|
|
0 commit comments