From df3e5c874f22db4041aa11cf9ebcb25eb4e120d7 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 1 Oct 2019 16:57:41 +0100 Subject: [PATCH] tests: Add support for integration testing Ubuntu "eoan" Refactor the Ubuntu testing infrastructure to support testing different versions. Signed-off-by: Rob Bradford --- scripts/run_integration_tests.sh | 18 ++++++++++++++++++ src/main.rs | 27 ++++++++++++++++++--------- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/scripts/run_integration_tests.sh b/scripts/run_integration_tests.sh index 7263e70fc..58ed98647 100755 --- a/scripts/run_integration_tests.sh +++ b/scripts/run_integration_tests.sh @@ -57,6 +57,24 @@ if [ ! -f "$BIONIC_OS_RAW_IMAGE" ]; then fi +EOAN_OS_IMAGE_NAME="eoan-server-cloudimg-amd64.img" +EOAN_OS_IMAGE_URL="https://cloudhypervisorstorage.blob.core.windows.net/images/$EOAN_OS_IMAGE_NAME" +EOAN_OS_IMAGE="$WORKLOADS_DIR/$EOAN_OS_IMAGE_NAME" +if [ ! -f "$EOAN_OS_IMAGE" ]; then + pushd $WORKLOADS_DIR + wget --quiet $EOAN_OS_IMAGE_URL + popd +fi + +EOAN_OS_RAW_IMAGE_NAME="eoan-server-cloudimg-amd64-raw.img" +EOAN_OS_RAW_IMAGE="$WORKLOADS_DIR/$EOAN_OS_RAW_IMAGE_NAME" +if [ ! -f "$EOAN_OS_RAW_IMAGE" ]; then + pushd $WORKLOADS_DIR + qemu-img convert -p -f qcow2 -O raw $EOAN_OS_IMAGE_NAME $EOAN_OS_RAW_IMAGE_NAME + popd +fi + + # Build custom kernel based on virtio-pmem and virtio-fs upstream patches VMLINUX_IMAGE="$WORKLOADS_DIR/vmlinux" BZIMAGE_IMAGE="$WORKLOADS_DIR/bzImage" diff --git a/src/main.rs b/src/main.rs index 7d5a187a3..23bb92404 100755 --- a/src/main.rs +++ b/src/main.rs @@ -400,14 +400,19 @@ mod tests { } } - struct BionicDiskConfig { + struct UbuntuDiskConfig { osdisk_raw_path: String, cloudinit_path: String, + image_name: String, } - impl BionicDiskConfig { - fn new() -> Self { - BionicDiskConfig { + const BIONIC_IMAGE_NAME: &str = "bionic-server-cloudimg-amd64-raw.img"; + const EOAN_IMAGE_NAME: &str = "eoan-server-cloudimg-amd64-raw.img"; + + impl UbuntuDiskConfig { + fn new(image_name: String) -> Self { + UbuntuDiskConfig { + image_name, osdisk_raw_path: String::new(), cloudinit_path: String::new(), } @@ -511,7 +516,7 @@ mod tests { } } - impl DiskConfig for BionicDiskConfig { + impl DiskConfig for UbuntuDiskConfig { fn prepare_cloudinit(&self, tmp_dir: &TempDir, network: &GuestNetworkConfig) -> String { let cloudinit_file_path = String::from(tmp_dir.path().join("cloudinit").to_str().unwrap()); @@ -575,7 +580,7 @@ mod tests { workload_path.push("workloads"); let mut osdisk_raw_base_path = workload_path.clone(); - osdisk_raw_base_path.push("bionic-server-cloudimg-amd64-raw.img"); + osdisk_raw_base_path.push(&self.image_name); let osdisk_raw_path = String::from(tmp_dir.path().join("osdisk_raw.img").to_str().unwrap()); @@ -894,11 +899,13 @@ mod tests { fn test_simple_launch() { test_block!(tb, "", { let mut clear = ClearDiskConfig::new(); - let mut bionic = BionicDiskConfig::new(); + let mut bionic = UbuntuDiskConfig::new(BIONIC_IMAGE_NAME.to_string()); + let mut eoan = UbuntuDiskConfig::new(EOAN_IMAGE_NAME.to_string()); vec![ &mut clear as &mut dyn DiskConfig, &mut bionic as &mut dyn DiskConfig, + &mut eoan as &mut dyn DiskConfig, ] .iter_mut() .for_each(|disk_config| { @@ -930,7 +937,7 @@ mod tests { aver_eq!(tb, guest.get_cpu_count().unwrap_or_default(), 1); aver_eq!(tb, guest.get_initial_apicid().unwrap_or(1), 0); - aver!(tb, guest.get_total_memory().unwrap_or_default() > 490_000); + aver!(tb, guest.get_total_memory().unwrap_or_default() > 488_000); aver!(tb, guest.get_entropy().unwrap_or_default() >= 900); aver_eq!( tb, @@ -2355,11 +2362,13 @@ mod tests { fn test_reboot() { test_block!(tb, "", { let mut clear = ClearDiskConfig::new(); - let mut bionic = BionicDiskConfig::new(); + let mut bionic = UbuntuDiskConfig::new(BIONIC_IMAGE_NAME.to_string()); + let mut eoan = UbuntuDiskConfig::new(EOAN_IMAGE_NAME.to_string()); vec![ &mut clear as &mut dyn DiskConfig, &mut bionic as &mut dyn DiskConfig, + &mut eoan as &mut dyn DiskConfig, ] .iter_mut() .for_each(|disk_config| {