diff options
author | 2018-10-11 21:59:50 +0100 | |
---|---|---|
committer | 2018-10-11 16:59:50 -0400 | |
commit | 6ed88fab744bd3d8cc071153a4c78970798cf9e6 (patch) | |
tree | ab4935e8cb81931b65966ba13829f3f8780b12b3 /plugin/kubernetes/handler_test.go | |
parent | c8fb66f8cc60ff17b916b033982c5491f23cdcc9 (diff) | |
download | coredns-6ed88fab744bd3d8cc071153a4c78970798cf9e6.tar.gz coredns-6ed88fab744bd3d8cc071153a4c78970798cf9e6.tar.zst coredns-6ed88fab744bd3d8cc071153a4c78970798cf9e6.zip |
Revert "use keys (#2167)" (#2188)
This reverts commit 974ed086f25ad45a01947e276e2eb8aa73d007a3.
Diffstat (limited to 'plugin/kubernetes/handler_test.go')
-rw-r--r-- | plugin/kubernetes/handler_test.go | 169 |
1 files changed, 91 insertions, 78 deletions
diff --git a/plugin/kubernetes/handler_test.go b/plugin/kubernetes/handler_test.go index b3353af1b..604f00fab 100644 --- a/plugin/kubernetes/handler_test.go +++ b/plugin/kubernetes/handler_test.go @@ -379,15 +379,15 @@ func TestServeDNS(t *testing.T) { type APIConnServeTest struct{} -func (APIConnServeTest) HasSynced() bool { return true } -func (APIConnServeTest) Run() { return } -func (APIConnServeTest) Stop() error { return nil } -func (APIConnServeTest) EpIndexReverse(string) *object.Endpoints { return nil } -func (APIConnServeTest) SvcIndexReverse(string) *object.Service { return nil } -func (APIConnServeTest) Modified() int64 { return time.Now().Unix() } -func (APIConnServeTest) SetWatchChan(watch.Chan) {} -func (APIConnServeTest) Watch(string) error { return nil } -func (APIConnServeTest) StopWatching(string) {} +func (APIConnServeTest) HasSynced() bool { return true } +func (APIConnServeTest) Run() { return } +func (APIConnServeTest) Stop() error { return nil } +func (APIConnServeTest) EpIndexReverse(string) []*object.Endpoints { return nil } +func (APIConnServeTest) SvcIndexReverse(string) []*object.Service { return nil } +func (APIConnServeTest) Modified() int64 { return time.Now().Unix() } +func (APIConnServeTest) SetWatchChan(watch.Chan) {} +func (APIConnServeTest) Watch(string) error { return nil } +func (APIConnServeTest) StopWatching(string) {} func (APIConnServeTest) PodIndex(string) []*object.Pod { a := []*object.Pod{ @@ -396,90 +396,103 @@ func (APIConnServeTest) PodIndex(string) []*object.Pod { return a } -var svcIndex = map[string]*object.Service{ - "testns/svc1": { - Name: "svc1", - Namespace: "testns", - Type: api.ServiceTypeClusterIP, - ClusterIP: "10.0.0.1", - Ports: []api.ServicePort{ - {Name: "http", Protocol: "tcp", Port: 80}, +var svcIndex = map[string][]*object.Service{ + "svc1.testns": { + { + Name: "svc1", + Namespace: "testns", + Type: api.ServiceTypeClusterIP, + ClusterIP: "10.0.0.1", + Ports: []api.ServicePort{ + {Name: "http", Protocol: "tcp", Port: 80}, + }, }, }, - "testns/svcempty": { - Name: "svcempty", - Namespace: "testns", - Type: api.ServiceTypeClusterIP, - ClusterIP: "10.0.0.1", - Ports: []api.ServicePort{ - {Name: "http", Protocol: "tcp", Port: 80}, + "svcempty.testns": { + { + Name: "svcempty", + Namespace: "testns", + Type: api.ServiceTypeClusterIP, + ClusterIP: "10.0.0.1", + Ports: []api.ServicePort{ + {Name: "http", Protocol: "tcp", Port: 80}, + }, }, }, - "testns/svc6": { - Name: "svc6", - Namespace: "testns", - Type: api.ServiceTypeClusterIP, - ClusterIP: "1234:abcd::1", - Ports: []api.ServicePort{ - {Name: "http", Protocol: "tcp", Port: 80}, + "svc6.testns": { + { + Name: "svc6", + Namespace: "testns", + Type: api.ServiceTypeClusterIP, + ClusterIP: "1234:abcd::1", + Ports: []api.ServicePort{ + {Name: "http", Protocol: "tcp", Port: 80}, + }, }, }, - "testns/hdls1": { - Name: "hdls1", - Namespace: "testns", - Type: api.ServiceTypeClusterIP, - ClusterIP: api.ClusterIPNone, + "hdls1.testns": { + { + Name: "hdls1", + Namespace: "testns", + Type: api.ServiceTypeClusterIP, + ClusterIP: api.ClusterIPNone, + }, }, - "testns/external": { - - Name: "external", - Namespace: "testns", - ExternalName: "ext.interwebs.test", - Type: api.ServiceTypeExternalName, - Ports: []api.ServicePort{ - {Name: "http", Protocol: "tcp", Port: 80}, + "external.testns": { + { + Name: "external", + Namespace: "testns", + ExternalName: "ext.interwebs.test", + Type: api.ServiceTypeExternalName, + Ports: []api.ServicePort{ + {Name: "http", Protocol: "tcp", Port: 80}, + }, }, }, - "testns/external-to-service": { - Name: "external-to-service", - Namespace: "testns", - ExternalName: "svc1.testns.svc.cluster.local.", - Type: api.ServiceTypeExternalName, - Ports: []api.ServicePort{ - {Name: "http", Protocol: "tcp", Port: 80}, + "external-to-service.testns": { + { + Name: "external-to-service", + Namespace: "testns", + ExternalName: "svc1.testns.svc.cluster.local.", + Type: api.ServiceTypeExternalName, + Ports: []api.ServicePort{ + {Name: "http", Protocol: "tcp", Port: 80}, + }, }, }, - "testns/hdlsprtls": { - Name: "hdlsprtls", - Namespace: "testns", - Type: api.ServiceTypeClusterIP, - ClusterIP: api.ClusterIPNone, + "hdlsprtls.testns": { + { + Name: "hdlsprtls", + Namespace: "testns", + Type: api.ServiceTypeClusterIP, + ClusterIP: api.ClusterIPNone, + }, }, - "unexposedns/svc1": { - Name: "svc1", - Namespace: "unexposedns", - Type: api.ServiceTypeClusterIP, - ClusterIP: "10.0.0.2", - Ports: []api.ServicePort{ - {Name: "http", Protocol: "tcp", Port: 80}, + "svc1.unexposedns": { + { + Name: "svc1", + Namespace: "unexposedns", + Type: api.ServiceTypeClusterIP, + ClusterIP: "10.0.0.2", + Ports: []api.ServicePort{ + {Name: "http", Protocol: "tcp", Port: 80}, + }, }, }, } -func (APIConnServeTest) SvcIndex(s string) *object.Service { - return svcIndex[s] -} +func (APIConnServeTest) SvcIndex(s string) []*object.Service { return svcIndex[s] } func (APIConnServeTest) ServiceList() []*object.Service { var svcs []*object.Service for _, svc := range svcIndex { - svcs = append(svcs, svc) + svcs = append(svcs, svc...) } return svcs } -var epsIndex = map[string]*object.Endpoints{ - "testns/svc1": { +var epsIndex = map[string][]*object.Endpoints{ + "svc1.testns": {{ Subsets: []object.EndpointSubset{ { Addresses: []object.EndpointAddress{ @@ -492,8 +505,8 @@ var epsIndex = map[string]*object.Endpoints{ }, Name: "svc1", Namespace: "testns", - }, - "testns/svcempty": { + }}, + "svcempty.testns": {{ Subsets: []object.EndpointSubset{ { Addresses: nil, @@ -504,8 +517,8 @@ var epsIndex = map[string]*object.Endpoints{ }, Name: "svcempty", Namespace: "testns", - }, - "testns/hdls1": { + }}, + "hdls1.testns": {{ Subsets: []object.EndpointSubset{ { Addresses: []object.EndpointAddress{ @@ -523,8 +536,8 @@ var epsIndex = map[string]*object.Endpoints{ }, Name: "hdls1", Namespace: "testns", - }, - "testns/hdlsprtls": { + }}, + "hdlsprtls.testns": {{ Subsets: []object.EndpointSubset{ { Addresses: []object.EndpointAddress{ @@ -535,17 +548,17 @@ var epsIndex = map[string]*object.Endpoints{ }, Name: "hdlsprtls", Namespace: "testns", - }, + }}, } -func (APIConnServeTest) EpIndex(s string) *object.Endpoints { +func (APIConnServeTest) EpIndex(s string) []*object.Endpoints { return epsIndex[s] } func (APIConnServeTest) EndpointsList() []*object.Endpoints { var eps []*object.Endpoints for _, ep := range epsIndex { - eps = append(eps, ep) + eps = append(eps, ep...) } return eps } |