aboutsummaryrefslogtreecommitdiff
path: root/plugin/kubernetes/kubernetes_test.go
diff options
context:
space:
mode:
authorGravatar Sandeep Rajan <srajan@infoblox.com> 2017-10-17 21:30:54 -0400
committerGravatar John Belamaric <jbelamaric@infoblox.com> 2017-10-17 21:30:54 -0400
commitb6b05eae8f3d1c1413b0308bc8e9285ec0423a96 (patch)
treeddb3f0e3ad99827012306ee09f316b3ffd23581d /plugin/kubernetes/kubernetes_test.go
parent0c63248a0eb927affeef701150e818ad92eac808 (diff)
downloadcoredns-b6b05eae8f3d1c1413b0308bc8e9285ec0423a96.tar.gz
coredns-b6b05eae8f3d1c1413b0308bc8e9285ec0423a96.tar.zst
coredns-b6b05eae8f3d1c1413b0308bc8e9285ec0423a96.zip
Plugin/Kubernetes: Service and Endpoint Indexing (#1149)
* indexing * corrections
Diffstat (limited to 'plugin/kubernetes/kubernetes_test.go')
-rw-r--r--plugin/kubernetes/kubernetes_test.go138
1 files changed, 135 insertions, 3 deletions
diff --git a/plugin/kubernetes/kubernetes_test.go b/plugin/kubernetes/kubernetes_test.go
index 4a3bb3d07..fecc7c396 100644
--- a/plugin/kubernetes/kubernetes_test.go
+++ b/plugin/kubernetes/kubernetes_test.go
@@ -51,9 +51,54 @@ func TestEndpointHostname(t *testing.T) {
type APIConnServiceTest struct{}
-func (APIConnServiceTest) Run() { return }
-func (APIConnServiceTest) Stop() error { return nil }
-func (APIConnServiceTest) PodIndex(string) []*api.Pod { return nil }
+func (APIConnServiceTest) Run() { return }
+func (APIConnServiceTest) Stop() error { return nil }
+func (APIConnServiceTest) PodIndex(string) []*api.Pod { return nil }
+func (APIConnServiceTest) SvcIndexReverse(string) []*api.Service { return nil }
+func (APIConnServiceTest) EpIndexReverse(string) []*api.Endpoints { return nil }
+
+func (APIConnServiceTest) SvcIndex(string) []*api.Service {
+ svcs := []*api.Service{
+ {
+ ObjectMeta: meta.ObjectMeta{
+ Name: "svc1",
+ Namespace: "testns",
+ },
+ Spec: api.ServiceSpec{
+ ClusterIP: "10.0.0.1",
+ Ports: []api.ServicePort{{
+ Name: "http",
+ Protocol: "tcp",
+ Port: 80,
+ }},
+ },
+ },
+ {
+ ObjectMeta: meta.ObjectMeta{
+ Name: "hdls1",
+ Namespace: "testns",
+ },
+ Spec: api.ServiceSpec{
+ ClusterIP: api.ClusterIPNone,
+ },
+ },
+ {
+ ObjectMeta: meta.ObjectMeta{
+ Name: "external",
+ Namespace: "testns",
+ },
+ Spec: api.ServiceSpec{
+ ExternalName: "coredns.io",
+ Ports: []api.ServicePort{{
+ Name: "http",
+ Protocol: "tcp",
+ Port: 80,
+ }},
+ },
+ },
+ }
+ return svcs
+}
func (APIConnServiceTest) ServiceList() []*api.Service {
svcs := []*api.Service{
@@ -98,6 +143,93 @@ func (APIConnServiceTest) ServiceList() []*api.Service {
return svcs
}
+func (APIConnServiceTest) EpIndex(string) []*api.Endpoints {
+ n := "test.node.foo.bar"
+
+ eps := []*api.Endpoints{
+ {
+ Subsets: []api.EndpointSubset{
+ {
+ Addresses: []api.EndpointAddress{
+ {
+ IP: "172.0.0.1",
+ Hostname: "ep1a",
+ },
+ },
+ Ports: []api.EndpointPort{
+ {
+ Port: 80,
+ Protocol: "tcp",
+ Name: "http",
+ },
+ },
+ },
+ },
+ ObjectMeta: meta.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: meta.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: meta.ObjectMeta{
+ Name: "hdls1",
+ Namespace: "testns",
+ },
+ },
+ {
+ Subsets: []api.EndpointSubset{
+ {
+ Addresses: []api.EndpointAddress{
+ {
+ IP: "10.9.8.7",
+ NodeName: &n,
+ },
+ },
+ },
+ },
+ },
+ }
+ return eps
+}
+
func (APIConnServiceTest) EndpointsList() []*api.Endpoints {
n := "test.node.foo.bar"