18
18
*/
19
19
20
20
import org.apache.tools.ant.taskdefs.condition.Os
21
- import org.elasticsearch.gradle.test.ClusterConfiguration
22
21
import org.elasticsearch.gradle.test.RestIntegTestTask
23
22
24
23
import java.nio.file.Files
@@ -64,15 +63,17 @@ dependencies {
64
63
compile " org.apache.logging.log4j:log4j-slf4j-impl:${ versions.log4j} "
65
64
66
65
hdfsFixture project(' :test:fixtures:hdfs-fixture' )
66
+ // Set the keytab files in the classpath so that we can access them from test code without the security manager
67
+ // freaking out.
68
+ testRuntime fileTree(dir : project(' :test:fixtures:krb5kdc-fixture' ). ext. krb5Keytabs(" hdfs" ," hdfs_hdfs.build.elastic.co.keytab" ). parent, include : [' *.keytab' ])
67
69
}
68
70
69
71
dependencyLicenses {
70
72
mapping from : / hadoop-.*/ , to : ' hadoop'
71
73
}
72
74
73
-
74
75
String realm = " BUILD.ELASTIC.CO"
75
-
76
+ String krb5conf = project( ' :test:fixtures:krb5kdc-fixture ' ) . ext . krb5Conf( " hdfs " )
76
77
77
78
// Create HDFS File System Testing Fixtures for HA/Secure combinations
78
79
for (String fixtureName : [' hdfsFixture' , ' haHdfsFixture' , ' secureHdfsFixture' , ' secureHaHdfsFixture' ]) {
@@ -91,9 +92,8 @@ for (String fixtureName : ['hdfsFixture', 'haHdfsFixture', 'secureHdfsFixture',
91
92
92
93
// If it's a secure fixture, then depend on Kerberos Fixture and principals + add the krb5conf to the JVM options
93
94
if (fixtureName. equals(' secureHdfsFixture' ) || fixtureName. equals(' secureHaHdfsFixture' )) {
94
- miniHDFSArgs. add(" -Djava.security.krb5.conf=${ project(':test:fixtures:krb5kdc-fixture').ext.krb5Conf("hdfs") } " );
95
+ miniHDFSArgs. add(" -Djava.security.krb5.conf=${ krb5conf } " )
95
96
}
96
-
97
97
// If it's an HA fixture, set a nameservice to use in the JVM options
98
98
if (fixtureName. equals(' haHdfsFixture' ) || fixtureName. equals(' secureHaHdfsFixture' )) {
99
99
miniHDFSArgs. add(" -Dha-nameservice=ha-hdfs" )
@@ -107,70 +107,44 @@ for (String fixtureName : ['hdfsFixture', 'haHdfsFixture', 'secureHdfsFixture',
107
107
if (fixtureName. equals(' secureHdfsFixture' ) || fixtureName. equals(' secureHaHdfsFixture' )) {
108
108
miniHDFSArgs. add(" hdfs/hdfs.build.elastic.co@${ realm} " )
109
109
miniHDFSArgs. add(
110
- project(' :test:fixtures:krb5kdc-fixture' )
111
- .ext. krb5Keytabs(" hdfs" , " hdfs_hdfs.build.elastic.co.keytab" )
110
+ project(' :test:fixtures:krb5kdc-fixture' ). ext. krb5Keytabs(" hdfs" , " hdfs_hdfs.build.elastic.co.keytab" )
112
111
)
113
112
}
114
113
115
114
args miniHDFSArgs. toArray()
116
115
}
117
116
}
118
117
119
- // The following closure must execute before the afterEvaluate block in the constructor of the following integrationTest tasks:
120
- project. afterEvaluate {
121
- for (String integTestTaskName : [' integTestHa' , ' integTestSecure' , ' integTestSecureHa' ]) {
122
- ClusterConfiguration cluster = project. extensions. getByName(" ${ integTestTaskName} Cluster" ) as ClusterConfiguration
123
- cluster. dependsOn(project. bundlePlugin)
124
-
125
- Task restIntegTestTask = project. tasks. getByName(integTestTaskName)
126
- restIntegTestTask. clusterConfig. plugin(project. path)
127
-
128
- // Default jvm arguments for all test clusters
129
- String jvmArgs = " -Xms" + System . getProperty(' tests.heap.size' , ' 512m' ) +
130
- " " + " -Xmx" + System . getProperty(' tests.heap.size' , ' 512m' ) +
131
- " " + System . getProperty(' tests.jvm.argline' , ' ' )
132
-
133
- // If it's a secure cluster, add the keytab as an extra config, and set the krb5 conf in the JVM options.
134
- if (integTestTaskName. equals(' integTestSecure' ) || integTestTaskName. equals(' integTestSecureHa' )) {
135
- String krb5conf = project(' :test:fixtures:krb5kdc-fixture' ). ext. krb5Conf(" hdfs" )
136
- restIntegTestTask. clusterConfig. extraConfigFile(
137
- " repository-hdfs/krb5.keytab" ,
138
- " ${ project(':test:fixtures:krb5kdc-fixture').ext.krb5Keytabs("hdfs", "elasticsearch.keytab")} "
139
- )
140
- jvmArgs = jvmArgs + " " + " -Djava.security.krb5.conf=${ krb5conf} "
141
-
142
- // If it's the HA + Secure tests then also set the Kerberos settings for the integration test JVM since we'll
143
- // need to auth to HDFS to trigger namenode failovers.
144
- if (integTestTaskName. equals(' integTestSecureHa' )) {
145
- Task restIntegTestTaskRunner = project. tasks. getByName(" ${ integTestTaskName} Runner" )
146
- restIntegTestTaskRunner. systemProperty " test.krb5.principal.es" , " elasticsearch@${ realm} "
147
- restIntegTestTaskRunner. systemProperty " test.krb5.principal.hdfs" , " hdfs/hdfs.build.elastic.co@${ realm} "
148
- restIntegTestTaskRunner. jvmArgs " -Djava.security.krb5.conf=${ krb5conf} "
149
- restIntegTestTaskRunner. systemProperty (
118
+ for (String integTestTaskName : [' integTestHa' , ' integTestSecure' , ' integTestSecureHa' ]) {
119
+ task " ${ integTestTaskName} " (type : RestIntegTestTask ) {
120
+ description = " Runs rest tests against an elasticsearch cluster with HDFS."
121
+ dependsOn(project. bundlePlugin)
122
+ runner {
123
+ if (integTestTaskName. contains(" Secure" )) {
124
+ dependsOn secureHdfsFixture
125
+ systemProperty " test.krb5.principal.es" , " elasticsearch@${ realm} "
126
+ systemProperty " test.krb5.principal.hdfs" , " hdfs/hdfs.build.elastic.co@${ realm} "
127
+ jvmArgs " -Djava.security.krb5.conf=${ krb5conf} "
128
+ systemProperty (
150
129
" test.krb5.keytab.hdfs" ,
151
130
project(' :test:fixtures:krb5kdc-fixture' ). ext. krb5Keytabs(" hdfs" ," hdfs_hdfs.build.elastic.co.keytab" )
152
131
)
153
132
}
154
133
}
155
-
156
- restIntegTestTask. clusterConfig. jvmArgs = jvmArgs
157
134
}
158
- }
159
135
160
- // Create a Integration Test suite just for HA based tests
161
- RestIntegTestTask integTestHa = project. tasks. create(' integTestHa' , RestIntegTestTask . class) {
162
- description = " Runs rest tests against an elasticsearch cluster with HDFS configured with HA Namenode."
163
- }
164
-
165
- // Create a Integration Test suite just for security based tests
166
- RestIntegTestTask integTestSecure = project. tasks. create(' integTestSecure' , RestIntegTestTask . class) {
167
- description = " Runs rest tests against an elasticsearch cluster with HDFS secured by MIT Kerberos."
136
+ testClusters. " ${ integTestTaskName} " {
137
+ plugin(file(bundlePlugin. archiveFile))
138
+ if (integTestTaskName. contains(" Secure" )) {
139
+ systemProperty " java.security.krb5.conf" , krb5conf
140
+ extraConfigFile(
141
+ " repository-hdfs/krb5.keytab" ,
142
+ file(" ${ project(':test:fixtures:krb5kdc-fixture').ext.krb5Keytabs("hdfs", "elasticsearch.keytab")} " )
143
+ )
144
+ }
145
+ }
168
146
}
169
147
170
- // Create a Integration Test suite just for HA related security based tests
171
- RestIntegTestTask integTestSecureHa = project. tasks. create(' integTestSecureHa' , RestIntegTestTask . class) {
172
- description = " Runs rest tests against an elasticsearch cluster with HDFS configured with HA Namenode and secured by MIT Kerberos."
173
- }
174
148
175
149
// Determine HDFS Fixture compatibility for the current build environment.
176
150
boolean fixtureSupported = false
@@ -199,21 +173,27 @@ if (legalPath == false) {
199
173
200
174
// Always ignore HA integration tests in the normal integration test runner, they are included below as
201
175
// part of their own HA-specific integration test tasks.
202
- integTestRunner. exclude(' **/Ha*TestSuiteIT.class' )
176
+ integTest. runner {
177
+ exclude(' **/Ha*TestSuiteIT.class' )
178
+ }
203
179
204
180
if (fixtureSupported) {
205
181
// Check depends on the HA test. Already depends on the standard test.
206
182
project. check. dependsOn(integTestHa)
207
183
208
184
// Both standard and HA tests depend on their respective HDFS fixtures
209
- integTestCluster . dependsOn hdfsFixture
210
- integTestHaCluster . dependsOn haHdfsFixture
185
+ integTest . dependsOn hdfsFixture
186
+ integTestHa . dependsOn haHdfsFixture
211
187
212
188
// The normal test runner only runs the standard hdfs rest tests
213
- integTestRunner. systemProperty ' tests.rest.suite' , ' hdfs_repository'
189
+ integTest. runner {
190
+ systemProperty ' tests.rest.suite' , ' hdfs_repository'
191
+ }
214
192
215
193
// Only include the HA integration tests for the HA test task
216
- integTestHaRunner. setIncludes([' **/Ha*TestSuiteIT.class' ])
194
+ integTestHa. runner {
195
+ setIncludes([' **/Ha*TestSuiteIT.class' ])
196
+ }
217
197
} else {
218
198
if (legalPath) {
219
199
logger. warn(" hdfsFixture unsupported, please set HADOOP_HOME and put HADOOP_HOME\\ bin in PATH" )
@@ -222,29 +202,27 @@ if (fixtureSupported) {
222
202
}
223
203
224
204
// The normal integration test runner will just test that the plugin loads
225
- integTestRunner. systemProperty ' tests.rest.suite' , ' hdfs_repository/10_basic'
205
+ integTest. runner {
206
+ systemProperty ' tests.rest.suite' , ' hdfs_repository/10_basic'
207
+ }
226
208
// HA fixture is unsupported. Don't run them.
227
209
integTestHa. setEnabled(false )
228
210
}
229
211
230
212
check. dependsOn(integTestSecure, integTestSecureHa)
231
213
232
- // Fixture dependencies
233
- integTestSecureCluster. dependsOn secureHdfsFixture
234
- integTestSecureHaCluster. dependsOn secureHaHdfsFixture
235
-
236
- // Set the keytab files in the classpath so that we can access them from test code without the security manager
237
- // freaking out.
238
- project. dependencies {
239
- testRuntime fileTree(dir : project(' :test:fixtures:krb5kdc-fixture' ). ext. krb5Keytabs(" hdfs" ," hdfs_hdfs.build.elastic.co.keytab" ). parent, include : [' *.keytab' ])
240
- }
241
-
242
214
// Run just the secure hdfs rest test suite.
243
- integTestSecureRunner. systemProperty ' tests.rest.suite' , ' secure_hdfs_repository'
215
+ integTestSecure. runner {
216
+ systemProperty ' tests.rest.suite' , ' secure_hdfs_repository'
217
+ }
244
218
// Ignore HA integration Tests. They are included below as part of integTestSecureHa test runner.
245
- integTestSecureRunner. exclude(' **/Ha*TestSuiteIT.class' )
219
+ integTestSecure. runner {
220
+ exclude(' **/Ha*TestSuiteIT.class' )
221
+ }
246
222
// Only include the HA integration tests for the HA test task
247
- integTestSecureHaRunner. setIncludes([' **/Ha*TestSuiteIT.class' ])
223
+ integTestSecureHa. runner {
224
+ setIncludes([' **/Ha*TestSuiteIT.class' ])
225
+ }
248
226
249
227
thirdPartyAudit {
250
228
ignoreMissingClasses()
0 commit comments