aboutsummaryrefslogtreecommitdiff
path: root/test/kubernetes_fallthrough_test.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2017-09-01 08:53:42 +0200
committerGravatar GitHub <noreply@github.com> 2017-09-01 08:53:42 +0200
commit7d47af4f0615e3040691f5d0dd1230aded998a06 (patch)
tree5c6105486cd3656a8023c582a23d386a4af96259 /test/kubernetes_fallthrough_test.go
parenta08a4beec453c9c65f3b2be31859e33a973c436c (diff)
downloadcoredns-7d47af4f0615e3040691f5d0dd1230aded998a06.tar.gz
coredns-7d47af4f0615e3040691f5d0dd1230aded998a06.tar.zst
coredns-7d47af4f0615e3040691f5d0dd1230aded998a06.zip
mw/kubernetes: move fallthrough tests out (#1008)
* mw/kubernetes: move fallthrough tests out Remove the testcase duplication and put fallthrough tests in separate file. Also make some names shorter and more descriptive. * fix test build * fix corefile
Diffstat (limited to 'test/kubernetes_fallthrough_test.go')
-rw-r--r--test/kubernetes_fallthrough_test.go75
1 files changed, 75 insertions, 0 deletions
diff --git a/test/kubernetes_fallthrough_test.go b/test/kubernetes_fallthrough_test.go
new file mode 100644
index 000000000..4e5ee5d5c
--- /dev/null
+++ b/test/kubernetes_fallthrough_test.go
@@ -0,0 +1,75 @@
+// +build k8s
+
+package test
+
+import (
+ "io/ioutil"
+ "log"
+ "os"
+ "testing"
+
+ "github.com/coredns/coredns/middleware/test"
+
+ "github.com/miekg/dns"
+)
+
+func init() {
+ log.SetOutput(ioutil.Discard)
+}
+
+var dnsTestCasesFallthrough = []test.Case{
+ {
+ Qname: "ext-svc.test-1.svc.cluster.local.", Qtype: dns.TypeA,
+ Rcode: dns.RcodeSuccess,
+ Answer: []dns.RR{
+ test.A("example.net. 303 IN A 13.14.15.16"),
+ test.CNAME("ext-svc.test-1.svc.cluster.local. 303 IN CNAME example.net."),
+ },
+ },
+ {
+ Qname: "f.b.svc.cluster.local.", Qtype: dns.TypeA,
+ Rcode: dns.RcodeSuccess,
+ Answer: []dns.RR{
+ test.A("f.b.svc.cluster.local. 303 IN A 10.10.10.11"),
+ },
+ Ns: []dns.RR{
+ test.NS("cluster.local. 303 IN NS a.iana-servers.net."),
+ test.NS("cluster.local. 303 IN NS b.iana-servers.net."),
+ },
+ },
+ {
+ Qname: "foo.cluster.local.", Qtype: dns.TypeA,
+ Rcode: dns.RcodeSuccess,
+ Answer: []dns.RR{
+ test.A("foo.cluster.local. 303 IN A 10.10.10.10"),
+ },
+ Ns: []dns.RR{
+ test.NS("cluster.local. 303 IN NS a.iana-servers.net."),
+ test.NS("cluster.local. 303 IN NS b.iana-servers.net."),
+ },
+ },
+}
+
+func TestKubernetesFallthrough(t *testing.T) {
+ dbfile, rmFunc, err := TempFile(os.TempDir(), clusterLocal)
+ if err != nil {
+ t.Fatalf("Could not create zonefile for fallthrough server: %s", err)
+ }
+ defer rmFunc()
+
+ rmFunc, upstream, udp := upstreamServer(t)
+ defer upstream.Stop()
+ defer rmFunc()
+
+ corefile :=
+ `.:0 {
+ file ` + dbfile + ` cluster.local
+ kubernetes cluster.local {
+ endpoint http://localhost:8080
+ namespaces test-1
+ upstream ` + udp + `
+ fallthrough
+ }
+`
+ doIntegrationTests(t, corefile, dnsTestCasesFallthrough)
+}