From 31cc8aa91ec652d42b4577822a3b665d87db83ee Mon Sep 17 00:00:00 2001 From: Darragh Bailey Date: Tue, 1 Jun 2021 17:45:02 +0100 Subject: [PATCH] Add basic vagrant package integration test (#1302) Simple integration test for vagrant package to ensure the execution completes successfully to allow for some refactoring to be performed. Ensure libguestfs-tools installed to provide virt-sysprep for tests and update docs to reflect. --- .github/workflows/integration-tests.yml | 3 ++- README.md | 11 +++++----- tests/package_simple/Vagrantfile | 8 +++++++ tests/runtests.bats | 28 +++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 tests/package_simple/Vagrantfile diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 09069cf..4074552 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -43,12 +43,13 @@ jobs: bridge-utils \ dnsmasq-base \ ebtables \ + libarchive-tools \ + libguestfs-tools \ libvirt-clients \ libvirt-daemon \ libvirt-daemon-system \ qemu-kvm \ qemu-utils \ - libarchive-tools \ ; sudo apt-get install \ libvirt-dev \ diff --git a/README.md b/README.md index 6a26af9..4448ce5 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,7 @@ vagrant-libvirt. This depends on your distro. An overview: apt-get build-dep vagrant ruby-libvirt apt-get install qemu libvirt-daemon-system libvirt-clients ebtables dnsmasq-base apt-get install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev +a[t-get install libguestfs-tools ``` * Ubuntu 18.04, Debian 8 and older: @@ -190,23 +191,24 @@ apt-get install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev apt-get build-dep vagrant ruby-libvirt apt-get install qemu libvirt-bin ebtables dnsmasq-base apt-get install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev +apt-get install libguestfs-tools ``` (It is possible some users will already have libraries from the third line installed, but this is the way to make it work OOTB.) * CentOS 6, 7, Fedora 21: ```shell -yum install qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm +yum install qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm libguestfs-tools ``` * Fedora 22 and up: ```shell -dnf install -y gcc libvirt libvirt-devel libxml2-devel make ruby-devel +dnf install -y gcc libvirt libvirt-devel libxml2-devel make ruby-devel libguestfs-tools ``` * OpenSUSE leap 15.1: ```shell -zypper install qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm +zypper install qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm libguestfs ``` * Arch Linux: please read the related [ArchWiki](https://wiki.archlinux.org/index.php/Vagrant#vagrant-libvirt) page. @@ -241,8 +243,7 @@ On Ubuntu, Debian, make sure you are running all three of the `apt` commands abo On RedHat, Centos, Fedora, ... ```shell -$ sudo dnf install libxslt-devel libxml2-devel libvirt-devel \ - libguestfs-tools-c ruby-devel gcc +$ sudo dnf install libxslt-devel libxml2-devel libvirt-devel ruby-devel gcc ``` On Arch Linux it is recommended to follow [steps from ArchWiki](https://wiki.archlinux.org/index.php/Vagrant#vagrant-libvirt). diff --git a/tests/package_simple/Vagrantfile b/tests/package_simple/Vagrantfile new file mode 100644 index 0000000..fce0f36 --- /dev/null +++ b/tests/package_simple/Vagrantfile @@ -0,0 +1,8 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + config.vm.box = "infernix/tinycore" + config.ssh.shell = "/bin/sh" + config.vm.synced_folder ".", "/vagrant", disabled: true +end diff --git a/tests/runtests.bats b/tests/runtests.bats index ad75501..13b84d7 100644 --- a/tests/runtests.bats +++ b/tests/runtests.bats @@ -134,3 +134,31 @@ cleanup() { [ $(expr "$output" : ".*alive.*") -ne 0 ] cleanup } + +@test "package simple domain" { + export VAGRANT_CWD=tests/package_simple + cleanup + run ${VAGRANT_CMD} up ${VAGRANT_OPT} + echo "${output}" + echo "status = ${status}" + [ "$status" -eq 0 ] + run ${VAGRANT_CMD} halt + echo "${output}" + echo "status = ${status}" + [ "$status" -eq 0 ] + run ${VAGRANT_CMD} package + echo "${output}" + echo "status = ${status}" + [ "$status" -eq 0 ] + run ${VAGRANT_CMD} box add package.box --name test-package-simple-domain + echo "${output}" + echo "status = ${status}" + [ "$status" -eq 0 ] + run ${VAGRANT_CMD} box remove test-package-simple-domain + echo "${output}" + echo "status = ${status}" + [ "$status" -eq 0 ] + rm -f package.box + + cleanup +}