]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/test/common/config/vm_setup.sh
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / test / common / config / vm_setup.sh
CommitLineData
11fdf7f2
TL
1#!/usr/bin/env bash
2
3# Virtual Machine environment requirements:
4# 8 GiB of RAM (for DPDK)
5# enable intel_kvm on your host machine
6
7# The purpose of this script is to provide a simple procedure for spinning up a new
8# virtual test environment capable of running our whole test suite. This script, when
9f95a23c
TL
9# applied to a fresh install of fedora 26 or ubuntu 16,18 server will install all of the
10# necessary dependencies to run almost the complete test suite. The main exception being VHost.
11# Vhost requires the configuration of a second virtual machine. instructions for how to configure
11fdf7f2
TL
12# that vm are included in the file TEST_ENV_SETUP_README inside this repository
13
14# it is important to enable nesting for vms in kernel command line of your machine for the vhost tests.
15# in /etc/default/grub
16# append the following to the GRUB_CMDLINE_LINUX line
17# intel_iommu=on kvm-intel.nested=1
18
19# We have made a lot of progress with removing hardcoded paths from the tests,
20
f67539c2
TL
21sudo() {
22 "$(type -P sudo)" -E "$@"
23}
24
11fdf7f2
TL
25set -e
26
27VM_SETUP_PATH=$(readlink -f ${BASH_SOURCE%/*})
28
29UPGRADE=false
30INSTALL=false
f67539c2 31CONF="rocksdb,fio,flamegraph,tsocks,qemu,libiscsi,nvmecli,qat,spdk,refspdk"
11fdf7f2 32
f67539c2
TL
33if [[ -e /etc/os-release ]]; then
34 source /etc/os-release
35fi
11fdf7f2 36
f67539c2
TL
37if [ $(uname -s) == "FreeBSD" ]; then
38 OSID="freebsd"
39 OSVERSION=$(freebsd-version | cut -d. -f1)
40else
41 OSID=$(source /etc/os-release && echo $ID)
42 OSVERSION=$(source /etc/os-release && echo $VERSION_ID)
43fi
9f95a23c 44
f67539c2
TL
45function usage() {
46 echo "This script is intended to automate the environment setup for a linux virtual machine."
47 echo "Please run this script as your regular user. The script will make calls to sudo as needed."
48 echo ""
49 echo "./vm_setup.sh"
50 echo " -h --help"
51 echo " -u --upgrade Run $package_manager upgrade"
52 echo " -i --install-deps Install $package_manager based dependencies"
53 echo " -t --test-conf List of test configurations to enable (${CONF})"
54 echo " -c --conf-path Path to configuration file"
55 echo " -d --dir-git Path to where git sources should be saved"
56 echo " -s --disable-tsocks Disable use of tsocks"
57 exit 0
9f95a23c
TL
58}
59
f67539c2
TL
60vmsetupdir=$(readlink -f "$(dirname "$0")")
61rootdir=$(readlink -f "$vmsetupdir/../../../")
11fdf7f2 62
f67539c2 63managers=("$vmsetupdir/pkgdep/"*)
9f95a23c 64# Get package manager #
f67539c2
TL
65if hash dnf &> /dev/null; then
66 source "$vmsetupdir/pkgdep/dnf"
67elif hash yum &> /dev/null; then
68 source "$vmsetupdir/pkgdep/yum"
69elif hash apt-get &> /dev/null; then
70 source "$vmsetupdir/pkgdep/apt-get"
71elif hash pacman &> /dev/null; then
72 source "$vmsetupdir/pkgdep/pacman"
73elif hash pkg &> /dev/null; then
74 source "$vmsetupdir/pkgdep/pkg"
75elif hash swupd &> /dev/null; then
76 source "$vmsetupdir/pkgdep/swupd"
9f95a23c 77else
f67539c2 78 package_manager="undefined"
9f95a23c
TL
79fi
80
81# Parse input arguments #
f67539c2
TL
82while getopts 'd:siuht:c:-:' optchar; do
83 case "$optchar" in
84 -)
85 case "$OPTARG" in
86 help) usage ;;
87 upgrade) UPGRADE=true ;;
88 install-deps) INSTALL=true ;;
89 test-conf=*) CONF="${OPTARG#*=}" ;;
90 conf-path=*) CONF_PATH="${OPTARG#*=}" ;;
91 dir-git=*) GIT_REPOS="${OPTARG#*=}" ;;
92 disable-tsocks) NO_TSOCKS=true ;;
93 *)
94 echo "Invalid argument '$OPTARG'"
95 usage
96 ;;
97 esac
98 ;;
99 h) usage ;;
100 u) UPGRADE=true ;;
101 i) INSTALL=true ;;
102 t) CONF="$OPTARG" ;;
103 c) CONF_PATH="$OPTARG" ;;
104 d) GIT_REPOS="$OPTARG" ;;
105 s) NO_TSOCKS=true ;;
106 *)
107 echo "Invalid argument '$OPTARG'"
108 usage
109 ;;
110 esac
11fdf7f2
TL
111done
112
f67539c2
TL
113if [[ "$package_manager" == "undefined" ]]; then
114 echo "Supported package manager not found. Script supports:"
115 printf ' * %s\n' "${managers[@]##*/}"
116 exit 1
11fdf7f2
TL
117fi
118
f67539c2
TL
119if [ -n "$CONF_PATH" ]; then
120 if [ ! -f "$CONF_PATH" ]; then
121 echo Configuration file does not exist: "$CONF_PATH"
122 exit 1
123 else
124 source "$CONF_PATH"
125 fi
11fdf7f2
TL
126fi
127
f67539c2
TL
128if $UPGRADE; then
129 upgrade
11fdf7f2 130fi
11fdf7f2
TL
131
132if $INSTALL; then
f67539c2
TL
133 sudo "$rootdir/scripts/pkgdep.sh" --all
134 pre_install
135 install "${packages[@]}"
11fdf7f2
TL
136fi
137
f67539c2 138source "$vmsetupdir/pkgdep/git"
11fdf7f2 139
11fdf7f2
TL
140# create autorun-spdk.conf in home folder. This is sourced by the autotest_common.sh file.
141# By setting any one of the values below to 0, you can skip that specific test. If you are
142# using your autotest platform to do sanity checks before uploading to the build pool, it is
143# probably best to only run the tests that you believe your changes have modified along with
144# Scanbuild and check format. This is because running the whole suite of tests in series can
145# take ~40 minutes to complete.
146if [ ! -e ~/autorun-spdk.conf ]; then
147 cat > ~/autorun-spdk.conf << EOF
148# assign a value of 1 to all of the pertinent tests
11fdf7f2 149SPDK_RUN_VALGRIND=1
9f95a23c
TL
150SPDK_TEST_CRYPTO=1
151SPDK_RUN_FUNCTIONAL_TEST=1
f67539c2 152SPDK_TEST_AUTOBUILD=1
11fdf7f2
TL
153SPDK_TEST_UNITTEST=1
154SPDK_TEST_ISCSI=1
155SPDK_TEST_ISCSI_INITIATOR=1
11fdf7f2 156SPDK_TEST_NVME=1
9f95a23c 157SPDK_TEST_NVME_CLI=1
11fdf7f2
TL
158SPDK_TEST_NVMF=1
159SPDK_TEST_RBD=1
11fdf7f2 160SPDK_TEST_BLOCKDEV=1
11fdf7f2
TL
161SPDK_TEST_BLOBFS=1
162SPDK_TEST_PMDK=1
163SPDK_TEST_LVOL=1
9f95a23c 164SPDK_TEST_JSON=1
11fdf7f2
TL
165SPDK_RUN_ASAN=1
166SPDK_RUN_UBSAN=1
9f95a23c
TL
167# doesn't work on vm
168SPDK_TEST_IOAT=0
169# requires some extra configuration. see TEST_ENV_SETUP_README
170SPDK_TEST_VHOST=0
171SPDK_TEST_VHOST_INIT=0
172# Not configured here
173SPDK_RUN_INSTALLED_DPDK=0
174
11fdf7f2
TL
175EOF
176fi