diff options
author | Flavio Castelli <fcastelli@suse.com> | 2017-07-27 01:23:08 +0200 |
---|---|---|
committer | Flavio Castelli <flavio@castelli.me> | 2017-07-27 14:59:30 +0200 |
commit | 991da6f90957a3cba82d6e079423492c5841e74d (patch) | |
tree | 22af87ca7a4c3ec8f59ca16f3e868ae5445c523b /travis | |
parent | ccf4dff4f872291b5cf131cbdfb3d3c5b2f0dd47 (diff) | |
download | terraform-provider-libvirt-991da6f90957a3cba82d6e079423492c5841e74d.tar terraform-provider-libvirt-991da6f90957a3cba82d6e079423492c5841e74d.tar.gz |
Fix broken tests
The tests are failing because travis has an old version of libvirt that
is not happy about the xml we generate.
Unfortunately there's no way to get a more recent version of ubuntu on
travis (it's stuck with trusty!!) and there are not libvirt 2.0
packages for trusty.
This commit fixes the issues in the "inception" way:
* travis provisions a ubuntu trusty VM as usual
* the travis/host script does the following steps:
* installs LXD
* creates a system container based on the latest release of ubuntu
* runs the container as privileged one
* mount the git checkout into the container as read-only mount
point (it easier than having a RW one)
* runs the travis/guest script inside of the container:
* install libvirt + go 1.8
* run the acceptance tests, save coverage to file
* on the travis VM:
* pull the coverage results file from the container
* send it to coverall
So far everything is working and is a miracle given the container,
based on a more recent version of ubuntu, is using the kernel of the
host, the old ubuntu trusty.
This is just a termporary workaround until either travis updates its
VMs to a more recent release of ubuntu or we switch the project to use
Jenkins with an openSUSE worker.
Signed-off-by: Flavio Castelli <fcastelli@suse.com>
Diffstat (limited to 'travis')
-rwxr-xr-x | travis/run-tests-inside-guest | 19 | ||||
-rwxr-xr-x | travis/setup-guest | 21 | ||||
-rwxr-xr-x | travis/setup-host | 16 |
3 files changed, 56 insertions, 0 deletions
diff --git a/travis/run-tests-inside-guest b/travis/run-tests-inside-guest new file mode 100755 index 00000000..63fbb0c5 --- /dev/null +++ b/travis/run-tests-inside-guest @@ -0,0 +1,19 @@ +#!/bin/bash +set -x + +unset http_proxy + +export GOROOT=/usr/lib/go-1.8/ +export GOPATH=/root/go +export PATH=$GOPATH/bin:$GOROOT/bin:$PATH + +mkdir -p /root/go/src/github.com/dmacvicar/ +cp -r /code/ /root/go/src/github.com/dmacvicar/terraform-provider-libvirt +cd /root/go/src/github.com/dmacvicar/terraform-provider-libvirt + +go build . + +export TERRAFORM_LIBVIRT_TEST_DOMAIN_TYPE=qemu +export LIBVIRT_DEFAULT_URI="qemu:///system" +export TF_ACC=true +go test -v -covermode=count -coverprofile=profile.cov ./libvirt diff --git a/travis/setup-guest b/travis/setup-guest new file mode 100755 index 00000000..43b87853 --- /dev/null +++ b/travis/setup-guest @@ -0,0 +1,21 @@ +#!/bin/bash +set -x + +unset http_proxy + +check_network() { + ping -c 3 archive.ubuntu.com +} + +while check_network ; [ $? -ne 0 ];do + echo waiting for network to be ready... + sleep 1 +done + +apt-get -qq update +apt-get install -y qemu libvirt-bin libvirt-dev golang-1.8 +echo -e "<pool type='dir'>\n<name>default</name>\n<target>\n<path>/pool-default</path>\n</target>\n</pool>" > pool.xml +mkdir /pool-default +chmod a+rwx /pool-default +virsh pool-define pool.xml +virsh pool-start default diff --git a/travis/setup-host b/travis/setup-host new file mode 100755 index 00000000..fd4ad07f --- /dev/null +++ b/travis/setup-host @@ -0,0 +1,16 @@ +#!/bin/bash +set -x + +sudo apt -t trusty-backports install -y lxd + +sudo sed -i 's/LXD_IPV4_ADDR=".*"/LXD_IPV4_ADDR="192.168.123.1"/' /etc/default/lxd-bridge +sudo sed -i 's/LXD_IPV4_NETMASK=".*"/LXD_IPV4_NETMASK="255.255.255.0"/' /etc/default/lxd-bridge +sudo sed -i 's/LXD_IPV4_NETWORK=".*"/LXD_IPV4_NETWORK="192.168.123.0\/24"/' /etc/default/lxd-bridge +sudo sed -i 's/LXD_IPV4_DHCP_RANGE=".*"/LXD_IPV4_DHCP_RANGE="192.168.123.2,192.168.123.12"/' /etc/default/lxd-bridge +sudo sed -i 's/LXD_IPV4_DHCP_MAX=".*"/LXD_IPV4_DHCP_MAX="10"/' /etc/default/lxd-bridge + +sudo service lxd restart + +sudo lxc launch ubuntu:zesty libvirt -c security.privileged=true +sudo lxc config device add libvirt code disk source=`pwd` path=code +sudo lxc info libvirt |