@@ -24,18 +24,19 @@ import org.elasticsearch.gradle.test.RestIntegTestTask
24
24
import java.nio.file.Files
25
25
import java.nio.file.Path
26
26
import java.nio.file.Paths
27
-
27
+ apply plugin : ' elasticsearch.test.fixtures'
28
+
28
29
esplugin {
29
30
description ' The HDFS repository plugin adds support for Hadoop Distributed File-System (HDFS) repositories.'
30
31
classname ' org.elasticsearch.repositories.hdfs.HdfsPlugin'
31
32
}
32
33
33
- apply plugin : ' elasticsearch.vagrantsupport'
34
-
35
34
versions << [
36
35
' hadoop2' : ' 2.8.1'
37
36
]
38
37
38
+ testFixtures. useFixture " :test:fixtures:krb5kdc-fixture"
39
+
39
40
configurations {
40
41
hdfsFixture
41
42
}
@@ -68,67 +69,27 @@ dependencyLicenses {
68
69
mapping from : / hadoop-.*/ , to : ' hadoop'
69
70
}
70
71
71
- // MIT Kerberos Vagrant Testing Fixture
72
- String box = " krb5kdc"
73
- Map<String ,String > vagrantEnvVars = [
74
- ' VAGRANT_CWD' : " ${ project(':test:fixtures:krb5kdc-fixture').projectDir} " ,
75
- ' VAGRANT_VAGRANTFILE' : ' Vagrantfile' ,
76
- ' VAGRANT_PROJECT_DIR' : " ${ project(':test:fixtures:krb5kdc-fixture').projectDir} "
77
- ]
78
-
79
- task krb5kdcUpdate (type : org.elasticsearch.gradle.vagrant.VagrantCommandTask ) {
80
- command ' box'
81
- subcommand ' update'
82
- boxName box
83
- environmentVars vagrantEnvVars
84
- dependsOn " vagrantCheckVersion" , " virtualboxCheckVersion"
85
- }
86
-
87
- task krb5kdcFixture (type : org.elasticsearch.gradle.test.VagrantFixture ) {
88
- command ' up'
89
- args ' --provision' , ' --provider' , ' virtualbox'
90
- boxName box
91
- environmentVars vagrantEnvVars
92
- dependsOn krb5kdcUpdate
93
- }
94
-
95
- task krb5AddPrincipals {
96
- dependsOn krb5kdcFixture
97
- }
98
72
99
- List<String > principals = [ " elasticsearch" , " hdfs/hdfs.build.elastic.co" ]
100
73
String realm = " BUILD.ELASTIC.CO"
101
74
102
- for (String principal : principals) {
103
- Task create = project. tasks. create(" addPrincipal#${ principal} " . replace(' /' , ' _' ), org.elasticsearch.gradle.vagrant.VagrantCommandTask ) {
104
- command ' ssh'
105
- args ' --command' , " sudo bash /vagrant/src/main/resources/provision/addprinc.sh $principal "
106
- boxName box
107
- environmentVars vagrantEnvVars
108
- dependsOn krb5kdcFixture
109
- }
110
- krb5AddPrincipals. dependsOn(create)
111
- }
112
75
113
76
// Create HDFS File System Testing Fixtures for HA/Secure combinations
114
77
for (String fixtureName : [' hdfsFixture' , ' haHdfsFixture' , ' secureHdfsFixture' , ' secureHaHdfsFixture' ]) {
115
78
project. tasks. create(fixtureName, org.elasticsearch.gradle.test.AntFixture ) {
116
- dependsOn project. configurations. hdfsFixture
79
+ dependsOn project. configurations. hdfsFixture, project( ' :test:fixtures:krb5kdc-fixture ' ) . tasks . postProcessFixture
117
80
executable = new File (project. runtimeJavaHome, ' bin/java' )
118
81
env ' CLASSPATH' , " ${ -> project.configurations.hdfsFixture.asPath } "
119
82
waitCondition = { fixture , ant ->
120
83
// the hdfs.MiniHDFS fixture writes the ports file when
121
84
// it's ready, so we can just wait for the file to exist
122
85
return fixture. portsFile. exists()
123
- }
86
+ }
124
87
125
88
final List<String > miniHDFSArgs = []
126
89
127
90
// If it's a secure fixture, then depend on Kerberos Fixture and principals + add the krb5conf to the JVM options
128
91
if (fixtureName. equals(' secureHdfsFixture' ) || fixtureName. equals(' secureHaHdfsFixture' )) {
129
- dependsOn krb5kdcFixture, krb5AddPrincipals
130
- Path krb5Config = project(' :test:fixtures:krb5kdc-fixture' ). buildDir. toPath(). resolve(" conf" ). resolve(" krb5.conf" )
131
- miniHDFSArgs. add(" -Djava.security.krb5.conf=${ krb5Config} " );
92
+ miniHDFSArgs. add(" -Djava.security.krb5.conf=${ project(':test:fixtures:krb5kdc-fixture').ext.krb5Conf("hdfs")} " );
132
93
if (project. runtimeJavaVersion == JavaVersion . VERSION_1_9 ) {
133
94
miniHDFSArgs. add(' --add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED' )
134
95
}
@@ -145,9 +106,11 @@ for (String fixtureName : ['hdfsFixture', 'haHdfsFixture', 'secureHdfsFixture',
145
106
146
107
// If it's a secure fixture, then set the principal name and keytab locations to use for auth.
147
108
if (fixtureName. equals(' secureHdfsFixture' ) || fixtureName. equals(' secureHaHdfsFixture' )) {
148
- Path keytabPath = project(' :test:fixtures:krb5kdc-fixture' ). buildDir. toPath(). resolve(" keytabs" ). resolve(" hdfs_hdfs.build.elastic.co.keytab" )
149
109
miniHDFSArgs. add(" hdfs/hdfs.build.elastic.co@${ realm} " )
150
- miniHDFSArgs. add(" ${ keytabPath} " )
110
+ miniHDFSArgs. add(
111
+ project(' :test:fixtures:krb5kdc-fixture' )
112
+ .ext. krb5Keytabs(" hdfs" , " hdfs_hdfs.build.elastic.co.keytab" )
113
+ )
151
114
}
152
115
153
116
args miniHDFSArgs. toArray()
@@ -170,10 +133,11 @@ project.afterEvaluate {
170
133
171
134
// If it's a secure cluster, add the keytab as an extra config, and set the krb5 conf in the JVM options.
172
135
if (integTestTaskName. equals(' integTestSecure' ) || integTestTaskName. equals(' integTestSecureHa' )) {
173
- Path elasticsearchKT = project(' :test:fixtures:krb5kdc-fixture' ). buildDir. toPath(). resolve(" keytabs" ). resolve(" elasticsearch.keytab" ). toAbsolutePath()
174
- Path krb5conf = project(' :test:fixtures:krb5kdc-fixture' ). buildDir. toPath(). resolve(" conf" ). resolve(" krb5.conf" ). toAbsolutePath()
175
-
176
- restIntegTestTask. clusterConfig. extraConfigFile(" repository-hdfs/krb5.keytab" , " ${ elasticsearchKT} " )
136
+ String krb5conf = project(' :test:fixtures:krb5kdc-fixture' ). ext. krb5Conf(" hdfs" )
137
+ restIntegTestTask. clusterConfig. extraConfigFile(
138
+ " repository-hdfs/krb5.keytab" ,
139
+ " ${ project(':test:fixtures:krb5kdc-fixture').ext.krb5Keytabs("hdfs", "elasticsearch.keytab")} "
140
+ )
177
141
jvmArgs = jvmArgs + " " + " -Djava.security.krb5.conf=${ krb5conf} "
178
142
if (project. runtimeJavaVersion == JavaVersion . VERSION_1_9 ) {
179
143
jvmArgs = jvmArgs + " " + ' --add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED'
@@ -189,9 +153,10 @@ project.afterEvaluate {
189
153
if (project. runtimeJavaVersion == JavaVersion . VERSION_1_9 ) {
190
154
restIntegTestTaskRunner. jvmArg ' --add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED'
191
155
}
192
-
193
- Path hdfsKT = project(' :test:fixtures:krb5kdc-fixture' ). buildDir. toPath(). resolve(" keytabs" ). resolve(" hdfs_hdfs.build.elastic.co.keytab" ). toAbsolutePath()
194
- restIntegTestTaskRunner. systemProperty " test.krb5.keytab.hdfs" , " ${ hdfsKT} "
156
+ restIntegTestTaskRunner. systemProperty (
157
+ " test.krb5.keytab.hdfs" ,
158
+ project(' :test:fixtures:krb5kdc-fixture' ). ext. krb5Keytabs(" hdfs" ," hdfs_hdfs.build.elastic.co.keytab" )
159
+ )
195
160
}
196
161
}
197
162
@@ -269,41 +234,25 @@ if (fixtureSupported) {
269
234
integTestHa. setEnabled(false )
270
235
}
271
236
272
- // Secure HDFS testing relies on the Vagrant based Kerberos fixture.
273
- boolean secureFixtureSupported = false
274
- if (fixtureSupported) {
275
- secureFixtureSupported = project. rootProject. vagrantSupported
276
- }
277
-
278
- if (secureFixtureSupported) {
279
- project. check. dependsOn(integTestSecure)
280
- project. check. dependsOn(integTestSecureHa)
237
+ check. dependsOn(integTestSecure, integTestSecureHa)
281
238
282
- // Fixture dependencies
283
- integTestSecureCluster. dependsOn secureHdfsFixture, krb5kdcFixture
284
- integTestSecureHaCluster. dependsOn secureHaHdfsFixture, krb5kdcFixture
239
+ // Fixture dependencies
240
+ integTestSecureCluster. dependsOn secureHdfsFixture
241
+ integTestSecureHaCluster. dependsOn secureHaHdfsFixture
285
242
286
- // Set the keytab files in the classpath so that we can access them from test code without the security manager
287
- // freaking out.
288
- Path hdfsKeytabPath = project(' :test:fixtures:krb5kdc-fixture' ). buildDir. toPath(). resolve(" keytabs" )
289
- project. dependencies {
290
- testRuntime fileTree(dir : hdfsKeytabPath. toString(), include : [' *.keytab' ])
291
- }
292
-
293
- // Run just the secure hdfs rest test suite.
294
- integTestSecureRunner. systemProperty ' tests.rest.suite' , ' secure_hdfs_repository'
295
- // Ignore HA integration Tests. They are included below as part of integTestSecureHa test runner.
296
- integTestSecureRunner. exclude(' **/Ha*TestSuiteIT.class' )
297
-
298
- // Only include the HA integration tests for the HA test task
299
- integTestSecureHaRunner. patternSet. setIncludes([' **/Ha*TestSuiteIT.class' ])
300
- } else {
301
- // Security tests unsupported. Don't run these tests.
302
- integTestSecure. enabled = false
303
- integTestSecureHa. enabled = false
304
- testingConventions. enabled = false
243
+ // Set the keytab files in the classpath so that we can access them from test code without the security manager
244
+ // freaking out.
245
+ project. dependencies {
246
+ testRuntime fileTree(dir : project(' :test:fixtures:krb5kdc-fixture' ). ext. krb5Keytabs(" hdfs" ," hdfs_hdfs.build.elastic.co.keytab" ). parent, include : [' *.keytab' ])
305
247
}
306
248
249
+ // Run just the secure hdfs rest test suite.
250
+ integTestSecureRunner. systemProperty ' tests.rest.suite' , ' secure_hdfs_repository'
251
+ // Ignore HA integration Tests. They are included below as part of integTestSecureHa test runner.
252
+ integTestSecureRunner. exclude(' **/Ha*TestSuiteIT.class' )
253
+ // Only include the HA integration tests for the HA test task
254
+ integTestSecureHaRunner. patternSet. setIncludes([' **/Ha*TestSuiteIT.class' ])
255
+
307
256
thirdPartyAudit {
308
257
ignoreMissingClasses()
309
258
ignoreViolations (
0 commit comments