diff options
author | 2016-08-22 23:15:21 -0700 | |
---|---|---|
committer | 2016-08-23 07:15:21 +0100 | |
commit | 2153d2defd194d6678b749e54b72b21ed9f4b123 (patch) | |
tree | d8795c3370f2b7ae3b5c0dc48931a0032e6f8361 /test/kubernetes_test.go | |
parent | 8c9c4778c635aebcbf377dfeec8498f81184a06c (diff) | |
download | coredns-2153d2defd194d6678b749e54b72b21ed9f4b123.tar.gz coredns-2153d2defd194d6678b749e54b72b21ed9f4b123.tar.zst coredns-2153d2defd194d6678b749e54b72b21ed9f4b123.zip |
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
Diffstat (limited to 'test/kubernetes_test.go')
-rw-r--r-- | test/kubernetes_test.go | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/test/kubernetes_test.go b/test/kubernetes_test.go index c8dce32e4..3ba2bfcd4 100644 --- a/test/kubernetes_test.go +++ b/test/kubernetes_test.go @@ -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 { |