Add A lookup for headless services (#451)

This commit is contained in:
Chris O'Haver 2016-12-02 17:50:01 -05:00 committed by Miek Gieben
parent 8faa8354b4
commit 56d3b47d11
4 changed files with 136 additions and 6 deletions

View file

@ -59,6 +59,8 @@ var dnsTestCases = []test.Case{
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"),
test.A("headless-svc.test-1.svc.cluster.local. 303 IN A 172.17.0.5"),
test.A("headless-svc.test-1.svc.cluster.local. 303 IN A 172.17.0.6"),
},
},
{
@ -68,6 +70,8 @@ var dnsTestCases = []test.Case{
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"),
test.A("headless-svc.test-1.svc.cluster.local. 303 IN A 172.17.0.5"),
test.A("headless-svc.test-1.svc.cluster.local. 303 IN A 172.17.0.6"),
},
},
{
@ -87,6 +91,16 @@ var dnsTestCases = []test.Case{
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"),
test.A("headless-svc.test-1.svc.cluster.local. 303 IN A 172.17.0.5"),
test.A("headless-svc.test-1.svc.cluster.local. 303 IN A 172.17.0.6"),
},
},
{
Qname: "headless-svc.test-1.svc.cluster.local.", Qtype: dns.TypeA,
Rcode: dns.RcodeSuccess,
Answer: []dns.RR{
test.A("headless-svc.test-1.svc.cluster.local. 303 IN A 172.17.0.5"),
test.A("headless-svc.test-1.svc.cluster.local. 303 IN A 172.17.0.6"),
},
},
//TODO: Fix below to all use test.SRV not test.A!
@ -137,6 +151,8 @@ var dnsTestCases = []test.Case{
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."),
test.SRV("_c-port._udp.headless-svc.test-1.svc.cluster.local. 303 IN SRV 10 100 1234 headless-svc.test-1.svc.cluster.local."),
test.SRV("_c-port._udp.headless-svc.test-1.svc.cluster.local. 303 IN SRV 10 100 1234 headless-svc.test-1.svc.cluster.local."),
},
},
{
@ -147,6 +163,8 @@ var dnsTestCases = []test.Case{
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."),
test.SRV("_c-port._udp.headless-svc.test-1.svc.cluster.local. 303 IN SRV 10 100 1234 headless-svc.test-1.svc.cluster.local."),
test.SRV("_c-port._udp.headless-svc.test-1.svc.cluster.local. 303 IN SRV 10 100 1234 headless-svc.test-1.svc.cluster.local."),
},
},
{
@ -167,6 +185,8 @@ var dnsTestCases = []test.Case{
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."),
test.SRV("_c-port._udp.headless-svc.test-1.svc.cluster.local. 303 IN SRV 10 100 1234 headless-svc.test-1.svc.cluster.local."),
test.SRV("_c-port._udp.headless-svc.test-1.svc.cluster.local. 303 IN SRV 10 100 1234 headless-svc.test-1.svc.cluster.local."),
},
},
{
@ -223,6 +243,7 @@ func TestKubernetesIntegration(t *testing.T) {
time.Sleep(5 * time.Second)
for _, tc := range dnsTestCases {
dnsClient := new(dns.Client)
dnsMessage := new(dns.Msg)