aboutsummaryrefslogtreecommitdiff
path: root/plugin/k8s_external/external_test.go
diff options
context:
space:
mode:
authorGravatar Michael Kashin <mmkashin@gmail.com> 2020-05-29 10:04:23 -0700
committerGravatar GitHub <noreply@github.com> 2020-05-29 17:04:23 +0000
commit2e3ef77731f3ffffa24eae057acce3435f2babcb (patch)
treeddbf0c4fbbc09a19e7b3d41990e555a7dcc93db2 /plugin/k8s_external/external_test.go
parent54fb2112ac7616db93d5b9e505079d821f15ec2d (diff)
downloadcoredns-2e3ef77731f3ffffa24eae057acce3435f2babcb.tar.gz
coredns-2e3ef77731f3ffffa24eae057acce3435f2babcb.tar.zst
coredns-2e3ef77731f3ffffa24eae057acce3435f2babcb.zip
k8s_external can now resolve CNAME returned by AWS ELB/NLB (#3916)
Automatically submitted.
Diffstat (limited to 'plugin/k8s_external/external_test.go')
-rw-r--r--plugin/k8s_external/external_test.go51
1 files changed, 41 insertions, 10 deletions
diff --git a/plugin/k8s_external/external_test.go b/plugin/k8s_external/external_test.go
index 1123c6f6f..45584b6b1 100644
--- a/plugin/k8s_external/external_test.go
+++ b/plugin/k8s_external/external_test.go
@@ -41,6 +41,7 @@ func TestExternal(t *testing.T) {
}
resp := w.Msg
+
if resp == nil {
t.Fatalf("Test %d, got nil message and no error for %q", i, r.Question[0].Name)
}
@@ -147,21 +148,33 @@ var tests = []test.Case{
test.SOA("example.com. 5 IN SOA ns1.dns.example.com. hostmaster.example.com. 1499347823 7200 1800 86400 5"),
},
},
+ {
+ Qname: "svc11.testns.example.com.", Qtype: dns.TypeA, Rcode: dns.RcodeSuccess,
+ Answer: []dns.RR{
+ test.A("svc11.testns.example.com. 5 IN A 1.2.3.4"),
+ },
+ },
+ {
+ Qname: "svc12.testns.example.com.", Qtype: dns.TypeA, Rcode: dns.RcodeSuccess,
+ Answer: []dns.RR{
+ test.CNAME("svc12.testns.example.com. 5 IN CNAME dummy.hostname"),
+ },
+ },
}
type external struct{}
-func (external) HasSynced() bool { return true }
-func (external) Run() {}
-func (external) Stop() error { return nil }
-func (external) EpIndexReverse(string) []*object.Endpoints { return nil }
-func (external) SvcIndexReverse(string) []*object.Service { return nil }
-func (external) Modified() int64 { return 0 }
-func (external) EpIndex(s string) []*object.Endpoints { return nil }
-func (external) EndpointsList() []*object.Endpoints { return nil }
+func (external) HasSynced() bool { return true }
+func (external) Run() {}
+func (external) Stop() error { return nil }
+func (external) EpIndexReverse(string) []*object.Endpoints { return nil }
+func (external) SvcIndexReverse(string) []*object.Service { return nil }
+func (external) Modified() int64 { return 0 }
+func (external) EpIndex(s string) []*object.Endpoints { return nil }
+func (external) EndpointsList() []*object.Endpoints { return nil }
func (external) GetNodeByName(ctx context.Context, name string) (*api.Node, error) { return nil, nil }
-func (external) SvcIndex(s string) []*object.Service { return svcIndexExternal[s] }
-func (external) PodIndex(string) []*object.Pod { return nil }
+func (external) SvcIndex(s string) []*object.Service { return svcIndexExternal[s] }
+func (external) PodIndex(string) []*object.Pod { return nil }
func (external) GetNamespaceByName(name string) (*api.Namespace, error) {
return &api.Namespace{
@@ -192,6 +205,24 @@ var svcIndexExternal = map[string][]*object.Service{
Ports: []api.ServicePort{{Name: "http", Protocol: "tcp", Port: 80}},
},
},
+ "svc11.testns": {
+ {
+ Name: "svc11",
+ Namespace: "testns",
+ Type: api.ServiceTypeLoadBalancer,
+ ExternalIPs: []string{"1.2.3.4"},
+ Ports: []api.ServicePort{{Name: "http", Protocol: "tcp", Port: 80}},
+ },
+ },
+ "svc12.testns": {
+ {
+ Name: "svc12",
+ Namespace: "testns",
+ Type: api.ServiceTypeLoadBalancer,
+ ExternalIPs: []string{"dummy.hostname"},
+ Ports: []api.ServicePort{{Name: "http", Protocol: "tcp", Port: 80}},
+ },
+ },
}
func (external) ServiceList() []*object.Service {