diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-06-03 18:40:15 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-06-03 18:40:15 +0300 |
commit | 9e9f11944c0b98b06b6c1d9d85bf2fa56bd129a6 (patch) | |
tree | 9e23d3c0423dc2863988acb4000afd9742b7bd4b | |
parent | c6d5f522c24683a7846dfd2407e264977ce19122 (diff) | |
download | vmdb2-9e9f11944c0b98b06b6c1d9d85bf2fa56bd129a6.tar.gz |
Add a smoke test for vmdb2-built images
This is for a fixed image, and more may be added later.
-rw-r--r-- | smoke-pc.vmdb | 43 | ||||
-rw-r--r-- | smoke.yarn | 59 |
2 files changed, 102 insertions, 0 deletions
diff --git a/smoke-pc.vmdb b/smoke-pc.vmdb new file mode 100644 index 0000000..9fe587e --- /dev/null +++ b/smoke-pc.vmdb @@ -0,0 +1,43 @@ +steps: + - mkimg: "{{ output }}" + size: 4G + + - mklabel: msdos + device: "{{ output }}" + + - mkpart: primary + device: "{{ output }}" + start: 0% + end: 100% + part-tag: root-part + + - mkfs: ext4 + partition: root-part + + - mount: root-part + fs-tag: root-fs + + - unpack-rootfs: root-fs + + - debootstrap: stretch + mirror: http://http.debian.net/debian + target: root-fs + unless: rootfs_unpacked + + - apt: linux-image-amd64 + fs-tag: root-fs + unless: rootfs_unpacked + + - cache-rootfs: root-fs + unless: rootfs_unpacked + + - chroot: root-fs + shell: | + sed -i '/^root:[^:]*:/s//root::/' /etc/passwd + echo pc-vmdb2 > /etc/hostname + + - grub: bios + root-fs: root-fs + root-part: root-part + device: "{{ output }}" + console: serial diff --git a/smoke.yarn b/smoke.yarn new file mode 100644 index 0000000..d5ed02f --- /dev/null +++ b/smoke.yarn @@ -0,0 +1,59 @@ +# Smoke test vmdb2-built images + +This yarn file builds a basic image, and runs it under Qemu. The image +is configured to have a serial console enabled, and the scenario below +will log in as root (no password), and command the virtual machine to +power off. If this works, the image is at least minimally functional, +so the "smoke test" passes. + +More elaborate testing can be added, but smoke testing is enough for +now. + +To run this yarn file, you need to run it as root (since it needs to +build an image as root), and you need to run on an amd64 system (and +thus build an amd64 image). Additionally, you need to add the folloing +option to yarn: + + --env ROOTFS_TARBALL=/path/to/rootfs/tarball + +This means vmdb2 will use the given tarball when creating an image, +and if the tarball doesn't exist yet, it will create it. This makes +testing multiple time much faster. + + SCENARIO smoke test image + WHEN user runs vmdb smoke-pc.vmdb --output smoke-pc.img + THEN user can boot smoke-pc.img and power it off from root shell + + IMPLEMENTS WHEN user runs vmdb (\S+) --output (\S+) + "$SRCDIR/vmdb2" --no-default-config "$SRCDIR/$MATCH_1" \ + --output "$DATADIR/$MATCH_2" \ + --log vmdb.log \ + --rootfs-tarball "$ROOTFS_TARBALL" + + IMPLEMENTS THEN user can boot (\S+) and power it off from root shell + cd "$DATADIR" + img="$MATCH_1" + cat << EOF > run.sh + qemu-system-x86_64 -drive file="$img",format=raw -m 1024 -nographic + EOF + chmod a+rx run.sh + cat << EOF > expect.txt + set timeout 30 + proc abort {} { + puts "ERROR ERROR\n" + exit 1 + } + spawn ./run.sh + expect "login: " + send "root\n" + expect "# " + send "poweroff\r" + set timeout 5 + expect { + "reboot: Power down" {puts poweroffing\n} + eof abort + timeout abort + } + expect eof + EOF + expect -d expect.txt > expect.out |