Skip to content

Commit d9477cd

Browse files
committed
tests: Add integration testing
This tests Cloud Hypervisor and QEMU (PVH) against Ubuntu Bionic/Focal and Clear Linux. They are built and run when the "integration_tests" feature is enabled and expect certain files to be available. This is handled by the "run_integration_tests.sh" script. This is also integrated into the Cloud Hypervior Jenkins using the included Jenkinsfile. Currently QEMU with Focal is disabled as that does not function. Signed-off-by: Rob Bradford <[email protected]>
1 parent e07fb90 commit d9477cd

File tree

11 files changed

+961
-0
lines changed

11 files changed

+961
-0
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,18 @@ log-serial = []
2222
# Log panics to serial output. Disabling this (without disabling log-serial)
2323
# gets you most of the code size reduction, without losing _all_ debugging.
2424
log-panic = ["log-serial"]
25+
integration_tests = []
2526

2627
[dependencies]
2728
bitflags = "1.2"
2829
x86_64 = "0.11"
2930
atomic_refcell = "0.1"
3031
r-efi = "2.1.0"
3132
uart_16550 = "0.2.7"
33+
34+
[dev-dependencies]
35+
dirs = "2.0.2"
36+
rand = "0.7.3"
37+
ssh2 = "0.8.1"
38+
tempdir = "0.3.7"
39+
tempfile = "3.1.0"

Jenkinsfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
pipeline {
2+
agent none
3+
stages {
4+
stage ("Worker build") {
5+
agent { node { label 'focal-fw' } }
6+
options {
7+
timeout(time: 1, unit: 'HOURS')
8+
}
9+
10+
stages {
11+
stage ('Checkout') {
12+
steps {
13+
checkout scm
14+
}
15+
}
16+
stage ('Install system packages') {
17+
steps {
18+
sh "sudo apt-get -y install build-essential mtools qemu-system-x86 libssl-dev pkg-config"
19+
}
20+
}
21+
stage ('Install Rust') {
22+
steps {
23+
sh "nohup curl https://sh.rustup.rs -sSf | sh -s -- -y"
24+
}
25+
}
26+
stage ('Run integration tests') {
27+
steps {
28+
sh "./run_integration_tests.sh"
29+
}
30+
}
31+
}
32+
}
33+
}
34+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"hostname" : "cloud"
3+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#cloud-config
2+
users:
3+
- name: cloud
4+
passwd: $6$7125787751a8d18a$sHwGySomUA1PawiNFWVCKYQN.Ec.Wzz0JtPPL1MvzFrkwmop2dq7.4CYf03A5oemPQ4pOFCCrtCelvFBEle/K.
5+
sudo:
6+
- ALL=(ALL) NOPASSWD:ALL
7+
write_files:
8+
-
9+
path: /etc/systemd/network/00-static-l1.network
10+
permissions: 0644
11+
content: |
12+
[Match]
13+
MACAddress=12:34:56:78:90:ab
14+
15+
[Network]
16+
Address=192.168.2.2/24
17+
Gateway=192.168.2.1

resources/cloud-init/ubuntu/meta-data

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
instance-id: cloud
2+
local-hostname: cloud
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
network:
2+
version: 1
3+
config:
4+
- type: physical
5+
name: eth0
6+
mac_address: 12:34:56:78:90:ab
7+
subnets:
8+
- type: static
9+
address: 192.168.2.2/24
10+
gateway: 192.168.2.1
11+
dns_nameservers:
12+
- 192.168.2.1

resources/cloud-init/ubuntu/user-data

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#cloud-config
2+
users:
3+
- name: cloud
4+
passwd: $6$7125787751a8d18a$sHwGySomUA1PawiNFWVCKYQN.Ec.Wzz0JtPPL1MvzFrkwmop2dq7.4CYf03A5oemPQ4pOFCCrtCelvFBEle/K.
5+
sudo: ALL=(ALL) NOPASSWD:ALL
6+
lock_passwd: False
7+
inactive: False
8+
shell: /bin/bash
9+
10+
ssh_pwauth: True

run_integration_tests.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
set -x
3+
4+
source $HOME/.cargo/env
5+
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
10+
11+
WORKLOADS_DIR="$HOME/workloads"
12+
mkdir -p "$WORKLOADS_DIR"
13+
14+
15+
CLEAR_OS_IMAGE_NAME="clear-31311-cloudguest.img"
16+
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"
18+
if [ ! -f "$CLEAR_OS_IMAGE" ]; then
19+
pushd $WORKLOADS_DIR
20+
wget --quiet $CLEAR_OS_IMAGE_URL || exit 1
21+
popd
22+
fi
23+
24+
BIONIC_OS_IMAGE_NAME="bionic-server-cloudimg-amd64.img"
25+
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"
27+
if [ ! -f "$BIONIC_OS_IMAGE" ]; then
28+
pushd $WORKLOADS_DIR
29+
wget --quiet $BIONIC_OS_IMAGE_URL || exit 1
30+
popd
31+
fi
32+
33+
BIONIC_OS_RAW_IMAGE_NAME="bionic-server-cloudimg-amd64-raw.img"
34+
BIONIC_OS_RAW_IMAGE="$WORKLOADS_DIR/$BIONIC_OS_RAW_IMAGE_NAME"
35+
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
38+
popd
39+
fi
40+
41+
42+
FOCAL_OS_IMAGE_NAME="focal-server-cloudimg-amd64.img"
43+
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"
45+
if [ ! -f "$FOCAL_OS_IMAGE" ]; then
46+
pushd $WORKLOADS_DIR
47+
wget --quiet $FOCAL_OS_IMAGE_URL || exit 1
48+
popd
49+
fi
50+
51+
FOCAL_OS_RAW_IMAGE_NAME="focal-server-cloudimg-amd64-raw.img"
52+
FOCAL_OS_RAW_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_RAW_IMAGE_NAME"
53+
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
56+
popd
57+
fi
58+
59+
cargo install cargo-xbuild
60+
rustup component add rust-src
61+
cargo xbuild --release --target target.json
62+
63+
sudo adduser $USER kvm
64+
newgrp kvm << EOF
65+
export RUST_BACKTRACE=1
66+
cargo test --features "integration_tests" -- --test-threads=1 test_boot
67+
EOF

0 commit comments

Comments
 (0)