aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml33
-rwxr-xr-xtravis/run-tests-inside-guest19
-rwxr-xr-xtravis/setup-guest21
-rwxr-xr-xtravis/setup-host16
4 files changed, 63 insertions, 26 deletions
diff --git a/.travis.yml b/.travis.yml
index cd78f440..a05d064a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,31 +3,12 @@ language: go
go:
- 1.8
-
-before_install:
- - sudo add-apt-repository -y cloud-archive:mitaka
- - sudo apt-get -qq update
- - sudo apt-get install -y qemu libvirt-bin libvirt-dev
- - sudo usermod -a -G libvirtd $USER
- - echo -e "<pool type='dir'>\n<name>default</name>\n<target>\n<path>/pool-default</path>\n</target>\n</pool>" > pool.xml
- - sudo mkdir /pool-default
- - sudo chmod a+rwx /pool-default
- - sudo virsh pool-define pool.xml
- - sudo virsh pool-start default
+install: true
+before_script:
- go get github.com/mattn/goveralls
-
-install:
- - go build .
-
-# override the custom test script, this would trigger
-# also the execution of the unit tests of the vendored
-# code
-env:
- global:
- - TERRAFORM_LIBVIRT_TEST_DOMAIN_TYPE=qemu
- - TF_ACC=true
- - LIBVIRT_DEFAULT_URI="qemu:///system"
-
+ - sudo bash ./travis/setup-host
+ - sudo lxc exec libvirt -- bash /code/travis/setup-guest
script:
- - sg libvirtd -c "go test -v ./libvirt"
- - sg libvirtd -c "$HOME/gopath/bin/goveralls -v -service=travis-ci"
+ - sudo lxc exec libvirt -- bash /code/travis/run-tests-inside-guest
+ - sudo lxc file pull libvirt/root/go/src/github.com/dmacvicar/terraform-provider-libvirt/profile.cov .
+ - goveralls -coverprofile=profile.cov -service=travis-ci
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