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.
This commit is contained in:
Darragh Bailey
2021-06-01 17:45:02 +01:00
committed by GitHub
parent dbbfad2503
commit 31cc8aa91e
4 changed files with 44 additions and 6 deletions

View File

@@ -43,12 +43,13 @@ jobs:
bridge-utils \ bridge-utils \
dnsmasq-base \ dnsmasq-base \
ebtables \ ebtables \
libarchive-tools \
libguestfs-tools \
libvirt-clients \ libvirt-clients \
libvirt-daemon \ libvirt-daemon \
libvirt-daemon-system \ libvirt-daemon-system \
qemu-kvm \ qemu-kvm \
qemu-utils \ qemu-utils \
libarchive-tools \
; ;
sudo apt-get install \ sudo apt-get install \
libvirt-dev \ libvirt-dev \

View File

@@ -183,6 +183,7 @@ vagrant-libvirt. This depends on your distro. An overview:
apt-get build-dep vagrant ruby-libvirt apt-get build-dep vagrant ruby-libvirt
apt-get install qemu libvirt-daemon-system libvirt-clients ebtables dnsmasq-base 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 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: * 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 build-dep vagrant ruby-libvirt
apt-get install qemu libvirt-bin ebtables dnsmasq-base 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 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.) (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: * CentOS 6, 7, Fedora 21:
```shell ```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: * Fedora 22 and up:
```shell ```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: * OpenSUSE leap 15.1:
```shell ```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. * 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, ... On RedHat, Centos, Fedora, ...
```shell ```shell
$ sudo dnf install libxslt-devel libxml2-devel libvirt-devel \ $ sudo dnf install libxslt-devel libxml2-devel libvirt-devel ruby-devel gcc
libguestfs-tools-c ruby-devel gcc
``` ```
On Arch Linux it is recommended to follow [steps from ArchWiki](https://wiki.archlinux.org/index.php/Vagrant#vagrant-libvirt). On Arch Linux it is recommended to follow [steps from ArchWiki](https://wiki.archlinux.org/index.php/Vagrant#vagrant-libvirt).

8
tests/package_simple/Vagrantfile vendored Normal file
View File

@@ -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

View File

@@ -134,3 +134,31 @@ cleanup() {
[ $(expr "$output" : ".*alive.*") -ne 0 ] [ $(expr "$output" : ".*alive.*") -ne 0 ]
cleanup 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
}