diff options
author | 2017-06-03 03:27:24 -0400 | |
---|---|---|
committer | 2017-06-03 08:27:24 +0100 | |
commit | 18bc52b5e0fafd1b571af8b92f02c047fc4b91f4 (patch) | |
tree | c5963af1983d03f42cdcdd7d928017d2ea3bb8e1 /middleware/kubernetes | |
parent | 6d52827a8ae37d153299d7c570e1e9ddf26f2256 (diff) | |
download | coredns-18bc52b5e0fafd1b571af8b92f02c047fc4b91f4.tar.gz coredns-18bc52b5e0fafd1b571af8b92f02c047fc4b91f4.tar.zst coredns-18bc52b5e0fafd1b571af8b92f02c047fc4b91f4.zip |
add more coverage (#702)
Diffstat (limited to 'middleware/kubernetes')
-rw-r--r-- | middleware/kubernetes/kubernetes_test.go | 98 |
1 files changed, 97 insertions, 1 deletions
diff --git a/middleware/kubernetes/kubernetes_test.go b/middleware/kubernetes/kubernetes_test.go index f0b434cc6..8e2cb7547 100644 --- a/middleware/kubernetes/kubernetes_test.go +++ b/middleware/kubernetes/kubernetes_test.go @@ -294,6 +294,29 @@ func (APIConnServiceTest) ServiceList() []*api.Service { svcs := []*api.Service{ { ObjectMeta: api.ObjectMeta{ + Name: "svc1", + Namespace: "testns", + }, + Spec: api.ServiceSpec{ + ClusterIP: "10.0.0.1", + Ports: []api.ServicePort{{ + Name: "http", + Protocol: "tcp", + Port: 80, + }}, + }, + }, + { + ObjectMeta: api.ObjectMeta{ + Name: "hdls1", + Namespace: "testns", + }, + Spec: api.ServiceSpec{ + ClusterIP: api.ClusterIPNone, + }, + }, + { + ObjectMeta: api.ObjectMeta{ Name: "external", Namespace: "testns", }, @@ -316,7 +339,76 @@ func (APIConnServiceTest) PodIndex(string) []interface{} { } func (APIConnServiceTest) EndpointsList() api.EndpointsList { - return api.EndpointsList{} + return api.EndpointsList{ + Items: []api.Endpoints{ + { + Subsets: []api.EndpointSubset{ + { + Addresses: []api.EndpointAddress{ + { + IP: "172.0.0.1", + }, + }, + Ports: []api.EndpointPort{ + { + Port: 80, + Protocol: "tcp", + Name: "http", + }, + }, + }, + }, + ObjectMeta: api.ObjectMeta{ + Name: "svc1", + Namespace: "testns", + }, + }, + { + Subsets: []api.EndpointSubset{ + { + Addresses: []api.EndpointAddress{ + { + IP: "172.0.0.2", + }, + }, + Ports: []api.EndpointPort{ + { + Port: 80, + Protocol: "tcp", + Name: "http", + }, + }, + }, + }, + ObjectMeta: api.ObjectMeta{ + Name: "hdls1", + Namespace: "testns", + }, + }, + { + Subsets: []api.EndpointSubset{ + { + Addresses: []api.EndpointAddress{ + { + IP: "172.0.0.3", + }, + }, + Ports: []api.EndpointPort{ + { + Port: 80, + Protocol: "tcp", + Name: "http", + }, + }, + }, + }, + ObjectMeta: api.ObjectMeta{ + Name: "hdls1", + Namespace: "testns", + }, + }, + }, + } } func TestServices(t *testing.T) { @@ -334,6 +426,10 @@ func TestServices(t *testing.T) { answer svcAns } tests := []svcTest{ + // Cluster IP Services + {qname: "svc1.testns.svc.interwebs.test.", qtype: dns.TypeA, answer: svcAns{host: "10.0.0.1", key: "/coredns/test/interwebs/svc/testns/svc1"}}, + {qname: "_http._tcp.svc1.testns.svc.interwebs.test.", qtype: dns.TypeSRV, answer: svcAns{host: "10.0.0.1", key: "/coredns/test/interwebs/svc/testns/svc1"}}, + // External Services {qname: "external.testns.svc.interwebs.test.", qtype: dns.TypeCNAME, answer: svcAns{host: "coredns.io", key: "/coredns/test/interwebs/svc/testns/external"}}, } |