summaryrefslogtreecommitdiff
path: root/libvirt/domain_def.go
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 /libvirt/domain_def.go
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 'libvirt/domain_def.go')
-rw-r--r--libvirt/domain_def.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/libvirt/domain_def.go b/libvirt/domain_def.go
index 3920c979..f26b549c 100644
--- a/libvirt/domain_def.go
+++ b/libvirt/domain_def.go
@@ -2,6 +2,7 @@ package libvirt
import (
"encoding/xml"
+ "os"
)
type defDomain struct {
@@ -115,7 +116,11 @@ type defConsole struct {
func newDomainDef() defDomain {
// libvirt domain definition
domainDef := defDomain{}
- domainDef.Type = "kvm"
+ if v := os.Getenv("TERRAFORM_LIBVIRT_TEST_DOMAIN_TYPE"); v != "" {
+ domainDef.Type = v
+ } else {
+ domainDef.Type = "kvm"
+ }
domainDef.Xmlns = ""
domainDef.Os = defOs{}