summaryrefslogtreecommitdiffstats
path: root/run-tests-in-vagrant.sh
diff options
context:
space:
mode:
authorRaghavendra Talur <rtalur@redhat.com>2016-01-18 14:44:46 +0530
committerRaghavendra Talur <rtalur@redhat.com>2016-02-25 10:24:18 -0800
commit025eebecefa45c8a3e6eb33fe382dd701ac9c28a (patch)
treefac20baa692865b7bd2c22feda8abb6e969eabd9 /run-tests-in-vagrant.sh
parente991d14a3a2aaf19218cbb5993a94de263769cb4 (diff)
vagrant-test: Provide option to autostart vm on host boot
If the machines are being used as test machines for active development, user might want to have them autostart on host boot. You can use -a as short option or --autostart as longoption with run-tests-in-vagrant.sh to set the autostart flag on the VM. The autostart value is set to off by default. It is done using virsh until vagrant-libvirt supports it in the API. Change-Id: I5b53ea6d850c991d548dbac0bb8fadd528cabf41 BUG: 1291537 Signed-off-by: Raghavendra Talur <rtalur@redhat.com> Reviewed-on: http://review.gluster.org/13252 Smoke: Gluster Build System <jenkins@build.gluster.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Diffstat (limited to 'run-tests-in-vagrant.sh')
-rwxr-xr-xrun-tests-in-vagrant.sh28
1 files changed, 26 insertions, 2 deletions
diff --git a/run-tests-in-vagrant.sh b/run-tests-in-vagrant.sh
index f66fae0ac3d..aedf1ca0a18 100755
--- a/run-tests-in-vagrant.sh
+++ b/run-tests-in-vagrant.sh
@@ -1,11 +1,29 @@
#!/bin/bash
###############################################################################
-# TODO: Provide an option parser; may be getopts. #
# TODO: Allow subset of tests to be executed when VM starts. #
# TODO: Provide option to destroy the VM. #
###############################################################################
+ORIGIN_DIR=$PWD
+autostart="no"
+
+function parse_args () {
+ args=`getopt \
+ --options a \
+ --long autostart \
+ -n 'run-tests-in-vagrant.sh' \
+ -- "$@"`
+ eval set -- "$args"
+ while true; do
+ case "$1" in
+ -a|--autostart) autostart="yes"; shift ;;
+ --) shift ; break ;;
+ *) echo "Internal error!" ; exit 1;;
+ esac
+ done
+}
+
function force_location()
{
current_dir=$(dirname $0);
@@ -51,7 +69,7 @@ function ansible_check()
fi
}
-ORIGIN_DIR=$PWD
+parse_args "$@"
echo "Checking current dir...."
force_location
@@ -96,6 +114,12 @@ echo
echo
+if [ "x$autostart" == "xyes" ] ; then
+ echo "autostart option enabled, calling virsh autostart"
+ virsh autostart ${BRANCHNAME}_vagrant-testVM
+ echo
+ echo
+fi
echo "Copying source code from host machine to VM"
cd tests/vagrant/$BRANCHNAME