Skip to content

Commit b9e2a1f

Browse files
committed
Revert "Sense for VirtualBox and $HOME when deciding to turn on vagrant testing. (#24636)"
This reverts commit 4ed0abe.
1 parent 0d8216d commit b9e2a1f

File tree

5 files changed

+82
-153
lines changed

5 files changed

+82
-153
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantSupportPlugin.groovy

Lines changed: 0 additions & 127 deletions
This file was deleted.

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,43 @@ class VagrantTestPlugin implements Plugin<Project> {
227227
vagrantSetUpTask.dependsOn copyBatsTests, copyBatsUtils, copyBatsArchives, createVersionFile, createUpgradeFromFile
228228
}
229229

230+
private static void createCheckVagrantVersionTask(Project project) {
231+
project.tasks.create('vagrantCheckVersion', Exec) {
232+
description 'Check the Vagrant version'
233+
group 'Verification'
234+
commandLine 'vagrant', '--version'
235+
standardOutput = new ByteArrayOutputStream()
236+
doLast {
237+
String version = standardOutput.toString().trim()
238+
if ((version ==~ /Vagrant 1\.(8\.[6-9]|9\.[0-9])+/) == false) {
239+
throw new InvalidUserDataException("Illegal version of vagrant [${version}]. Need [Vagrant 1.8.6+]")
240+
}
241+
}
242+
}
243+
}
244+
245+
private static void createCheckVirtualBoxVersionTask(Project project) {
246+
project.tasks.create('virtualboxCheckVersion', Exec) {
247+
description 'Check the Virtualbox version'
248+
group 'Verification'
249+
commandLine 'vboxmanage', '--version'
250+
standardOutput = new ByteArrayOutputStream()
251+
doLast {
252+
String version = standardOutput.toString().trim()
253+
try {
254+
String[] versions = version.split('\\.')
255+
int major = Integer.parseInt(versions[0])
256+
int minor = Integer.parseInt(versions[1])
257+
if ((major < 5) || (major == 5 && minor < 1)) {
258+
throw new InvalidUserDataException("Illegal version of virtualbox [${version}]. Need [5.1+]")
259+
}
260+
} catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
261+
throw new InvalidUserDataException("Unable to parse version of virtualbox [${version}]. Required [5.1+]", e)
262+
}
263+
}
264+
}
265+
}
266+
230267
private static void createPackagingTestTask(Project project) {
231268
project.tasks.create('packagingTest') {
232269
group 'Verification'
@@ -254,6 +291,8 @@ class VagrantTestPlugin implements Plugin<Project> {
254291
createCleanTask(project)
255292
createStopTask(project)
256293
createSmokeTestTask(project)
294+
createCheckVagrantVersionTask(project)
295+
createCheckVirtualBoxVersionTask(project)
257296
createPrepareVagrantTestEnvTask(project)
258297
createPackagingTestTask(project)
259298
createPlatformTestTask(project)

buildSrc/src/main/resources/META-INF/gradle-plugins/elasticsearch.vagrantsupport.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

plugins/repository-hdfs/build.gradle

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ esplugin {
2929
classname 'org.elasticsearch.repositories.hdfs.HdfsPlugin'
3030
}
3131

32-
apply plugin: 'elasticsearch.vagrantsupport'
33-
3432
versions << [
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

9188
task 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;
132129
if (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;
160157
if (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

193212
thirdPartyAudit.excludes = [

qa/vagrant/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
* under the License.
1818
*/
1919

20-
apply plugin: 'elasticsearch.vagrantsupport'
2120
apply plugin: 'elasticsearch.vagrant'
2221

2322
List<String> plugins = []

0 commit comments

Comments
 (0)