From 025eebecefa45c8a3e6eb33fe382dd701ac9c28a Mon Sep 17 00:00:00 2001 From: Raghavendra Talur Date: Mon, 18 Jan 2016 14:44:46 +0530 Subject: 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 Reviewed-on: http://review.gluster.org/13252 Smoke: Gluster Build System CentOS-regression: Gluster Build System NetBSD-regression: NetBSD Build System --- run-tests-in-vagrant.sh | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'run-tests-in-vagrant.sh') 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 -- cgit