1
1
import org.elasticsearch.gradle.MavenFilteringHack
2
2
import org.elasticsearch.gradle.info.BuildParams
3
- import org.elasticsearch.gradle.test.AntFixture
4
3
import org.elasticsearch.gradle.test.RestIntegTestTask
5
4
6
5
import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
@@ -23,6 +22,7 @@ import static org.elasticsearch.gradle.PropertyNormalization.IGNORE_VALUE
23
22
* specific language governing permissions and limitations
24
23
* under the License.
25
24
*/
25
+ apply plugin : ' elasticsearch.test.fixtures'
26
26
27
27
esplugin {
28
28
description ' The S3 repository plugin adds S3 repositories'
@@ -52,7 +52,7 @@ dependencies {
52
52
// and whitelist this hack in JarHell
53
53
compile ' javax.xml.bind:jaxb-api:2.2.2'
54
54
55
- testCompile project(' :test:fixtures:minio -fixture' )
55
+ testCompile project(' :test:fixtures:s3 -fixture' )
56
56
}
57
57
58
58
dependencyLicenses {
@@ -104,7 +104,7 @@ if (!s3PermanentAccessKey && !s3PermanentSecretKey && !s3PermanentBucket && !s3P
104
104
s3PermanentAccessKey = ' access_key'
105
105
s3PermanentSecretKey = ' secret_key'
106
106
s3PermanentBucket = ' bucket'
107
- s3PermanentBasePath = ' '
107
+ s3PermanentBasePath = ' base_path '
108
108
109
109
useFixture = true
110
110
@@ -113,21 +113,21 @@ if (!s3PermanentAccessKey && !s3PermanentSecretKey && !s3PermanentBucket && !s3P
113
113
}
114
114
115
115
if (! s3TemporaryAccessKey && ! s3TemporarySecretKey && ! s3TemporaryBucket && ! s3TemporaryBasePath && ! s3TemporarySessionToken) {
116
- s3TemporaryAccessKey = ' s3_integration_test_temporary_access_key '
117
- s3TemporarySecretKey = ' s3_integration_test_temporary_secret_key '
118
- s3TemporaryBucket = ' temporary-bucket-test '
119
- s3TemporaryBasePath = ' integration_test '
120
- s3TemporarySessionToken = ' s3_integration_test_temporary_session_token '
116
+ s3TemporaryAccessKey = ' session_token_access_key '
117
+ s3TemporarySecretKey = ' session_token_secret_key '
118
+ s3TemporaryBucket = ' session_token_bucket '
119
+ s3TemporaryBasePath = ' session_token_base_path '
120
+ s3TemporarySessionToken = ' session_token '
121
121
122
122
} else if (! s3TemporaryAccessKey || ! s3TemporarySecretKey || ! s3TemporaryBucket || ! s3TemporaryBasePath || ! s3TemporarySessionToken) {
123
123
throw new IllegalArgumentException (" not all options specified to run against external S3 service as temporary credentials are present" )
124
124
}
125
125
126
126
if (! s3EC2Bucket && ! s3EC2BasePath && ! s3ECSBucket && ! s3ECSBasePath) {
127
- s3EC2Bucket = ' ec2-bucket-test '
128
- s3EC2BasePath = ' integration_test '
129
- s3ECSBucket = ' ecs-bucket-test '
130
- s3ECSBasePath = ' integration_test '
127
+ s3EC2Bucket = ' ec2_bucket '
128
+ s3EC2BasePath = ' ec2_base_path '
129
+ s3ECSBucket = ' ecs_bucket '
130
+ s3ECSBasePath = ' ecs_base_path '
131
131
} else if (! s3EC2Bucket || ! s3EC2BasePath || ! s3ECSBucket || ! s3ECSBasePath) {
132
132
throw new IllegalArgumentException (" not all options specified to run EC2/ECS tests are present" )
133
133
}
@@ -141,8 +141,6 @@ task thirdPartyTest(type: Test) {
141
141
}
142
142
143
143
if (useFixture) {
144
- apply plugin : ' elasticsearch.test.fixtures'
145
-
146
144
testFixtures. useFixture(' :test:fixtures:minio-fixture' )
147
145
148
146
def minioAddress = {
@@ -200,39 +198,6 @@ if (useFixture) {
200
198
201
199
check. dependsOn(thirdPartyTest)
202
200
203
- File parentFixtures = new File (project. buildDir, " fixtures" )
204
- File s3FixtureFile = new File (parentFixtures, ' s3Fixture.properties' )
205
-
206
- task s3FixtureProperties {
207
- outputs. file(s3FixtureFile)
208
- def s3FixtureOptions = [
209
- " tests.seed" : BuildParams . testSeed,
210
- " s3Fixture.permanent_bucket_name" : s3PermanentBucket,
211
- " s3Fixture.permanent_key" : s3PermanentAccessKey,
212
- " s3Fixture.temporary_bucket_name" : s3TemporaryBucket,
213
- " s3Fixture.temporary_key" : s3TemporaryAccessKey,
214
- " s3Fixture.temporary_session_token" : s3TemporarySessionToken,
215
- " s3Fixture.ec2_bucket_name" : s3EC2Bucket,
216
- " s3Fixture.ecs_bucket_name" : s3ECSBucket,
217
- " s3Fixture.disableChunkedEncoding" : s3DisableChunkedEncoding
218
- ]
219
-
220
- doLast {
221
- file(s3FixtureFile). text = s3FixtureOptions. collect { k , v -> " $k = $v " }. join(" \n " )
222
- }
223
- }
224
-
225
- /* * A task to start the AmazonS3Fixture which emulates an S3 service **/
226
- task s3Fixture (type : AntFixture ) {
227
- dependsOn testClasses
228
- dependsOn s3FixtureProperties
229
- inputs. file(s3FixtureFile)
230
-
231
- env ' CLASSPATH' , " ${ -> project.sourceSets.test.runtimeClasspath.asPath} "
232
- executable = " ${ BuildParams.runtimeJavaHome} /bin/java"
233
- args ' org.elasticsearch.repositories.s3.AmazonS3Fixture' , baseDir, s3FixtureFile. getAbsolutePath()
234
- }
235
-
236
201
processTestResources {
237
202
Map<String , Object > expansions = [
238
203
' permanent_bucket' : s3PermanentBucket,
@@ -249,8 +214,13 @@ processTestResources {
249
214
MavenFilteringHack . filter(it, expansions)
250
215
}
251
216
252
- integTest {
253
- dependsOn s3Fixture
217
+ testFixtures. useFixture(' :test:fixtures:s3-fixture' )
218
+
219
+ def fixtureAddress = { fixture ->
220
+ assert useFixture: ' closure should not be used without a fixture'
221
+ int ephemeralPort = project(' :test:fixtures:s3-fixture' ). postProcessFixture. ext. " test.fixtures.${ fixture} .tcp.80"
222
+ assert ephemeralPort > 0
223
+ ' http://127.0.0.1:' + ephemeralPort
254
224
}
255
225
256
226
testClusters. integTest {
@@ -262,12 +232,12 @@ testClusters.integTest {
262
232
keystore ' s3.client.integration_test_temporary.session_token' , s3TemporarySessionToken
263
233
264
234
if (useFixture) {
265
- setting ' s3.client.integration_test_permanent.endpoint' , { " http:// ${ s3Fixture.addressAndPort } " }, IGNORE_VALUE
266
- setting ' s3.client.integration_test_temporary.endpoint' , { " http:// ${ s3Fixture.addressAndPort } " }, IGNORE_VALUE
267
- setting ' s3.client.integration_test_ec2.endpoint' , { " http:// ${ s3Fixture.addressAndPort } " }, IGNORE_VALUE
235
+ setting ' s3.client.integration_test_permanent.endpoint' , { "${ -> fixtureAddress( ' s3-fixture ' ) }" }, IGNORE_VALUE
236
+ setting 's3.client.integration_test_temporary.endpoint', { " ${ -> fixtureAddress( ' s3-fixture-with-session-token ' ) }" }, IGNORE_VALUE
237
+ setting 's3.client.integration_test_ec2.endpoint', { " ${ -> fixtureAddress( ' s3-fixture-with-ec2 ' ) }" }, IGNORE_VALUE
268
238
269
239
// to redirect InstanceProfileCredentialsProvider to custom auth point
270
- systemProperty " com.amazonaws.sdk.ec2MetadataServiceEndpointOverride" , { " http:// ${ s3Fixture.addressAndPort } " }, IGNORE_VALUE
240
+ systemProperty " com. amazonaws. sdk. ec2MetadataServiceEndpointOverride" , { " ${ -> fixtureAddress( ' s3-fixture-with-ec2 ' ) }" }, IGNORE_VALUE
271
241
} else {
272
242
println " Using an external service to test the repository- s3 plugin"
273
243
}
@@ -280,7 +250,7 @@ task s3ThirdPartyTests {
280
250
if (useFixture) {
281
251
task integTestECS(type: RestIntegTestTask.class) {
282
252
description = " Runs tests using the ECS repository. "
283
- dependsOn(project . s3Fixture, ' bundlePlugin' )
253
+ dependsOn('bundlePlugin')
284
254
runner {
285
255
systemProperty 'tests.rest.blacklist', [
286
256
'repository_s3/10_basic/*',
@@ -293,9 +263,9 @@ if (useFixture) {
293
263
check.dependsOn(integTestECS)
294
264
295
265
testClusters.integTestECS {
296
- setting ' s3.client.integration_test_ecs.endpoint' , { " http:// ${ s3Fixture.addressAndPort } " }, IGNORE_VALUE
266
+ setting 's3.client.integration_test_ecs.endpoint', { " ${ -> fixtureAddress( ' s3-fixture-with-ecs ' ) }" }, IGNORE_VALUE
297
267
plugin file(tasks.bundlePlugin.archiveFile)
298
- environment ' AWS_CONTAINER_CREDENTIALS_FULL_URI' , { " http:// ${ s3Fixture.addressAndPort } /ecs_credentials_endpoint" }, IGNORE_VALUE
268
+ environment 'AWS_CONTAINER_CREDENTIALS_FULL_URI', { " ${ -> fixtureAddress( ' s3-fixture-with-ecs ' ) }/ ecs_credentials_endpoint" }, IGNORE_VALUE
299
269
}
300
270
301
271
gradle.taskGraph.whenReady {
0 commit comments