@@ -29,8 +29,6 @@ esplugin {
2929 classname ' org.elasticsearch.repositories.hdfs.HdfsPlugin'
3030}
3131
32- apply plugin : ' elasticsearch.vagrantsupport'
33-
3432versions << [
3533 ' hadoop2' : ' 2.7.1'
3634]
@@ -85,7 +83,6 @@ task krb5kdcUpdate(type: org.elasticsearch.gradle.vagrant.VagrantCommandTask) {
8583 subcommand ' update'
8684 boxName box
8785 environmentVars vagrantEnvVars
88- dependsOn " vagrantCheckVersion" , " virtualboxCheckVersion"
8986}
9087
9188task krb5kdcFixture (type : org.elasticsearch.gradle.test.VagrantFixture ) {
@@ -128,7 +125,7 @@ task secureHdfsFixture(type: org.elasticsearch.gradle.test.AntFixture) {
128125 " ${ keytabPath} "
129126}
130127
131- boolean fixtureSupported = false
128+ boolean fixtureSupported = false ;
132129if (Os . isFamily(Os . FAMILY_WINDOWS )) {
133130 // hdfs fixture will not start without hadoop native libraries on windows
134131 String nativePath = System . getenv(" HADOOP_HOME" )
@@ -156,38 +153,60 @@ if (fixtureSupported) {
156153 integTestRunner. systemProperty ' tests.rest.suite' , ' hdfs_repository/10_basic'
157154}
158155
159- boolean secureFixtureSupported = false
156+ boolean secureFixtureSupported = false ;
160157if (fixtureSupported) {
161- secureFixtureSupported = project. rootProject. vagrantSupported
158+ // Only do secure fixture support if the regular fixture is supported,
159+ // and if vagrant is installed. The ignoreExitValue on exec only matters
160+ // in cases where the command can be found and successfully started. In
161+ // situations where the vagrant command isn't able to be started at all
162+ // (it's not installed) then Gradle still throws ExecException.
163+ ByteArrayOutputStream pipe = new ByteArrayOutputStream ()
164+ try {
165+ ExecResult runResult = exec {
166+ commandLine ' vagrant' , ' --version'
167+ standardOutput pipe
168+ ignoreExitValue true
169+ }
170+ String output = pipe. toString(). trim()
171+ if (runResult. exitValue == 0 ) {
172+ secureFixtureSupported = (output ==~ / Vagrant 1\. (8\. [6-9]|9\. [0-9])+/ )
173+ } else {
174+ logger. warn(" Could not read installed vagrant version:\n " + output)
175+ }
176+ } catch (org.gradle.process.internal.ExecException e) {
177+ logger. warn(" Could not find vagrant: " + e. message)
178+ // Swallow error. Vagrant isn't installed. Leave secure fixture support off.
179+ }
162180}
163181
164182// Create a Integration Test suite just for security based tests
165- // This must execute before the afterEvaluate block from integTestSecure
166- project. afterEvaluate {
167- Path elasticsearchKT = project(' :test:fixtures:krb5kdc-fixture' ). buildDir. toPath(). resolve(" keytabs" ). resolve(" elasticsearch.keytab" ). toAbsolutePath()
168- Path krb5conf = project(' :test:fixtures:krb5kdc-fixture' ). buildDir. toPath(). resolve(" conf" ). resolve(" krb5.conf" ). toAbsolutePath()
169-
170- project. integTestSecureCluster. dependsOn(project. bundlePlugin)
171- project. integTestSecure. clusterConfig. plugin(project. path)
172- project. integTestSecure. clusterConfig. extraConfigFile(" repository-hdfs/krb5.keytab" , " ${ elasticsearchKT} " )
173- project. integTestSecure. clusterConfig. jvmArgs = " -Xms" + System . getProperty(' tests.heap.size' , ' 512m' ) +
174- " " + " -Xmx" + System . getProperty(' tests.heap.size' , ' 512m' ) +
175- " " + " -Djava.security.krb5.conf=${ krb5conf} " +
176- " " + System . getProperty(' tests.jvm.argline' , ' ' )
177- }
183+ if (secureFixtureSupported && false ) { // This fails due to a vagrant configuration issue - remove the false check to re-enable
184+ // This must execute before the afterEvaluate block from integTestSecure
185+ project. afterEvaluate {
186+ Path elasticsearchKT = project(' :test:fixtures:krb5kdc-fixture' ). buildDir. toPath(). resolve(" keytabs" ). resolve(" elasticsearch.keytab" ). toAbsolutePath()
187+ Path krb5conf = project(' :test:fixtures:krb5kdc-fixture' ). buildDir. toPath(). resolve(" conf" ). resolve(" krb5.conf" ). toAbsolutePath()
188+
189+ project. integTestSecureCluster. dependsOn(project. bundlePlugin)
190+ project. integTestSecure. clusterConfig. plugin(project. path)
191+ project. integTestSecure. clusterConfig. extraConfigFile(" repository-hdfs/krb5.keytab" , " ${ elasticsearchKT} " )
192+ project. integTestSecure. clusterConfig. jvmArgs = " -Xms" + System . getProperty(' tests.heap.size' , ' 512m' ) +
193+ " " + " -Xmx" + System . getProperty(' tests.heap.size' , ' 512m' ) +
194+ " " + " -Djava.security.krb5.conf=${ krb5conf} " +
195+ " " + System . getProperty(' tests.jvm.argline' , ' ' )
196+ }
178197
179- RestIntegTestTask integTestSecure = project. tasks. create(' integTestSecure' , RestIntegTestTask . class) {
180- description = " Runs rest tests against an elasticsearch cluster with HDFS secured by MIT Kerberos."
181- }
198+ RestIntegTestTask integTestSecure = project. tasks. create(' integTestSecure' , RestIntegTestTask . class) {
199+ description = " Runs rest tests against an elasticsearch cluster with HDFS secured by MIT Kerberos."
200+ }
182201
183- if (secureFixtureSupported) {
202+ integTestSecure . mustRunAfter(project . integTest)
184203 project. check. dependsOn(integTestSecure)
185204
186205 // Fixture dependencies
187206 integTestSecureCluster. dependsOn secureHdfsFixture, krb5kdcFixture
188207 integTestSecureRunner. systemProperty ' tests.rest.suite' , ' secure_hdfs_repository'
189208} else {
190- integTestSecure . enabled = false
209+ logger . warn( " secured hdfsFixture is unsupported, please install Vagrant 1.8.6+ to enable " )
191210}
192211
193212thirdPartyAudit. excludes = [
0 commit comments