aboutsummaryrefslogtreecommitdiff
path: root/plugin/kubernetes/kubernetes_test.go
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2020-10-30 08:14:30 -0400
committerGravatar GitHub <noreply@github.com> 2020-10-30 08:14:30 -0400
commit272ccb195d31cd1622d48f961f3a189ce3abb937 (patch)
treeb5db771e2371b2e4ede772dff2c2c4217188115c /plugin/kubernetes/kubernetes_test.go
parentc840caf1ef77d8f86ee7d11f644e0d6ea42c469a (diff)
downloadcoredns-272ccb195d31cd1622d48f961f3a189ce3abb937.tar.gz
coredns-272ccb195d31cd1622d48f961f3a189ce3abb937.tar.zst
coredns-272ccb195d31cd1622d48f961f3a189ce3abb937.zip
plugin/kubernetes: Watch EndpointSlices (#4209)
* initial commit Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * convert endpointslices to object.endpoints Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * add opt hard coded for now Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * check that server supports endpointslice Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * fix import grouping Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * dont use endpoint slice in 1.17 or 1.18 Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * bump kind/k8s in circle ci to latest Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * drop k8s to latest supported by kind Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * use endpointslice name as endoint Name; index by Service name Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * use index key comparison in nsAddrs() Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * add Index to object.Endpoint fixtures; fix direct endpoint name compares Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * add slice dup check and test Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * todo Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * add ep-slice skew dup test for reverse Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * nsaddrs: de-dup ep-slice skew dups; add test Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * remove todo Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * address various feedback Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * consolidate endpoint/slice informer code Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * fix endpoint informer consolidation; use clearer func name Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * log info; use major/minor fields Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * fix nsAddr and unit test Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * add latency tracking for endpointslices Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * endpointslice latency unit test & fix Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * code shuffling Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * rename endpointslices in tests Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * remove de-dup from nsAddrs and test Signed-off-by: Chris O'Haver <cohaver@infoblox.com> * remove de-dup from findServices / test Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'plugin/kubernetes/kubernetes_test.go')
-rw-r--r--plugin/kubernetes/kubernetes_test.go34
1 files changed, 14 insertions, 20 deletions
diff --git a/plugin/kubernetes/kubernetes_test.go b/plugin/kubernetes/kubernetes_test.go
index eddb7645d..7458a3bdc 100644
--- a/plugin/kubernetes/kubernetes_test.go
+++ b/plugin/kubernetes/kubernetes_test.go
@@ -137,8 +137,9 @@ func (APIConnServiceTest) EpIndex(string) []*object.Endpoints {
},
},
},
- Name: "svc1",
+ Name: "svc1-slice1",
Namespace: "testns",
+ Index: object.EndpointsKey("svc1", "testns"),
},
{
Subsets: []object.EndpointSubset{
@@ -151,22 +152,9 @@ func (APIConnServiceTest) EpIndex(string) []*object.Endpoints {
},
},
},
- Name: "hdls1",
- Namespace: "testns",
- },
- {
- Subsets: []object.EndpointSubset{
- {
- Addresses: []object.EndpointAddress{
- {IP: "172.0.0.3"},
- },
- Ports: []object.EndpointPort{
- {Port: 80, Protocol: "tcp", Name: "http"},
- },
- },
- },
- Name: "hdls1",
+ Name: "hdls1-slice1",
Namespace: "testns",
+ Index: object.EndpointsKey("hdls1", "testns"),
},
{
Subsets: []object.EndpointSubset{
@@ -194,8 +182,9 @@ func (APIConnServiceTest) EndpointsList() []*object.Endpoints {
},
},
},
- Name: "svc1",
+ Name: "svc1-slice1",
Namespace: "testns",
+ Index: object.EndpointsKey("svc1", "testns"),
},
{
Subsets: []object.EndpointSubset{
@@ -208,22 +197,24 @@ func (APIConnServiceTest) EndpointsList() []*object.Endpoints {
},
},
},
- Name: "hdls1",
+ Name: "hdls1-slice1",
Namespace: "testns",
+ Index: object.EndpointsKey("hdls1", "testns"),
},
{
Subsets: []object.EndpointSubset{
{
Addresses: []object.EndpointAddress{
- {IP: "172.0.0.3"},
+ {IP: "172.0.0.2"},
},
Ports: []object.EndpointPort{
{Port: 80, Protocol: "tcp", Name: "http"},
},
},
},
- Name: "hdls1",
+ Name: "hdls1-slice2",
Namespace: "testns",
+ Index: object.EndpointsKey("hdls1", "testns"),
},
{
Subsets: []object.EndpointSubset{
@@ -275,6 +266,9 @@ func TestServices(t *testing.T) {
// External Services
{qname: "external.testns.svc.interwebs.test.", qtype: dns.TypeCNAME, answer: svcAns{host: "coredns.io", key: "/" + coredns + "/test/interwebs/svc/testns/external"}},
+
+ // Headless Services
+ {qname: "hdls1.testns.svc.interwebs.test.", qtype: dns.TypeA, answer: svcAns{host: "172.0.0.2", key: "/" + coredns + "/test/interwebs/svc/testns/hdls1/172-0-0-2"}},
}
for i, test := range tests {