@@ -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()
@@ -171,10 +134,11 @@ project.afterEvaluate {
171
134
172
135
// If it's a secure cluster, add the keytab as an extra config, and set the krb5 conf in the JVM options.
173
136
if (integTestTaskName. equals(' integTestSecure' ) || integTestTaskName. equals(' integTestSecureHa' )) {
174
- Path elasticsearchKT = project(' :test:fixtures:krb5kdc-fixture' ). buildDir. toPath(). resolve(" keytabs" ). resolve(" elasticsearch.keytab" ). toAbsolutePath()
175
- Path krb5conf = project(' :test:fixtures:krb5kdc-fixture' ). buildDir. toPath(). resolve(" conf" ). resolve(" krb5.conf" ). toAbsolutePath()
176
-
177
- restIntegTestTask. clusterConfig. extraConfigFile(" repository-hdfs/krb5.keytab" , " ${ elasticsearchKT} " )
137
+ String krb5conf = project(' :test:fixtures:krb5kdc-fixture' ). ext. krb5Conf(" hdfs" )
138
+ restIntegTestTask. clusterConfig. extraConfigFile(
139
+ " repository-hdfs/krb5.keytab" ,
140
+ " ${ project(':test:fixtures:krb5kdc-fixture').ext.krb5Keytabs("hdfs", "elasticsearch.keytab")} "
141
+ )
178
142
jvmArgs = jvmArgs + " " + " -Djava.security.krb5.conf=${ krb5conf} "
179
143
if (project. runtimeJavaVersion == JavaVersion . VERSION_1_9 ) {
180
144
jvmArgs = jvmArgs + " " + ' --add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED'
@@ -190,9 +154,10 @@ project.afterEvaluate {
190
154
if (project. runtimeJavaVersion == JavaVersion . VERSION_1_9 ) {
191
155
restIntegTestTaskRunner. jvmArg ' --add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED'
192
156
}
193
-
194
- Path hdfsKT = project(' :test:fixtures:krb5kdc-fixture' ). buildDir. toPath(). resolve(" keytabs" ). resolve(" hdfs_hdfs.build.elastic.co.keytab" ). toAbsolutePath()
195
- restIntegTestTaskRunner. systemProperty " test.krb5.keytab.hdfs" , " ${ hdfsKT} "
157
+ restIntegTestTaskRunner. systemProperty (
158
+ " test.krb5.keytab.hdfs" ,
159
+ project(' :test:fixtures:krb5kdc-fixture' ). ext. krb5Keytabs(" hdfs" ," hdfs_hdfs.build.elastic.co.keytab" )
160
+ )
196
161
}
197
162
}
198
163
@@ -270,41 +235,25 @@ if (fixtureSupported) {
270
235
integTestHa. setEnabled(false )
271
236
}
272
237
273
- // Secure HDFS testing relies on the Vagrant based Kerberos fixture.
274
- boolean secureFixtureSupported = false
275
- if (fixtureSupported) {
276
- secureFixtureSupported = project. rootProject. vagrantSupported
277
- }
278
-
279
- if (secureFixtureSupported) {
280
- project. check. dependsOn(integTestSecure)
281
- project. check. dependsOn(integTestSecureHa)
238
+ check. dependsOn(integTestSecure, integTestSecureHa)
282
239
283
- // Fixture dependencies
284
- integTestSecureCluster. dependsOn secureHdfsFixture, krb5kdcFixture
285
- integTestSecureHaCluster. dependsOn secureHaHdfsFixture, krb5kdcFixture
240
+ // Fixture dependencies
241
+ integTestSecureCluster. dependsOn secureHdfsFixture
242
+ integTestSecureHaCluster. dependsOn secureHaHdfsFixture
286
243
287
- // Set the keytab files in the classpath so that we can access them from test code without the security manager
288
- // freaking out.
289
- Path hdfsKeytabPath = project(' :test:fixtures:krb5kdc-fixture' ). buildDir. toPath(). resolve(" keytabs" )
290
- project. dependencies {
291
- testRuntime fileTree(dir : hdfsKeytabPath. toString(), include : [' *.keytab' ])
292
- }
293
-
294
- // Run just the secure hdfs rest test suite.
295
- integTestSecureRunner. systemProperty ' tests.rest.suite' , ' secure_hdfs_repository'
296
- // Ignore HA integration Tests. They are included below as part of integTestSecureHa test runner.
297
- integTestSecureRunner. exclude(' **/Ha*TestSuiteIT.class' )
298
-
299
- // Only include the HA integration tests for the HA test task
300
- integTestSecureHaRunner. patternSet. setIncludes([' **/Ha*TestSuiteIT.class' ])
301
- } else {
302
- // Security tests unsupported. Don't run these tests.
303
- integTestSecure. enabled = false
304
- integTestSecureHa. enabled = false
305
- testingConventions. enabled = false
244
+ // Set the keytab files in the classpath so that we can access them from test code without the security manager
245
+ // freaking out.
246
+ project. dependencies {
247
+ testRuntime fileTree(dir : project(' :test:fixtures:krb5kdc-fixture' ). ext. krb5Keytabs(" hdfs" ," hdfs_hdfs.build.elastic.co.keytab" ). parent, include : [' *.keytab' ])
306
248
}
307
249
250
+ // Run just the secure hdfs rest test suite.
251
+ integTestSecureRunner. systemProperty ' tests.rest.suite' , ' secure_hdfs_repository'
252
+ // Ignore HA integration Tests. They are included below as part of integTestSecureHa test runner.
253
+ integTestSecureRunner. exclude(' **/Ha*TestSuiteIT.class' )
254
+ // Only include the HA integration tests for the HA test task
255
+ integTestSecureHaRunner. patternSet. setIncludes([' **/Ha*TestSuiteIT.class' ])
256
+
308
257
thirdPartyAudit {
309
258
ignoreMissingClasses()
310
259
ignoreViolations (
0 commit comments