]>
Commit | Line | Data |
---|---|---|
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 |
21 | sudo() { |
22 | "$(type -P sudo)" -E "$@" | |
23 | } | |
24 | ||
11fdf7f2 TL |
25 | set -e |
26 | ||
27 | VM_SETUP_PATH=$(readlink -f ${BASH_SOURCE%/*}) | |
28 | ||
29 | UPGRADE=false | |
30 | INSTALL=false | |
f67539c2 | 31 | CONF="rocksdb,fio,flamegraph,tsocks,qemu,libiscsi,nvmecli,qat,spdk,refspdk" |
11fdf7f2 | 32 | |
f67539c2 TL |
33 | if [[ -e /etc/os-release ]]; then |
34 | source /etc/os-release | |
35 | fi | |
11fdf7f2 | 36 | |
f67539c2 TL |
37 | if [ $(uname -s) == "FreeBSD" ]; then |
38 | OSID="freebsd" | |
39 | OSVERSION=$(freebsd-version | cut -d. -f1) | |
40 | else | |
41 | OSID=$(source /etc/os-release && echo $ID) | |
42 | OSVERSION=$(source /etc/os-release && echo $VERSION_ID) | |
43 | fi | |
9f95a23c | 44 | |
f67539c2 TL |
45 | function 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 |
60 | vmsetupdir=$(readlink -f "$(dirname "$0")") |
61 | rootdir=$(readlink -f "$vmsetupdir/../../../") | |
11fdf7f2 | 62 | |
f67539c2 | 63 | managers=("$vmsetupdir/pkgdep/"*) |
9f95a23c | 64 | # Get package manager # |
f67539c2 TL |
65 | if hash dnf &> /dev/null; then |
66 | source "$vmsetupdir/pkgdep/dnf" | |
67 | elif hash yum &> /dev/null; then | |
68 | source "$vmsetupdir/pkgdep/yum" | |
69 | elif hash apt-get &> /dev/null; then | |
70 | source "$vmsetupdir/pkgdep/apt-get" | |
71 | elif hash pacman &> /dev/null; then | |
72 | source "$vmsetupdir/pkgdep/pacman" | |
73 | elif hash pkg &> /dev/null; then | |
74 | source "$vmsetupdir/pkgdep/pkg" | |
75 | elif hash swupd &> /dev/null; then | |
76 | source "$vmsetupdir/pkgdep/swupd" | |
9f95a23c | 77 | else |
f67539c2 | 78 | package_manager="undefined" |
9f95a23c TL |
79 | fi |
80 | ||
81 | # Parse input arguments # | |
f67539c2 TL |
82 | while 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 |
111 | done |
112 | ||
f67539c2 TL |
113 | if [[ "$package_manager" == "undefined" ]]; then |
114 | echo "Supported package manager not found. Script supports:" | |
115 | printf ' * %s\n' "${managers[@]##*/}" | |
116 | exit 1 | |
11fdf7f2 TL |
117 | fi |
118 | ||
f67539c2 TL |
119 | if [ -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 |
126 | fi |
127 | ||
f67539c2 TL |
128 | if $UPGRADE; then |
129 | upgrade | |
11fdf7f2 | 130 | fi |
11fdf7f2 TL |
131 | |
132 | if $INSTALL; then | |
f67539c2 TL |
133 | sudo "$rootdir/scripts/pkgdep.sh" --all |
134 | pre_install | |
135 | install "${packages[@]}" | |
11fdf7f2 TL |
136 | fi |
137 | ||
f67539c2 | 138 | source "$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. | |
146 | if [ ! -e ~/autorun-spdk.conf ]; then | |
147 | cat > ~/autorun-spdk.conf << EOF | |
148 | # assign a value of 1 to all of the pertinent tests | |
11fdf7f2 | 149 | SPDK_RUN_VALGRIND=1 |
9f95a23c TL |
150 | SPDK_TEST_CRYPTO=1 |
151 | SPDK_RUN_FUNCTIONAL_TEST=1 | |
f67539c2 | 152 | SPDK_TEST_AUTOBUILD=1 |
11fdf7f2 TL |
153 | SPDK_TEST_UNITTEST=1 |
154 | SPDK_TEST_ISCSI=1 | |
155 | SPDK_TEST_ISCSI_INITIATOR=1 | |
11fdf7f2 | 156 | SPDK_TEST_NVME=1 |
9f95a23c | 157 | SPDK_TEST_NVME_CLI=1 |
11fdf7f2 TL |
158 | SPDK_TEST_NVMF=1 |
159 | SPDK_TEST_RBD=1 | |
11fdf7f2 | 160 | SPDK_TEST_BLOCKDEV=1 |
11fdf7f2 TL |
161 | SPDK_TEST_BLOBFS=1 |
162 | SPDK_TEST_PMDK=1 | |
163 | SPDK_TEST_LVOL=1 | |
9f95a23c | 164 | SPDK_TEST_JSON=1 |
11fdf7f2 TL |
165 | SPDK_RUN_ASAN=1 |
166 | SPDK_RUN_UBSAN=1 | |
9f95a23c TL |
167 | # doesn't work on vm |
168 | SPDK_TEST_IOAT=0 | |
169 | # requires some extra configuration. see TEST_ENV_SETUP_README | |
170 | SPDK_TEST_VHOST=0 | |
171 | SPDK_TEST_VHOST_INIT=0 | |
172 | # Not configured here | |
173 | SPDK_RUN_INSTALLED_DPDK=0 | |
174 | ||
11fdf7f2 TL |
175 | EOF |
176 | fi |