Skip to content

Commit 32c82b8

Browse files
josephlrrbradford
authored andcommitted
integration: Cleanup scripts and Rust binary
We remove unnecssary dependancies, simplifying our Cargo.lock file. We also cleanup the integration test script, to avoid writing to the user's home directory. This allows normal users to actually run ./run_integration_tests.sh We also add checks to avoid doing unnecessary work. Signed-off-by: Joe Richey <[email protected]>
1 parent bf7de3f commit 32c82b8

File tree

5 files changed

+47
-191
lines changed

5 files changed

+47
-191
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ clear-*-kvm.img*
22
fat*.img
33
target
44
test_data
5+
resources/cloud-hypervisor
6+
resources/images

Cargo.lock

Lines changed: 5 additions & 156 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ r-efi = "2.1.0"
3232
uart_16550 = "0.2.7"
3333

3434
[dev-dependencies]
35-
dirs = "2.0.2"
3635
rand = "0.7.3"
3736
ssh2 = "0.8.1"
38-
tempdir = "0.3.7"
3937
tempfile = "3.1.0"

run_integration_tests.sh

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,72 @@
11
#!/bin/bash
2-
set -x
2+
set -xeuf
33

4-
source $HOME/.cargo/env
4+
source "${CARGO_HOME:-$HOME/.cargo}/env"
55

6-
CH_VERSION="v0.8.0"
7-
rm cloud-hypervisor
8-
wget --quiet "https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/$CH_VERSION/cloud-hypervisor" || exit 1
9-
chmod +x cloud-hypervisor
6+
XBUILD_VERSION="0.5.34"
7+
cargo install cargo-xbuild --version $XBUILD_VERSION
8+
9+
rustup component add rust-src
10+
cargo xbuild --release --target target.json
1011

11-
WORKLOADS_DIR="$HOME/workloads"
12-
mkdir -p "$WORKLOADS_DIR"
12+
CH_VERSION="v0.8.0"
13+
CH_URL="https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/$CH_VERSION/cloud-hypervisor"
14+
CH_PATH="./resources/cloud-hypervisor"
15+
if [ ! -f "$CH_PATH" ]; then
16+
wget --quiet $CH_URL -O $CH_PATH
17+
chmod +x $CH_PATH
18+
fi
1319

20+
IMAGES_DIR="./resources/images"
21+
mkdir -p "$IMAGES_DIR"
1422

1523
CLEAR_OS_IMAGE_NAME="clear-31311-cloudguest.img"
1624
CLEAR_OS_IMAGE_URL="https://cloudhypervisorstorage.blob.core.windows.net/images/$CLEAR_OS_IMAGE_NAME"
17-
CLEAR_OS_IMAGE="$WORKLOADS_DIR/$CLEAR_OS_IMAGE_NAME"
25+
CLEAR_OS_IMAGE="$IMAGES_DIR/$CLEAR_OS_IMAGE_NAME"
1826
if [ ! -f "$CLEAR_OS_IMAGE" ]; then
19-
pushd $WORKLOADS_DIR
20-
wget --quiet $CLEAR_OS_IMAGE_URL || exit 1
27+
pushd $IMAGES_DIR
28+
wget --quiet $CLEAR_OS_IMAGE_URL
2129
popd
2230
fi
2331

2432
BIONIC_OS_IMAGE_NAME="bionic-server-cloudimg-amd64.img"
2533
BIONIC_OS_IMAGE_URL="https://cloudhypervisorstorage.blob.core.windows.net/images/$BIONIC_OS_IMAGE_NAME"
26-
BIONIC_OS_IMAGE="$WORKLOADS_DIR/$BIONIC_OS_IMAGE_NAME"
34+
BIONIC_OS_IMAGE="$IMAGES_DIR/$BIONIC_OS_IMAGE_NAME"
2735
if [ ! -f "$BIONIC_OS_IMAGE" ]; then
28-
pushd $WORKLOADS_DIR
29-
wget --quiet $BIONIC_OS_IMAGE_URL || exit 1
36+
pushd $IMAGES_DIR
37+
wget --quiet $BIONIC_OS_IMAGE_URL
3038
popd
3139
fi
3240

3341
BIONIC_OS_RAW_IMAGE_NAME="bionic-server-cloudimg-amd64-raw.img"
34-
BIONIC_OS_RAW_IMAGE="$WORKLOADS_DIR/$BIONIC_OS_RAW_IMAGE_NAME"
42+
BIONIC_OS_RAW_IMAGE="$IMAGES_DIR/$BIONIC_OS_RAW_IMAGE_NAME"
3543
if [ ! -f "$BIONIC_OS_RAW_IMAGE" ]; then
36-
pushd $WORKLOADS_DIR
37-
qemu-img convert -p -f qcow2 -O raw $BIONIC_OS_IMAGE_NAME $BIONIC_OS_RAW_IMAGE_NAME || exit 1
44+
pushd $IMAGES_DIR
45+
qemu-img convert -p -f qcow2 -O raw $BIONIC_OS_IMAGE_NAME $BIONIC_OS_RAW_IMAGE_NAME
3846
popd
3947
fi
4048

4149

4250
FOCAL_OS_IMAGE_NAME="focal-server-cloudimg-amd64.img"
4351
FOCAL_OS_IMAGE_URL="https://cloudhypervisorstorage.blob.core.windows.net/images/$FOCAL_OS_IMAGE_NAME"
44-
FOCAL_OS_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_IMAGE_NAME"
52+
FOCAL_OS_IMAGE="$IMAGES_DIR/$FOCAL_OS_IMAGE_NAME"
4553
if [ ! -f "$FOCAL_OS_IMAGE" ]; then
46-
pushd $WORKLOADS_DIR
47-
wget --quiet $FOCAL_OS_IMAGE_URL || exit 1
54+
pushd $IMAGES_DIR
55+
wget --quiet $FOCAL_OS_IMAGE_URL
4856
popd
4957
fi
5058

5159
FOCAL_OS_RAW_IMAGE_NAME="focal-server-cloudimg-amd64-raw.img"
52-
FOCAL_OS_RAW_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_RAW_IMAGE_NAME"
60+
FOCAL_OS_RAW_IMAGE="$IMAGES_DIR/$FOCAL_OS_RAW_IMAGE_NAME"
5361
if [ ! -f "$FOCAL_OS_RAW_IMAGE" ]; then
54-
pushd $WORKLOADS_DIR
55-
qemu-img convert -p -f qcow2 -O raw $FOCAL_OS_IMAGE_NAME $FOCAL_OS_RAW_IMAGE_NAME || exit 1
62+
pushd $IMAGES_DIR
63+
qemu-img convert -p -f qcow2 -O raw $FOCAL_OS_IMAGE_NAME $FOCAL_OS_RAW_IMAGE_NAME
5664
popd
5765
fi
5866

59-
cargo install cargo-xbuild
60-
rustup component add rust-src
61-
cargo xbuild --release --target target.json
67+
# Add the user to the kvm group (if not already in it), so they can run VMs
68+
id -nGz "$USER" | grep -qzxF kvm || sudo adduser "$USER" kvm
6269

63-
sudo adduser $USER kvm
6470
newgrp kvm << EOF
6571
export RUST_BACKTRACE=1
6672
cargo test --features "integration_tests" -- --test-threads=1 test_boot

0 commit comments

Comments
 (0)