1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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)
}
|