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
This commit is contained in:
parent
a08a4beec4
commit
7d47af4f06
2 changed files with 85 additions and 346 deletions
75
test/kubernetes_fallthrough_test.go
Normal file
75
test/kubernetes_fallthrough_test.go
Normal file
|
@ -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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue