From 6695ac27970dd33e094dcae7f2d3caa39ae0f408 Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Wed, 26 Sep 2018 10:11:36 -0700 Subject: [PATCH] scripts/vagrant: Enable test machine deployment for fedora Allow the option to run vm_setup.sh during provisioning on a fedora system. This is one step closer to fully automating the setup of a build pool test machine. Change-Id: Ia3965b31e0a9217d176ffe3c165b8eb6b3ccad13 Signed-off-by: Seth Howell Reviewed-on: https://review.gerrithub.io/426946 Chandler-Test-Pool: SPDK Automated Test System Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- scripts/vagrant/Vagrantfile | 17 +++++++++++++++++ scripts/vagrant/create_vbox.sh | 15 +++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/scripts/vagrant/Vagrantfile b/scripts/vagrant/Vagrantfile index 81c80ea5f..e11468fb2 100644 --- a/scripts/vagrant/Vagrantfile +++ b/scripts/vagrant/Vagrantfile @@ -47,6 +47,14 @@ Vagrant.configure(2) do |config| config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig" end + # Copy the tsocks configuration file for use when installing some spdk test pool dependencies + if File.file?("/etc/tsocks.conf") + config.vm.provision "file", source: "/etc/tsocks.conf", destination: "tsocks.conf" + config.vm.provision "shell", inline: "sudo mv tsocks.conf /etc/tsocks.conf" + config.vm.provision "shell", inline: "sudo chown root:wheel /etc/tsocks.conf" + config.vm.provision "shell", inline: "sudo chmod 644 /etc/tsocks.conf" + end + # vagrant-cachier caches apt/yum etc to speed subsequent # vagrant up # to enable, run @@ -124,6 +132,15 @@ Vagrant.configure(2) do |config| config.vm.synced_folder "#{spdk_dir}", "/home/vagrant/spdk_repo/spdk", type: "rsync", rsync__auto: false end + # provision the vm with all of the necessary spdk dependencies for running the autorun.sh tests + if ENV['DEPLOY_TEST_VM'] == "1" && spdk_dir != "none" + config.vm.provision "shell" do |setup| + setup.path = "#{spdk_dir}/test/common/config/vm_setup.sh" + setup.privileged = false + setup.args = ["-u", "-i"] + end + end + if vhost_host_dir != "none" config.vm.synced_folder "#{vhost_host_dir}", "#{vhost_vm_dir}", type: "rsync", rsync__auto: false config.vm.provision "shell", inline: "sudo mkdir -p /root/.ssh" diff --git a/scripts/vagrant/create_vbox.sh b/scripts/vagrant/create_vbox.sh index 048094a96..db4ca9c1f 100755 --- a/scripts/vagrant/create_vbox.sh +++ b/scripts/vagrant/create_vbox.sh @@ -15,7 +15,7 @@ SPDK_DIR="$( cd "${DIR}/../../" && pwd )" # The command line help display_help() { echo - echo " Usage: ${0##*/} [-n ] [-s ] [-x ] [-hvrl] " + echo " Usage: ${0##*/} [-n ] [-s ] [-x ] [-hvrld] " echo echo " distro = " echo @@ -28,6 +28,7 @@ display_help() { echo " --vhost-vm-dir= directory where to put vhost dependencies in VM" echo " -r dry-run" echo " -l use a local copy of spdk, don't try to rsync from the host." + echo " -d deploy a test vm by provisioning all prerequisites for spdk autotest" echo " -h help" echo " -v verbose" echo @@ -48,12 +49,13 @@ VERBOSE=0 HELP=0 COPY_SPDK_DIR=1 DRY_RUN=0 +DEPLOY_TEST_VM=0 SPDK_VAGRANT_DISTRO="distro" SPDK_VAGRANT_VMCPU=4 SPDK_VAGRANT_VMRAM=4096 OPTIND=1 -while getopts ":n:s:x:p:vrlh-:" opt; do +while getopts ":n:s:x:p:vrldh-:" opt; do case "${opt}" in -) case "${OPTARG}" in @@ -89,6 +91,9 @@ while getopts ":n:s:x:p:vrlh-:" opt; do l) COPY_SPDK_DIR=0 ;; + d) + DEPLOY_TEST_VM=1 + ;; *) echo " Invalid argument: -$OPTARG" >&2 echo " Try: \"$0 -h\"" >&2 @@ -127,6 +132,11 @@ case "$SPDK_VAGRANT_DISTRO" in ;; esac +if ! echo "$SPDK_VAGRANT_DISTRO" | grep -q fedora && [ $DEPLOY_TEST_VM -eq 1 ]; then + echo "Warning: Test machine deployment is only available on fedora distros. Disabling it for this build" + DEPLOY_TEST_VM=0 +fi + if [ ${VERBOSE} = 1 ]; then echo echo DIR=${DIR} @@ -148,6 +158,7 @@ export SPDK_VAGRANT_VMCPU export SPDK_VAGRANT_VMRAM export SPDK_DIR export COPY_SPDK_DIR +export DEPLOY_TEST_VM if [ -n "$PROVIDER" ]; then provider="--provider=${PROVIDER}"