Fix k8s integration tests (#231)

* Adding debug message when starting k8s controller

* Adding work-around for timing issue in k8s integration tests

* Remove unused import

* Fix Makefile for ast package

* Increase k8s verbosity in travis

* Updating TODO list to find root cause of test issue

* go fmt cleanup
This commit is contained in:
Michael Richmond 2016-08-22 23:15:21 -07:00 committed by Miek Gieben
parent 8c9c4778c6
commit 2153d2defd
6 changed files with 65 additions and 46 deletions

View file

@ -6,7 +6,9 @@ import (
"io/ioutil"
"log"
"testing"
"time"
"github.com/mholt/caddy"
"github.com/miekg/dns"
)
@ -61,21 +63,15 @@ var testdataLookupSRV = []struct {
{"*.*.coredns.local.", 1, 1}, // One SRV record, via namespace and service wildcard
}
func testK8sIntegration(t *testing.T) {
func TestK8sIntegration(t *testing.T) {
// t.Skip("Skip Kubernetes Integration tests")
// subtests here (Go 1.7 feature).
testLookupA(t)
testLookupSRV(t)
}
func testLookupA(t *testing.T) {
corefile :=
`.:0 {
kubernetes coredns.local {
endpoint http://localhost:8080
namespaces demo
}
`
func createTestServer(t *testing.T, corefile string) (*caddy.Instance, string) {
server, err := CoreDNSServer(corefile)
if err != nil {
t.Fatalf("could not get CoreDNS serving instance: %s", err)
@ -85,10 +81,28 @@ func testLookupA(t *testing.T) {
if udp == "" {
t.Fatalf("could not get udp listening port")
}
return server, udp
}
func testLookupA(t *testing.T) {
corefile :=
`.:0 {
kubernetes coredns.local {
endpoint http://localhost:8080
namespaces demo
}
`
server, udp := createTestServer(t, corefile)
defer server.Stop()
log.SetOutput(ioutil.Discard)
// Work-around for timing condition that results in no-data being returned in
// test environment.
time.Sleep(5 * time.Second)
for _, testData := range testdataLookupA {
dnsClient := new(dns.Client)
dnsMessage := new(dns.Msg)
@ -126,18 +140,15 @@ func testLookupSRV(t *testing.T) {
}
`
server, err := CoreDNSServer(corefile)
if err != nil {
t.Fatalf("could not get CoreDNS serving instance: %s", err)
}
udp, _ := CoreDNSServerPorts(server, 0)
if udp == "" {
t.Fatalf("could not get udp listening port")
}
server, udp := createTestServer(t, corefile)
defer server.Stop()
log.SetOutput(ioutil.Discard)
// Work-around for timing condition that results in no-data being returned in
// test environment.
time.Sleep(5 * time.Second)
// TODO: Add checks for A records in additional section
for _, testData := range testdataLookupSRV {