From 2cccc4c78afc4e66eb6e634ca8008443b9292c9a Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Mon, 7 Nov 2016 11:25:23 +0100 Subject: [PATCH 1/2] Add VirtualBox version check This commit ensure that VirtualBox is available in version 5.1+ in the system before running packaging tests. It also check for Vagrant version is now greater than 1.8.6. --- qa/vagrant/build.gradle | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/qa/vagrant/build.gradle b/qa/vagrant/build.gradle index f263adbadc8e3..27dd5cef2b1f6 100644 --- a/qa/vagrant/build.gradle +++ b/qa/vagrant/build.gradle @@ -208,9 +208,19 @@ task checkVagrantVersion(type: Exec) { standardOutput = new ByteArrayOutputStream() doLast { String version = standardOutput.toString().trim() - if ((version ==~ /Vagrant 1\.[789]\..+/) == false) { - throw new InvalidUserDataException( - "Illegal version of vagrant [${version}]. Need [Vagrant 1.7+]") + if ((version ==~ /Vagrant 1\.(8\.[6-9]|9\.[0-9])+/) == false) { + throw new InvalidUserDataException("Illegal version of vagrant [${version}]. Need [Vagrant 1.8.6+]") + } + } +} + +task checkVirtualBoxVersion(type: Exec) { + commandLine 'vboxmanage', '--version' + standardOutput = new ByteArrayOutputStream() + doLast { + String version = standardOutput.toString().trim() + if ((version ==~ /5\.[1-9]\..+/) == false) { + throw new InvalidUserDataException("Illegal version of virtualbox [${version}]. Need [5.1+]") } } } @@ -247,7 +257,7 @@ for (String box : availableBoxes) { Task update = tasks.create("vagrant${boxTask}#update", VagrantCommandTask) { boxName box args 'box', 'update', box - dependsOn checkVagrantVersion + dependsOn checkVagrantVersion, checkVirtualBoxVersion } Task up = tasks.create("vagrant${boxTask}#up", VagrantCommandTask) { From 571cdf5b6ff4f611e243cfd47f3150346b02b740 Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Wed, 9 Nov 2016 09:50:17 +0100 Subject: [PATCH 2/2] Update after Jason comment --- qa/vagrant/build.gradle | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/qa/vagrant/build.gradle b/qa/vagrant/build.gradle index 27dd5cef2b1f6..7bd9861a9d164 100644 --- a/qa/vagrant/build.gradle +++ b/qa/vagrant/build.gradle @@ -219,8 +219,15 @@ task checkVirtualBoxVersion(type: Exec) { standardOutput = new ByteArrayOutputStream() doLast { String version = standardOutput.toString().trim() - if ((version ==~ /5\.[1-9]\..+/) == false) { - throw new InvalidUserDataException("Illegal version of virtualbox [${version}]. Need [5.1+]") + try { + String[] versions = version.split('\\.') + int major = Integer.parseInt(versions[0]) + int minor = Integer.parseInt(versions[1]) + if ((major < 5) || (major == 5 && minor < 1)) { + throw new InvalidUserDataException("Illegal version of virtualbox [${version}]. Need [5.1+]") + } + } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) { + throw new InvalidUserDataException("Unable to parse version of virtualbox [${version}]. Required [5.1+]", e) } } }