From afe4368c344a4934396521c0cf42c62e60ea515c Mon Sep 17 00:00:00 2001 From: John Belamaric Date: Mon, 14 Nov 2016 19:31:08 +0000 Subject: K8s Test Cleanup and Service PTR Change the CI setup for K8s to be simpler. Now it just creates a set of objects via a yaml file, making it very easy to modify the tests. Implement PTR for services. --- test/kubernetes_test.go | 117 ++++++++++++++++++++++++++++++------------------ 1 file changed, 74 insertions(+), 43 deletions(-) (limited to 'test/kubernetes_test.go') diff --git a/test/kubernetes_test.go b/test/kubernetes_test.go index 6fba08e54..819f55489 100644 --- a/test/kubernetes_test.go +++ b/test/kubernetes_test.go @@ -17,144 +17,175 @@ import ( var dnsTestCases = []test.Case{ { - Qname: "mynginx.demo.svc.coredns.local.", Qtype: dns.TypeA, + Qname: "svc-1-a.test-1.svc.cluster.local.", Qtype: dns.TypeA, Rcode: dns.RcodeSuccess, Answer: []dns.RR{ - test.A("mynginx.demo.svc.coredns.local. 1800 IN A 10.3.0.10"), + test.A("svc-1-a.test-1.svc.cluster.local. 303 IN A 10.3.0.100"), }, }, { - Qname: "bogusservice.demo.svc.coredns.local.", Qtype: dns.TypeA, + Qname: "bogusservice.test-1.svc.cluster.local.", Qtype: dns.TypeA, Rcode: dns.RcodeNameError, Answer: []dns.RR{}, }, { - Qname: "mynginx.*.svc.coredns.local.", Qtype: dns.TypeA, + Qname: "svc-1-a.*.svc.cluster.local.", Qtype: dns.TypeA, Rcode: dns.RcodeSuccess, Answer: []dns.RR{ - test.A("mynginx.demo.svc.coredns.local. 1800 IN A 10.3.0.10"), + test.A("svc-1-a.test-1.svc.cluster.local. 303 IN A 10.3.0.100"), }, }, { - Qname: "mynginx.any.svc.coredns.local.", Qtype: dns.TypeA, + Qname: "svc-1-a.any.svc.cluster.local.", Qtype: dns.TypeA, Rcode: dns.RcodeSuccess, Answer: []dns.RR{ - test.A("mynginx.demo.svc.coredns.local. 1800 IN A 10.3.0.10"), + test.A("svc-1-a.test-1.svc.cluster.local. 303 IN A 10.3.0.100"), }, }, { - Qname: "bogusservice.*.svc.coredns.local.", Qtype: dns.TypeA, + Qname: "bogusservice.*.svc.cluster.local.", Qtype: dns.TypeA, Rcode: dns.RcodeNameError, Answer: []dns.RR{}, }, { - Qname: "bogusservice.any.svc.coredns.local.", Qtype: dns.TypeA, + Qname: "bogusservice.any.svc.cluster.local.", Qtype: dns.TypeA, Rcode: dns.RcodeNameError, Answer: []dns.RR{}, }, { - Qname: "*.demo.svc.coredns.local.", Qtype: dns.TypeA, + Qname: "*.test-1.svc.cluster.local.", Qtype: dns.TypeA, Rcode: dns.RcodeSuccess, Answer: []dns.RR{ - test.A("mynginx.demo.svc.coredns.local. 1800 IN A 10.3.0.10"), - test.A("webserver.demo.svc.coredns.local. 1800 IN A 10.3.0.20"), + test.A("svc-1-a.test-1.svc.cluster.local. 303 IN A 10.3.0.100"), + test.A("svc-1-b.test-1.svc.cluster.local. 303 IN A 10.3.0.110"), + test.A("svc-c.test-1.svc.cluster.local. 303 IN A 10.3.0.115"), }, }, { - Qname: "any.demo.svc.coredns.local.", Qtype: dns.TypeA, + Qname: "any.test-1.svc.cluster.local.", Qtype: dns.TypeA, Rcode: dns.RcodeSuccess, Answer: []dns.RR{ - test.A("mynginx.demo.svc.coredns.local. 1800 IN A 10.3.0.10"), - test.A("webserver.demo.svc.coredns.local. 1800 IN A 10.3.0.20"), + test.A("svc-1-a.test-1.svc.cluster.local. 303 IN A 10.3.0.100"), + test.A("svc-1-b.test-1.svc.cluster.local. 303 IN A 10.3.0.110"), + test.A("svc-c.test-1.svc.cluster.local. 303 IN A 10.3.0.115"), }, }, { - Qname: "any.test.svc.coredns.local.", Qtype: dns.TypeA, + Qname: "any.test-2.svc.cluster.local.", Qtype: dns.TypeA, Rcode: dns.RcodeNameError, Answer: []dns.RR{}, }, { - Qname: "*.test.svc.coredns.local.", Qtype: dns.TypeA, + Qname: "*.test-2.svc.cluster.local.", Qtype: dns.TypeA, Rcode: dns.RcodeNameError, Answer: []dns.RR{}, }, { - Qname: "*.*.svc.coredns.local.", Qtype: dns.TypeA, + Qname: "*.*.svc.cluster.local.", Qtype: dns.TypeA, Rcode: dns.RcodeSuccess, Answer: []dns.RR{ - test.A("mynginx.demo.svc.coredns.local. 1800 IN A 10.3.0.10"), - test.A("webserver.demo.svc.coredns.local. 1800 IN A 10.3.0.20"), + test.A("svc-1-a.test-1.svc.cluster.local. 303 IN A 10.3.0.100"), + test.A("svc-1-b.test-1.svc.cluster.local. 303 IN A 10.3.0.110"), + test.A("svc-c.test-1.svc.cluster.local. 303 IN A 10.3.0.115"), }, }, //TODO: Fix below to all use test.SRV not test.A! { - Qname: "mynginx.demo.svc.coredns.local.", Qtype: dns.TypeSRV, + Qname: "svc-1-a.test-1.svc.cluster.local.", Qtype: dns.TypeSRV, Rcode: dns.RcodeSuccess, Answer: []dns.RR{ - test.A("mynginx.demo.svc.coredns.local. 1800 IN A 10.3.0.10"), + test.SRV("_http._tcp.svc-1-a.test-1.svc.cluster.local. 303 IN SRV 10 100 80 svc-1-a.test-1.svc.cluster.local."), + test.SRV("_https._tcp.svc-1-a.test-1.svc.cluster.local. 303 IN SRV 10 100 443 svc-1-a.test-1.svc.cluster.local."), }, }, { - Qname: "bogusservice.demo.svc.coredns.local.", Qtype: dns.TypeSRV, + Qname: "bogusservice.test-1.svc.cluster.local.", Qtype: dns.TypeSRV, Rcode: dns.RcodeNameError, Answer: []dns.RR{}, }, { - Qname: "mynginx.*.svc.coredns.local.", Qtype: dns.TypeSRV, + Qname: "svc-1-a.*.svc.cluster.local.", Qtype: dns.TypeSRV, Rcode: dns.RcodeSuccess, Answer: []dns.RR{ - test.A("mynginx.demo.svc.coredns.local. 1800 IN A 10.3.0.10"), + test.SRV("_http._tcp.svc-1-a.test-1.svc.cluster.local. 303 IN SRV 10 100 80 svc-1-a.test-1.svc.cluster.local."), + test.SRV("_https._tcp.svc-1-a.test-1.svc.cluster.local. 303 IN SRV 10 100 443 svc-1-a.test-1.svc.cluster.local."), }, }, { - Qname: "mynginx.any.svc.coredns.local.", Qtype: dns.TypeSRV, + Qname: "svc-1-a.any.svc.cluster.local.", Qtype: dns.TypeSRV, Rcode: dns.RcodeSuccess, Answer: []dns.RR{ - test.A("mynginx.demo.svc.coredns.local. 1800 IN A 10.3.0.10"), + test.SRV("_http._tcp.svc-1-a.test-1.svc.cluster.local. 303 IN SRV 10 100 80 svc-1-a.test-1.svc.cluster.local."), + test.SRV("_https._tcp.svc-1-a.test-1.svc.cluster.local. 303 IN SRV 10 100 443 svc-1-a.test-1.svc.cluster.local."), }, }, { - Qname: "bogusservice.*.svc.coredns.local.", Qtype: dns.TypeSRV, + Qname: "bogusservice.*.svc.cluster.local.", Qtype: dns.TypeSRV, Rcode: dns.RcodeNameError, Answer: []dns.RR{}, }, { - Qname: "bogusservice.any.svc.coredns.local.", Qtype: dns.TypeSRV, + Qname: "bogusservice.any.svc.cluster.local.", Qtype: dns.TypeSRV, Rcode: dns.RcodeNameError, Answer: []dns.RR{}, }, { - Qname: "*.demo.svc.coredns.local.", Qtype: dns.TypeSRV, + Qname: "*.test-1.svc.cluster.local.", Qtype: dns.TypeSRV, Rcode: dns.RcodeSuccess, Answer: []dns.RR{ - test.A("mynginx.demo.svc.coredns.local. 1800 IN A 10.3.0.10"), - test.A("webserver.demo.svc.coredns.local. 1800 IN A 10.3.0.20"), + test.SRV("_http._tcp.svc-1-a.test-1.svc.cluster.local. 303 IN SRV 10 100 80 svc-1-a.test-1.svc.cluster.local."), + test.SRV("_https._tcp.svc-1-a.test-1.svc.cluster.local. 303 IN SRV 10 100 443 svc-1-a.test-1.svc.cluster.local."), + test.SRV("_http._tcp.svc-1-b.test-1.svc.cluster.local. 303 IN SRV 10 100 80 svc-1-b.test-1.svc.cluster.local."), + test.SRV("_c-port._udp.svc-c.test-1.svc.cluster.local. 303 IN SRV 10 100 1234 svc-c.test-1.svc.cluster.local."), }, }, { - Qname: "any.demo.svc.coredns.local.", Qtype: dns.TypeSRV, + Qname: "any.test-1.svc.cluster.local.", Qtype: dns.TypeSRV, Rcode: dns.RcodeSuccess, Answer: []dns.RR{ - test.A("mynginx.demo.svc.coredns.local. 1800 IN A 10.3.0.10"), - test.A("webserver.demo.svc.coredns.local. 1800 IN A 10.3.0.20"), + test.SRV("_http._tcp.svc-1-a.test-1.svc.cluster.local. 303 IN SRV 10 100 80 svc-1-a.test-1.svc.cluster.local."), + test.SRV("_https._tcp.svc-1-a.test-1.svc.cluster.local. 303 IN SRV 10 100 443 svc-1-a.test-1.svc.cluster.local."), + test.SRV("_http._tcp.svc-1-b.test-1.svc.cluster.local. 303 IN SRV 10 100 80 svc-1-b.test-1.svc.cluster.local."), + test.SRV("_c-port._udp.svc-c.test-1.svc.cluster.local. 303 IN SRV 10 100 1234 svc-c.test-1.svc.cluster.local."), }, }, { - Qname: "any.test.svc.coredns.local.", Qtype: dns.TypeSRV, + Qname: "any.test-2.svc.cluster.local.", Qtype: dns.TypeSRV, Rcode: dns.RcodeNameError, Answer: []dns.RR{}, }, { - Qname: "*.test.svc.coredns.local.", Qtype: dns.TypeSRV, + Qname: "*.test-2.svc.cluster.local.", Qtype: dns.TypeSRV, Rcode: dns.RcodeNameError, Answer: []dns.RR{}, }, { - Qname: "*.*.svc.coredns.local.", Qtype: dns.TypeSRV, + Qname: "*.*.svc.cluster.local.", Qtype: dns.TypeSRV, Rcode: dns.RcodeSuccess, Answer: []dns.RR{ - test.A("mynginx.demo.svc.coredns.local. 1800 IN A 10.3.0.10"), - test.A("webserver.demo.svc.coredns.local. 1800 IN A 10.3.0.20"), + test.SRV("_http._tcp.svc-1-a.test-1.svc.cluster.local. 303 IN SRV 10 100 80 svc-1-a.test-1.svc.cluster.local."), + test.SRV("_https._tcp.svc-1-a.test-1.svc.cluster.local. 303 IN SRV 10 100 443 svc-1-a.test-1.svc.cluster.local."), + test.SRV("_http._tcp.svc-1-b.test-1.svc.cluster.local. 303 IN SRV 10 100 80 svc-1-b.test-1.svc.cluster.local."), + test.SRV("_c-port._udp.svc-c.test-1.svc.cluster.local. 303 IN SRV 10 100 1234 svc-c.test-1.svc.cluster.local."), + }, + }, + { + Qname: "123.0.3.10.in-addr.arpa.", Qtype: dns.TypePTR, + Rcode: dns.RcodeSuccess, + Answer: []dns.RR{}, + }, + { + Qname: "100.0.3.10.in-addr.arpa.", Qtype: dns.TypePTR, + Rcode: dns.RcodeSuccess, + Answer: []dns.RR{ + test.PTR("100.0.3.10.in-addr.arpa. 303 IN PTR svc-1-a.test-1.svc.cluster.local."), + }, + }, + { + Qname: "115.0.3.10.in-addr.arpa.", Qtype: dns.TypePTR, + Rcode: dns.RcodeSuccess, + Answer: []dns.RR{ + test.PTR("115.0.3.10.in-addr.arpa. 303 IN PTR svc-c.test-1.svc.cluster.local."), }, }, } @@ -176,12 +207,12 @@ func createTestServer(t *testing.T, corefile string) (*caddy.Instance, string) { func TestKubernetesIntegration(t *testing.T) { corefile := `.:0 { - kubernetes coredns.local { + kubernetes cluster.local 0.3.10.in-addr.arpa { endpoint http://localhost:8080 - #endpoint https://kubernetes/ admin.pem admin-key.pem ca.pem #endpoint https://kubernetes/ + #tls admin.pem admin-key.pem ca.pem #tls k8s_auth/client2.crt k8s_auth/client2.key k8s_auth/ca2.crt - namespaces demo + namespaces test-1 } ` server, udp := createTestServer(t, corefile) -- cgit v1.2.3 From 99b60d296641799d9a82f4fb5d0a747896dc01c4 Mon Sep 17 00:00:00 2001 From: John Belamaric Date: Tue, 15 Nov 2016 13:42:38 +0000 Subject: Change IPs to match hyperkube --- .travis/kubernetes/dns-test.yaml | 8 ++++---- test/kubernetes_test.go | 34 +++++++++++++++++----------------- 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'test/kubernetes_test.go') diff --git a/.travis/kubernetes/dns-test.yaml b/.travis/kubernetes/dns-test.yaml index 77a68426c..91140830f 100644 --- a/.travis/kubernetes/dns-test.yaml +++ b/.travis/kubernetes/dns-test.yaml @@ -99,7 +99,7 @@ metadata: spec: selector: app: app-1-a - clusterIP: 10.3.0.100 + clusterIP: 10.0.0.100 ports: - name: http port: 80 @@ -116,7 +116,7 @@ metadata: spec: selector: app: app-1-b - clusterIP: 10.3.0.110 + clusterIP: 10.0.0.110 ports: - name: http port: 80 @@ -130,7 +130,7 @@ metadata: spec: selector: app: app-c - clusterIP: 10.3.0.115 + clusterIP: 10.0.0.115 ports: - name: c-port port: 1234 @@ -144,7 +144,7 @@ metadata: spec: selector: app: app-c - clusterIP: 10.3.0.120 + clusterIP: 10.0.0.120 ports: - name: c-port port: 1234 diff --git a/test/kubernetes_test.go b/test/kubernetes_test.go index 819f55489..44033b965 100644 --- a/test/kubernetes_test.go +++ b/test/kubernetes_test.go @@ -20,7 +20,7 @@ var dnsTestCases = []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.3.0.100"), + test.A("svc-1-a.test-1.svc.cluster.local. 303 IN A 10.0.0.100"), }, }, { @@ -32,14 +32,14 @@ var dnsTestCases = []test.Case{ Qname: "svc-1-a.*.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.3.0.100"), + test.A("svc-1-a.test-1.svc.cluster.local. 303 IN A 10.0.0.100"), }, }, { Qname: "svc-1-a.any.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.3.0.100"), + test.A("svc-1-a.test-1.svc.cluster.local. 303 IN A 10.0.0.100"), }, }, { @@ -56,18 +56,18 @@ var dnsTestCases = []test.Case{ Qname: "*.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.3.0.100"), - test.A("svc-1-b.test-1.svc.cluster.local. 303 IN A 10.3.0.110"), - test.A("svc-c.test-1.svc.cluster.local. 303 IN A 10.3.0.115"), + test.A("svc-1-a.test-1.svc.cluster.local. 303 IN A 10.0.0.100"), + test.A("svc-1-b.test-1.svc.cluster.local. 303 IN A 10.0.0.110"), + test.A("svc-c.test-1.svc.cluster.local. 303 IN A 10.0.0.115"), }, }, { Qname: "any.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.3.0.100"), - test.A("svc-1-b.test-1.svc.cluster.local. 303 IN A 10.3.0.110"), - test.A("svc-c.test-1.svc.cluster.local. 303 IN A 10.3.0.115"), + test.A("svc-1-a.test-1.svc.cluster.local. 303 IN A 10.0.0.100"), + test.A("svc-1-b.test-1.svc.cluster.local. 303 IN A 10.0.0.110"), + test.A("svc-c.test-1.svc.cluster.local. 303 IN A 10.0.0.115"), }, }, { @@ -84,9 +84,9 @@ var dnsTestCases = []test.Case{ Qname: "*.*.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.3.0.100"), - test.A("svc-1-b.test-1.svc.cluster.local. 303 IN A 10.3.0.110"), - test.A("svc-c.test-1.svc.cluster.local. 303 IN A 10.3.0.115"), + test.A("svc-1-a.test-1.svc.cluster.local. 303 IN A 10.0.0.100"), + test.A("svc-1-b.test-1.svc.cluster.local. 303 IN A 10.0.0.110"), + test.A("svc-c.test-1.svc.cluster.local. 303 IN A 10.0.0.115"), }, }, //TODO: Fix below to all use test.SRV not test.A! @@ -170,22 +170,22 @@ var dnsTestCases = []test.Case{ }, }, { - Qname: "123.0.3.10.in-addr.arpa.", Qtype: dns.TypePTR, + Qname: "123.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR, Rcode: dns.RcodeSuccess, Answer: []dns.RR{}, }, { - Qname: "100.0.3.10.in-addr.arpa.", Qtype: dns.TypePTR, + Qname: "100.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR, Rcode: dns.RcodeSuccess, Answer: []dns.RR{ - test.PTR("100.0.3.10.in-addr.arpa. 303 IN PTR svc-1-a.test-1.svc.cluster.local."), + test.PTR("100.0.0.10.in-addr.arpa. 303 IN PTR svc-1-a.test-1.svc.cluster.local."), }, }, { - Qname: "115.0.3.10.in-addr.arpa.", Qtype: dns.TypePTR, + Qname: "115.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR, Rcode: dns.RcodeSuccess, Answer: []dns.RR{ - test.PTR("115.0.3.10.in-addr.arpa. 303 IN PTR svc-c.test-1.svc.cluster.local."), + test.PTR("115.0.0.10.in-addr.arpa. 303 IN PTR svc-c.test-1.svc.cluster.local."), }, }, } -- cgit v1.2.3 From 7e93746083ee235f3b611b312953e72f91ebd953 Mon Sep 17 00:00:00 2001 From: John Belamaric Date: Tue, 15 Nov 2016 15:03:49 +0000 Subject: Fix reverse zone in corefile --- test/kubernetes_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/kubernetes_test.go') diff --git a/test/kubernetes_test.go b/test/kubernetes_test.go index 44033b965..68ec319cf 100644 --- a/test/kubernetes_test.go +++ b/test/kubernetes_test.go @@ -207,7 +207,7 @@ func createTestServer(t *testing.T, corefile string) (*caddy.Instance, string) { func TestKubernetesIntegration(t *testing.T) { corefile := `.:0 { - kubernetes cluster.local 0.3.10.in-addr.arpa { + kubernetes cluster.local 0.0.10.in-addr.arpa { endpoint http://localhost:8080 #endpoint https://kubernetes/ #tls admin.pem admin-key.pem ca.pem -- cgit v1.2.3