summaryrefslogtreecommitdiff
path: root/.travis.yml
diff options
context:
space:
mode:
authorEamonn O'Toole <eamonn.otoole@hpe.com>2017-03-06 16:41:39 +0000
committerAlvaro <alvaro.saurin@gmail.com>2017-03-14 14:58:05 +0100
commit7238954130c9168fa67ff279970c75ab9f13ea81 (patch)
treed2e2df0d73542b94a5e60aa36da193a6f87187ee /.travis.yml
parent339afdac28358bf7bc007354d778e5efc3b0358b (diff)
downloadterraform-provider-libvirt-7238954130c9168fa67ff279970c75ab9f13ea81.tar
terraform-provider-libvirt-7238954130c9168fa67ff279970c75ab9f13ea81.tar.gz
Increase code coverage by running TF acceptance tests
This has required a number of changes, first of all to .travis.yml to allow the TF acceptance tests to run: 1. To avoid the need to build libvirt, we've added the Ubuntu "cloud-archive:mitaka" repo which contains more recent versions of libvirt than those that ship with 14.04. This also cuts a couple of minutes off the travis run-time. 2. We need to define and start a default storage pool, since one doesn't exist by default on 14.04. 3. We need to add the travis user to the libvirtd group, and then run both tests with "sg" to set the libvirtd group without requiring a log-out/log-in 4. We need to set a couple of global environment variables for the travis run: - TF_ACC to true to ensure that TF acceptance tests are run - LIBVIRT_DEFAULT_URI needs to be set, we set it to qemu://system. - We've added a new environment variable that can be used to set the domain type for test purposes. We need to set the domain type to "qemu" for travis CI. "test" doesn't implement all of the libvirt functions that are used, and "kvm" isn't yet available in travis. 5. We have to add "-v" to the test and goveralls command to ensure that TF acceptance tests are run. In addition, we had to make the following change to resource_libvirt_domain_test.go - The "br0" bridge doesn't exist by default, so instead we use the default network in resource_libvirt_domain_test.go With these changes the test coverage goes up to 44% as measured by goveralls. Because we're using qemu emulation, the tests take about 2 mins to run on travis. We might not need to run both the tests and goveralls; one might do.
Diffstat (limited to '.travis.yml')
-rw-r--r--.travis.yml29
1 files changed, 16 insertions, 13 deletions
diff --git a/.travis.yml b/.travis.yml
index 687158cf..eed2d261 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,18 +5,15 @@ go:
- 1.7
before_install:
+ - sudo add-apt-repository -y cloud-archive:mitaka
- sudo apt-get -qq update
- - sudo apt-get install -y wget
- - sudo apt-get build-dep -y libvirt
- - wget https://libvirt.org/sources/libvirt-1.2.14.tar.gz
- - sudo mkdir -p /usr/src
- - sudo tar xvzf libvirt-1.2.14.tar.gz -C /usr/src
- - pushd /usr/src/libvirt-1.2.14
- - sudo ./configure --prefix=/usr/
- - sudo make
- - sudo make install
- - sudo libvirtd -d
- - popd
+ - 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
- go get github.com/mattn/goveralls
- go get -u github.com/govend/govend
- govend -v
@@ -27,6 +24,12 @@ install:
# 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"
+
script:
- - go test ./libvirt
- - $HOME/gopath/bin/goveralls -service=travis-ci
+ - sg libvirtd -c "go test -v ./libvirt"
+ - sg libvirtd -c "$HOME/gopath/bin/goveralls -v -service=travis-ci"