aboutsummaryrefslogtreecommitdiff
path: root/plugin/kubernetes/kubernetes_test.go
diff options
context:
space:
mode:
authorGravatar Brian Akins <brian@akins.org> 2017-11-08 08:07:10 -0500
committerGravatar John Belamaric <jbelamaric@infoblox.com> 2017-11-08 08:07:10 -0500
commit3527be6c0056acbcd8dc9848ff96be2136c68ed5 (patch)
treecb03011fb882955cf67c726d6c3cc78f84451968 /plugin/kubernetes/kubernetes_test.go
parentc6ce769fc64f00d1fd0d34914a9bb5f4de2f7c2c (diff)
downloadcoredns-3527be6c0056acbcd8dc9848ff96be2136c68ed5.tar.gz
coredns-3527be6c0056acbcd8dc9848ff96be2136c68ed5.tar.zst
coredns-3527be6c0056acbcd8dc9848ff96be2136c68ed5.zip
Add option to use pod name rather than IP address for Kubernetes (#1190)
Change to use a new 'endpoints' directive and use a constant Add initial docs for 'endpoints' directive Add tests to Kubernetes setup for endpoints Changes based on PR feedback endpoint_pod_names is a boolean config option. Chahanged docs to reflect this. Add a test when endpoints_pod_names is not set Update README.md Remove endpointNameModeName as it is no longer used
Diffstat (limited to 'plugin/kubernetes/kubernetes_test.go')
-rw-r--r--plugin/kubernetes/kubernetes_test.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/plugin/kubernetes/kubernetes_test.go b/plugin/kubernetes/kubernetes_test.go
index ae0bb13e5..de8c3f025 100644
--- a/plugin/kubernetes/kubernetes_test.go
+++ b/plugin/kubernetes/kubernetes_test.go
@@ -34,15 +34,21 @@ func TestWildcard(t *testing.T) {
func TestEndpointHostname(t *testing.T) {
var tests = []struct {
- ip string
- hostname string
- expected string
+ ip string
+ hostname string
+ expected string
+ podName string
+ endpointNameMode bool
}{
- {"10.11.12.13", "", "10-11-12-13"},
- {"10.11.12.13", "epname", "epname"},
+ {"10.11.12.13", "", "10-11-12-13", "", false},
+ {"10.11.12.13", "epname", "epname", "", false},
+ {"10.11.12.13", "", "10-11-12-13", "hello-abcde", false},
+ {"10.11.12.13", "epname", "epname", "hello-abcde", false},
+ {"10.11.12.13", "epname", "epname", "hello-abcde", true},
+ {"10.11.12.13", "", "hello-abcde", "hello-abcde", true},
}
for _, test := range tests {
- result := endpointHostname(api.EndpointAddress{IP: test.ip, Hostname: test.hostname})
+ result := endpointHostname(api.EndpointAddress{IP: test.ip, Hostname: test.hostname, TargetRef: &api.ObjectReference{Name: test.podName}}, test.endpointNameMode)
if result != test.expected {
t.Errorf("Expected endpoint name for (ip:%v hostname:%v) to be '%v', but got '%v'", test.ip, test.hostname, test.expected, result)
}