xref: /cloud-hypervisor/scripts/run_integration_tests_live_migration.sh (revision 2571e59438597f53aa4993cd70d6462fe1364ba7)
1#!/bin/bash
2set -x
3
4source $HOME/.cargo/env
5source $(dirname "$0")/test-util.sh
6
7export BUILD_TARGET=${BUILD_TARGET-x86_64-unknown-linux-gnu}
8
9WORKLOADS_DIR="$HOME/workloads"
10mkdir -p "$WORKLOADS_DIR"
11
12process_common_args "$@"
13
14# For now these values are default for kvm
15test_features=""
16
17if [ "$hypervisor" = "mshv" ] ;  then
18    test_features="--features mshv"
19fi
20
21cp scripts/sha1sums-x86_64 $WORKLOADS_DIR
22
23FOCAL_OS_IMAGE_NAME="focal-server-cloudimg-amd64-custom-20210609-0.qcow2"
24FOCAL_OS_IMAGE_URL="https://cloud-hypervisor.azureedge.net/$FOCAL_OS_IMAGE_NAME"
25FOCAL_OS_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_IMAGE_NAME"
26if [ ! -f "$FOCAL_OS_IMAGE" ]; then
27    pushd $WORKLOADS_DIR
28    time wget --quiet $FOCAL_OS_IMAGE_URL || exit 1
29    popd
30fi
31
32FOCAL_OS_RAW_IMAGE_NAME="focal-server-cloudimg-amd64-custom-20210609-0.raw"
33FOCAL_OS_RAW_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_RAW_IMAGE_NAME"
34if [ ! -f "$FOCAL_OS_RAW_IMAGE" ]; then
35    pushd $WORKLOADS_DIR
36    time qemu-img convert -p -f qcow2 -O raw $FOCAL_OS_IMAGE_NAME $FOCAL_OS_RAW_IMAGE_NAME || exit 1
37    popd
38fi
39
40pushd $WORKLOADS_DIR
41grep focal sha1sums-x86_64 | sha1sum --check
42if [ $? -ne 0 ]; then
43    echo "sha1sum validation of images failed, remove invalid images to fix the issue."
44    exit 1
45fi
46popd
47
48# Download Cloud Hypervisor binary from its last stable release
49LAST_RELEASE_VERSION="v30.0"
50CH_RELEASE_URL="https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/$LAST_RELEASE_VERSION/cloud-hypervisor-static"
51CH_RELEASE_NAME="cloud-hypervisor-static"
52pushd $WORKLOADS_DIR
53time wget --quiet $CH_RELEASE_URL -O "$CH_RELEASE_NAME" || exit 1
54chmod +x $CH_RELEASE_NAME
55popd
56
57# Build custom kernel based on virtio-pmem and virtio-fs upstream patches
58VMLINUX_IMAGE="$WORKLOADS_DIR/vmlinux"
59if [ ! -f "$VMLINUX_IMAGE" ]; then
60    build_custom_linux
61fi
62
63BUILD_TARGET="$(uname -m)-unknown-linux-${CH_LIBC}"
64CFLAGS=""
65TARGET_CC=""
66if [[ "${BUILD_TARGET}" == "x86_64-unknown-linux-musl" ]]; then
67    TARGET_CC="musl-gcc"
68    CFLAGS="-I /usr/include/x86_64-linux-musl/ -idirafter /usr/include/"
69fi
70
71cargo build --features mshv --all --release --target $BUILD_TARGET
72
73# Test ovs-dpdk relies on hugepages
74HUGEPAGESIZE=`grep Hugepagesize /proc/meminfo | awk '{print $2}'`
75PAGE_NUM=`echo $((12288 * 1024 / $HUGEPAGESIZE))`
76echo $PAGE_NUM | sudo tee /proc/sys/vm/nr_hugepages
77sudo chmod a+rwX /dev/hugepages
78
79export RUST_BACKTRACE=1
80time cargo test $test_features "live_migration_parallel::$test_filter" -- ${test_binary_args[*]}
81RES=$?
82
83# Run some tests in sequence since the result could be affected by other tests
84# running in parallel.
85if [ $RES -eq 0 ]; then
86    export RUST_BACKTRACE=1
87    time cargo test $test_features "live_migration_sequential::$test_filter" -- --test-threads=1 ${test_binary_args[*]}
88    RES=$?
89fi
90
91exit $RES
92