aboutsummaryrefslogtreecommitdiff
path: root/plugin/kubernetes/reverse_test.go
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2020-02-21 01:24:02 -0500
committerGravatar GitHub <noreply@github.com> 2020-02-21 07:24:02 +0100
commit6ef105ced326f08212ed2f8cf2816a620e9a266a (patch)
tree9a5e6126f50b7657322c4e22205fdcb4c89d9d63 /plugin/kubernetes/reverse_test.go
parented1841c36f8633d7bd6ea3bc8a22eb16ce67377e (diff)
downloadcoredns-6ef105ced326f08212ed2f8cf2816a620e9a266a.tar.gz
coredns-6ef105ced326f08212ed2f8cf2816a620e9a266a.tar.zst
coredns-6ef105ced326f08212ed2f8cf2816a620e9a266a.zip
return all records with matching ip (#3687)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'plugin/kubernetes/reverse_test.go')
-rw-r--r--plugin/kubernetes/reverse_test.go69
1 files changed, 47 insertions, 22 deletions
diff --git a/plugin/kubernetes/reverse_test.go b/plugin/kubernetes/reverse_test.go
index 2af72522e..78bbef3a3 100644
--- a/plugin/kubernetes/reverse_test.go
+++ b/plugin/kubernetes/reverse_test.go
@@ -56,34 +56,51 @@ func (APIConnReverseTest) SvcIndexReverse(ip string) []*object.Service {
}
func (APIConnReverseTest) EpIndexReverse(ip string) []*object.Endpoints {
+ ep1 := object.Endpoints{
+ Subsets: []object.EndpointSubset{
+ {
+ Addresses: []object.EndpointAddress{
+ {IP: "10.0.0.100", Hostname: "ep1a"},
+ {IP: "1234:abcd::1", Hostname: "ep1b"},
+ {IP: "fd00:77:30::a", Hostname: "ip6svc1ex"},
+ {IP: "fd00:77:30::2:9ba6", Hostname: "ip6svc1in"},
+ {IP: "10.0.0.99", Hostname: "double-ep"}, // this endpoint is used by two services
+ },
+ Ports: []object.EndpointPort{
+ {Port: 80, Protocol: "tcp", Name: "http"},
+ },
+ },
+ },
+ Name: "svc1",
+ Namespace: "testns",
+ }
+ ep2 := object.Endpoints{
+ Subsets: []object.EndpointSubset{
+ {
+ Addresses: []object.EndpointAddress{
+ {IP: "10.0.0.99", Hostname: "double-ep"}, // this endpoint is used by two services
+ },
+ Ports: []object.EndpointPort{
+ {Port: 80, Protocol: "tcp", Name: "http"},
+ },
+ },
+ },
+ Name: "svc2",
+ Namespace: "testns",
+ }
switch ip {
case "10.0.0.100":
+ fallthrough
case "1234:abcd::1":
+ fallthrough
case "fd00:77:30::a":
+ fallthrough
case "fd00:77:30::2:9ba6":
- default:
- return nil
+ return []*object.Endpoints{&ep1}
+ case "10.0.0.99":
+ return []*object.Endpoints{&ep1, &ep2}
}
- eps := []*object.Endpoints{
- {
- Subsets: []object.EndpointSubset{
- {
- Addresses: []object.EndpointAddress{
- {IP: "10.0.0.100", Hostname: "ep1a"},
- {IP: "1234:abcd::1", Hostname: "ep1b"},
- {IP: "fd00:77:30::a", Hostname: "ip6svc1ex"},
- {IP: "fd00:77:30::2:9ba6", Hostname: "ip6svc1in"},
- },
- Ports: []object.EndpointPort{
- {Port: 80, Protocol: "tcp", Name: "http"},
- },
- },
- },
- Name: "svc1",
- Namespace: "testns",
- },
- }
- return eps
+ return nil
}
func (APIConnReverseTest) GetNodeByName(name string) (*api.Node, error) {
@@ -178,6 +195,14 @@ func TestReverse(t *testing.T) {
test.SOA("cluster.local. 5 IN SOA ns.dns.cluster.local. hostmaster.cluster.local. 1502989566 7200 1800 86400 5"),
},
},
+ {
+ Qname: "99.0.0.10.in-addr.arpa.", Qtype: dns.TypePTR,
+ Rcode: dns.RcodeSuccess,
+ Answer: []dns.RR{
+ test.PTR("99.0.0.10.in-addr.arpa. 5 IN PTR double-ep.svc1.testns.svc.cluster.local."),
+ test.PTR("99.0.0.10.in-addr.arpa. 5 IN PTR double-ep.svc2.testns.svc.cluster.local."),
+ },
+ },
}
ctx := context.TODO()