aboutsummaryrefslogtreecommitdiff
path: root/test/kubernetes_api_fallthrough_test.go
diff options
context:
space:
mode:
authorGravatar Yong Tang <yong.tang.github@outlook.com> 2017-09-01 10:21:05 -0700
committerGravatar Miek Gieben <miek@miek.nl> 2017-09-01 19:21:05 +0200
commit4b14243e9bb9fb6147771e7a5b76c934a28acdd7 (patch)
tree16c990ef82a84876d30e3e35270f5c2bc715b718 /test/kubernetes_api_fallthrough_test.go
parent6493858893960c677f1af118ff53626366d40a22 (diff)
downloadcoredns-4b14243e9bb9fb6147771e7a5b76c934a28acdd7.tar.gz
coredns-4b14243e9bb9fb6147771e7a5b76c934a28acdd7.tar.zst
coredns-4b14243e9bb9fb6147771e7a5b76c934a28acdd7.zip
Add k8s tags to related tests (#1018)
, so that `make test` will pass by default. Also fixed several ineffassign and golint issues. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'test/kubernetes_api_fallthrough_test.go')
-rw-r--r--test/kubernetes_api_fallthrough_test.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/kubernetes_api_fallthrough_test.go b/test/kubernetes_api_fallthrough_test.go
new file mode 100644
index 000000000..20c0aaa21
--- /dev/null
+++ b/test/kubernetes_api_fallthrough_test.go
@@ -0,0 +1,53 @@
+// +build k8s
+
+package test
+
+import (
+ "testing"
+ "time"
+
+ "github.com/coredns/coredns/middleware/test"
+
+ "github.com/miekg/dns"
+)
+
+func TestKubernetesAPIFallthrough(t *testing.T) {
+ tests := []test.Case{
+ {
+ Qname: "svc-1-a.test-1.svc.cluster.local.", Qtype: dns.TypeA,
+ Rcode: dns.RcodeSuccess,
+ Answer: []dns.RR{
+ test.A("svc-1-a.test-1.svc.cluster.local. 303 IN A 10.0.0.100"),
+ },
+ },
+ }
+
+ corefile :=
+ `.:0 {
+ kubernetes cluster.local {
+ endpoint http://nonexistance:8080,http://invalidip:8080,http://localhost:8080
+ namespaces test-1
+ pods disabled
+ }`
+
+ server, udp, _, err := CoreDNSServerAndPorts(corefile)
+ if err != nil {
+ t.Fatalf("Could not get CoreDNS serving instance: %s", err)
+ }
+ defer server.Stop()
+
+ // Work-around for timing condition that results in no-data being returned in test environment.
+ time.Sleep(3 * time.Second)
+
+ for _, tc := range tests {
+
+ c := new(dns.Client)
+ m := tc.Msg()
+
+ res, _, err := c.Exchange(m, udp)
+ if err != nil {
+ t.Fatalf("Could not send query: %s", err)
+ }
+ test.SortAndCheck(t, res, tc)
+ }
+}