ci: install libvirt for integration testing

This modifies the travis-ci configuration to build and install libvirt
1.2.2 and 2.3.0 for integration testing. Simple integration tests have
been included for Connect() and Disconnect().
This commit is contained in:
Ben LeMasurier 2016-10-20 12:51:44 -06:00
parent 00a2c05c46
commit 4ad0ae7f82
3 changed files with 90 additions and 1 deletions

View File

@ -1,13 +1,45 @@
language: go language: go
os: linux
dist: trusty
sudo: require
go: go:
- 1.7 - 1.7
env:
- LIBVIRT=1.2.2 EXT=gz
- LIBVIRT=2.3.0 EXT=xz
before_install: before_install:
- go get github.com/golang/lint/golint - go get github.com/golang/lint/golint
install:
# credit here goes to the go-libvirt authors,
# see: https://github.com/rgbkrk/libvirt-go/blob/master/.travis.yml
- sudo apt-get -qqy build-dep libvirt
- sudo apt-get -qqy install curl qemu-system-x86
- sudo mkdir -p /usr/src && sudo chown $(id -u) /usr/src
- curl -O -s https://libvirt.org/sources/libvirt-${LIBVIRT}.tar.${EXT}
- tar -C /usr/src -xf libvirt-${LIBVIRT}.tar.${EXT}
- pushd /usr/src/libvirt-${LIBVIRT}
- |
./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc \
--without-polkit \
--without-esx --without-vbox --without-xen --without-libxl --without-lxc \
--with-qemu
- make
- sudo make install
- popd
- sudo libvirtd -d -l -f libvirtd.conf
- sudo virtlogd -d || true
before_script: before_script:
- go get -d ./... - go get -d ./...
script: script:
- virsh list
- ./scripts/licensecheck.sh - ./scripts/licensecheck.sh
- go build ./... - go build ./...
- golint -set_exit_status ./... - golint -set_exit_status ./...
- go vet ./... - go vet ./...
- go test -v ./... - go test -v -tags=integration ./...

View File

@ -0,0 +1,50 @@
// Copyright 2016 The go-libvirt Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build integration
package libvirt
import (
"net"
"testing"
"time"
)
const testAddr = "127.0.0.1:16509"
func TestConnectIntegration(t *testing.T) {
l := New(testConn(t))
defer l.Disconnect()
if err := l.Connect(); err != nil {
t.Error(err)
}
}
func TestDisconnectIntegration(t *testing.T) {
l := New(testConn(t))
if err := l.Disconnect(); err != nil {
t.Error(err)
}
}
func testConn(t *testing.T) net.Conn {
conn, err := net.DialTimeout("tcp", testAddr, time.Second*2)
if err != nil {
t.Fatal(err)
}
return conn
}

7
libvirtd.conf Normal file
View File

@ -0,0 +1,7 @@
# libvirtd configuration for travis-ci
listen_tls = 0
listen_tcp = 1
tcp_port = "16509"
listen_addr = "127.0.0.1"
auth_unix_rw = "none"
auth_tcp = "none"