2018-10-01 18:47:23 +00:00
|
|
|
#!/usr/bin/env bash
|
2017-11-15 22:15:06 +00:00
|
|
|
|
|
|
|
# Virtual Machine environment requirements:
|
|
|
|
# 8 GiB of RAM (for DPDK)
|
|
|
|
# enable intel_kvm on your host machine
|
|
|
|
|
|
|
|
# The purpose of this script is to provide a simple procedure for spinning up a new
|
|
|
|
# virtual test environment capable of running our whole test suite. This script, when
|
2018-12-04 19:27:57 +00:00
|
|
|
# applied to a fresh install of fedora 26 or ubuntu 16,18 server will install all of the
|
|
|
|
# necessary dependencies to run almost the complete test suite. The main exception being VHost.
|
|
|
|
# Vhost requires the configuration of a second virtual machine. instructions for how to configure
|
2017-11-15 22:15:06 +00:00
|
|
|
# that vm are included in the file TEST_ENV_SETUP_README inside this repository
|
|
|
|
|
|
|
|
# it is important to enable nesting for vms in kernel command line of your machine for the vhost tests.
|
|
|
|
# in /etc/default/grub
|
|
|
|
# append the following to the GRUB_CMDLINE_LINUX line
|
|
|
|
# intel_iommu=on kvm-intel.nested=1
|
|
|
|
|
|
|
|
# We have made a lot of progress with removing hardcoded paths from the tests,
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2018-06-22 17:57:00 +00:00
|
|
|
VM_SETUP_PATH=$(readlink -f ${BASH_SOURCE%/*})
|
|
|
|
|
2018-06-26 20:47:41 +00:00
|
|
|
UPGRADE=false
|
|
|
|
INSTALL=false
|
2020-05-18 15:32:01 +00:00
|
|
|
CONF="rocksdb,fio,flamegraph,tsocks,qemu,vpp,libiscsi,nvmecli,qat,spdk,refspdk"
|
2020-05-14 14:08:15 +00:00
|
|
|
gcc_version=$(gcc -dumpversion) gcc_version=${gcc_version%%.*}
|
2018-06-26 20:47:41 +00:00
|
|
|
|
2020-05-18 15:20:37 +00:00
|
|
|
if [[ -e /etc/os-release ]]; then
|
|
|
|
source /etc/os-release
|
|
|
|
fi
|
|
|
|
|
2020-03-04 19:52:51 +00:00
|
|
|
if [ $(uname -s) == "FreeBSD" ]; then
|
2020-05-07 11:27:06 +00:00
|
|
|
OSID="freebsd"
|
|
|
|
OSVERSION=$(freebsd-version | cut -d. -f1)
|
|
|
|
PACKAGEMNG='pkg'
|
2020-03-04 19:52:51 +00:00
|
|
|
else
|
2020-05-07 11:27:06 +00:00
|
|
|
OSID=$(source /etc/os-release && echo $ID)
|
|
|
|
OSVERSION=$(source /etc/os-release && echo $VERSION_ID)
|
|
|
|
PACKAGEMNG='undefined'
|
2020-03-04 19:52:51 +00:00
|
|
|
fi
|
2018-12-04 19:27:57 +00:00
|
|
|
|
2020-05-07 11:27:06 +00:00
|
|
|
function usage() {
|
|
|
|
echo "This script is intended to automate the environment setup for a linux virtual machine."
|
|
|
|
echo "Please run this script as your regular user. The script will make calls to sudo as needed."
|
|
|
|
echo ""
|
|
|
|
echo "./vm_setup.sh"
|
|
|
|
echo " -h --help"
|
|
|
|
echo " -u --upgrade Run $PACKAGEMNG upgrade"
|
|
|
|
echo " -i --install-deps Install $PACKAGEMNG based dependencies"
|
|
|
|
echo " -t --test-conf List of test configurations to enable (${CONF})"
|
|
|
|
echo " -c --conf-path Path to configuration file"
|
2020-06-02 08:48:47 +00:00
|
|
|
echo " -d --dir-git Path to where git sources should be saved"
|
2020-05-07 11:27:06 +00:00
|
|
|
exit 0
|
2018-06-26 20:47:41 +00:00
|
|
|
}
|
|
|
|
|
2020-05-18 15:20:37 +00:00
|
|
|
vmsetupdir=$(readlink -f "$(dirname "$0")")
|
|
|
|
rootdir=$(readlink -f "$vmsetupdir/../../../")
|
|
|
|
|
|
|
|
managers=("$vmsetupdir/pkgdep/"*)
|
2018-12-04 19:27:57 +00:00
|
|
|
# Get package manager #
|
2020-05-07 11:27:06 +00:00
|
|
|
if hash yum &> /dev/null; then
|
2020-05-18 15:20:37 +00:00
|
|
|
source "$vmsetupdir/pkgdep/yum"
|
2020-05-07 11:27:06 +00:00
|
|
|
elif hash dnf &> /dev/null; then
|
2020-05-18 15:20:37 +00:00
|
|
|
source "$vmsetupdir/pkgdep/dnf"
|
2020-05-07 11:27:06 +00:00
|
|
|
elif hash apt-get &> /dev/null; then
|
2020-05-18 15:20:37 +00:00
|
|
|
source "$vmsetupdir/pkgdep/apt-get"
|
2020-05-07 11:27:06 +00:00
|
|
|
elif hash pacman &> /dev/null; then
|
2020-05-18 15:20:37 +00:00
|
|
|
source "$vmsetupdir/pkgdep/pacman"
|
2020-05-07 11:27:06 +00:00
|
|
|
elif hash pkg &> /dev/null; then
|
2020-05-18 15:20:37 +00:00
|
|
|
source "$vmsetupdir/pkgdep/pkg"
|
2018-12-04 19:27:57 +00:00
|
|
|
else
|
2020-05-18 15:20:37 +00:00
|
|
|
echo "Supported package manager not found. Script supports:"
|
|
|
|
printf ' * %s\n' "${managers[@]##*/}"
|
2018-12-04 19:27:57 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Parse input arguments #
|
2020-06-02 08:48:47 +00:00
|
|
|
while getopts 'd:iuht:c:-:' optchar; do
|
2020-05-07 11:27:06 +00:00
|
|
|
case "$optchar" in
|
|
|
|
-)
|
|
|
|
case "$OPTARG" in
|
|
|
|
help) usage ;;
|
|
|
|
upgrade) UPGRADE=true ;;
|
|
|
|
install-deps) INSTALL=true ;;
|
|
|
|
test-conf=*) CONF="${OPTARG#*=}" ;;
|
|
|
|
conf-path=*) CONF_PATH="${OPTARG#*=}" ;;
|
2020-06-02 08:48:47 +00:00
|
|
|
dir-git=*) GIT_REPOS="${OPTARG#*=}" ;;
|
2020-05-07 11:27:06 +00:00
|
|
|
*)
|
|
|
|
echo "Invalid argument '$OPTARG'"
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
h) usage ;;
|
|
|
|
u) UPGRADE=true ;;
|
|
|
|
i) INSTALL=true ;;
|
|
|
|
t) CONF="$OPTARG" ;;
|
|
|
|
c) CONF_PATH="$OPTARG" ;;
|
2020-06-02 08:48:47 +00:00
|
|
|
d) GIT_REPOS="$OPTARG" ;;
|
2020-05-07 11:27:06 +00:00
|
|
|
*)
|
|
|
|
echo "Invalid argument '$OPTARG'"
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
2018-06-26 20:47:41 +00:00
|
|
|
done
|
|
|
|
|
2019-07-25 13:01:09 +00:00
|
|
|
if [ -n "$CONF_PATH" ]; then
|
2020-05-07 11:27:06 +00:00
|
|
|
if [ ! -f "$CONF_PATH" ]; then
|
|
|
|
echo Configuration file does not exist: "$CONF_PATH"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
source "$CONF_PATH"
|
|
|
|
fi
|
2018-06-22 17:57:00 +00:00
|
|
|
fi
|
|
|
|
|
2018-06-26 20:47:41 +00:00
|
|
|
if $UPGRADE; then
|
2020-05-18 15:20:37 +00:00
|
|
|
upgrade
|
2018-06-26 20:47:41 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if $INSTALL; then
|
2020-05-18 15:20:37 +00:00
|
|
|
sudo "$rootdir/scripts/pkgdep.sh" --all
|
|
|
|
pre_install
|
|
|
|
install "${packages[@]}"
|
2020-04-23 05:57:53 +00:00
|
|
|
fi
|
|
|
|
|
2020-05-18 15:28:25 +00:00
|
|
|
source "$vmsetupdir/pkgdep/git"
|
2020-04-02 10:19:17 +00:00
|
|
|
|
2017-11-15 22:15:06 +00:00
|
|
|
# create autorun-spdk.conf in home folder. This is sourced by the autotest_common.sh file.
|
|
|
|
# By setting any one of the values below to 0, you can skip that specific test. If you are
|
|
|
|
# using your autotest platform to do sanity checks before uploading to the build pool, it is
|
|
|
|
# probably best to only run the tests that you believe your changes have modified along with
|
|
|
|
# Scanbuild and check format. This is because running the whole suite of tests in series can
|
|
|
|
# take ~40 minutes to complete.
|
2018-04-19 23:45:58 +00:00
|
|
|
if [ ! -e ~/autorun-spdk.conf ]; then
|
|
|
|
cat > ~/autorun-spdk.conf << EOF
|
2017-11-15 22:15:06 +00:00
|
|
|
# assign a value of 1 to all of the pertinent tests
|
|
|
|
SPDK_RUN_VALGRIND=1
|
2018-10-25 18:30:19 +00:00
|
|
|
SPDK_TEST_CRYPTO=1
|
2019-01-28 12:21:57 +00:00
|
|
|
SPDK_RUN_FUNCTIONAL_TEST=1
|
2019-12-19 15:57:30 +00:00
|
|
|
SPDK_TEST_AUTOBUILD=1
|
2017-11-15 22:15:06 +00:00
|
|
|
SPDK_TEST_UNITTEST=1
|
|
|
|
SPDK_TEST_ISCSI=1
|
2018-04-09 18:21:44 +00:00
|
|
|
SPDK_TEST_ISCSI_INITIATOR=1
|
2017-11-15 22:15:06 +00:00
|
|
|
SPDK_TEST_NVME=1
|
2018-10-25 18:30:19 +00:00
|
|
|
SPDK_TEST_NVME_CLI=1
|
2017-11-15 22:15:06 +00:00
|
|
|
SPDK_TEST_NVMF=1
|
|
|
|
SPDK_TEST_RBD=1
|
|
|
|
SPDK_TEST_BLOCKDEV=1
|
|
|
|
SPDK_TEST_BLOBFS=1
|
2018-04-03 23:07:39 +00:00
|
|
|
SPDK_TEST_PMDK=1
|
2018-04-09 18:21:44 +00:00
|
|
|
SPDK_TEST_LVOL=1
|
2018-10-25 18:30:19 +00:00
|
|
|
SPDK_TEST_JSON=1
|
2017-11-15 22:15:06 +00:00
|
|
|
SPDK_RUN_ASAN=1
|
|
|
|
SPDK_RUN_UBSAN=1
|
2018-10-25 18:30:19 +00:00
|
|
|
# doesn't work on vm
|
|
|
|
SPDK_TEST_IOAT=0
|
|
|
|
# requires some extra configuration. see TEST_ENV_SETUP_README
|
|
|
|
SPDK_TEST_VHOST=0
|
|
|
|
SPDK_TEST_VHOST_INIT=0
|
|
|
|
# Not configured here
|
|
|
|
SPDK_RUN_INSTALLED_DPDK=0
|
|
|
|
|
2017-11-15 22:15:06 +00:00
|
|
|
EOF
|
2018-04-19 23:45:58 +00:00
|
|
|
fi
|