aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Yong Tang <yong.tang.github@outlook.com> 2017-12-05 12:02:37 -0600
committerGravatar Miek Gieben <miek@miek.nl> 2017-12-05 18:02:37 +0000
commit0baab055df5ff263a50132a9e8201b8e25b4d22d (patch)
tree382b5bc1e96d1edd9a919c7d5d91f189c2c2d9eb
parent5bafa6d97f09cab356e6f5dce9ee46e672894372 (diff)
downloadcoredns-0baab055df5ff263a50132a9e8201b8e25b4d22d.tar.gz
coredns-0baab055df5ff263a50132a9e8201b8e25b4d22d.tar.zst
coredns-0baab055df5ff263a50132a9e8201b8e25b4d22d.zip
Update etcd/README.md for multiple endpoints, and add additional test cases (#1277)
This fix tries to address the issue raised in 1275 to clarify the syntax for multiple endpoints specification. This fix also adds additional test cases to demo the usage. This fix fixes 1275. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
-rw-r--r--plugin/etcd/README.md8
-rw-r--r--plugin/etcd/setup_test.go25
2 files changed, 27 insertions, 6 deletions
diff --git a/plugin/etcd/README.md b/plugin/etcd/README.md
index f8e3353ca..7cc396f53 100644
--- a/plugin/etcd/README.md
+++ b/plugin/etcd/README.md
@@ -79,6 +79,14 @@ when resolving external pointing CNAMEs.
}
~~~
+Multiple endpoints are supported as well.
+
+~~~
+etcd skydns.local {
+ endpoint http://localhost:2379 http://localhost:4001
+...
+~~~
+
### Reverse zones
diff --git a/plugin/etcd/setup_test.go b/plugin/etcd/setup_test.go
index 833e2ba4c..517aeea54 100644
--- a/plugin/etcd/setup_test.go
+++ b/plugin/etcd/setup_test.go
@@ -12,25 +12,31 @@ func TestSetupEtcd(t *testing.T) {
input string
shouldErr bool
expectedPath string
- expectedEndpoint string
+ expectedEndpoint []string
expectedErrContent string // substring from the expected error. Empty for positive cases.
}{
// positive
{
- `etcd`, false, "skydns", "http://localhost:2379", "",
+ `etcd`, false, "skydns", []string{"http://localhost:2379"}, "",
+ },
+ {
+ `etcd {
+ endpoint http://localhost:2379 http://localhost:3379 http://localhost:4379
+
+}`, false, "skydns", []string{"http://localhost:2379", "http://localhost:3379", "http://localhost:4379"}, "",
},
{
`etcd skydns.local {
endpoint localhost:300
}
-`, false, "skydns", "localhost:300", "",
+`, false, "skydns", []string{"localhost:300"}, "",
},
// negative
{
`etcd {
endpoints localhost:300
}
-`, true, "", "", "unknown property 'endpoints'",
+`, true, "", []string{""}, "unknown property 'endpoints'",
},
}
@@ -57,8 +63,15 @@ func TestSetupEtcd(t *testing.T) {
if !test.shouldErr && etcd.PathPrefix != test.expectedPath {
t.Errorf("Etcd not correctly set for input %s. Expected: %s, actual: %s", test.input, test.expectedPath, etcd.PathPrefix)
}
- if !test.shouldErr && etcd.endpoints[0] != test.expectedEndpoint { // only checks the first
- t.Errorf("Etcd not correctly set for input %s. Expected: '%s', actual: '%s'", test.input, test.expectedEndpoint, etcd.endpoints[0])
+ if !test.shouldErr {
+ if len(etcd.endpoints) != len(test.expectedEndpoint) {
+ t.Errorf("Etcd not correctly set for input %s. Expected: '%+v', actual: '%+v'", test.input, test.expectedEndpoint, etcd.endpoints)
+ }
+ for i, endpoint := range etcd.endpoints {
+ if endpoint != test.expectedEndpoint[i] {
+ t.Errorf("Etcd not correctly set for input %s. Expected: '%+v', actual: '%+v'", test.input, test.expectedEndpoint, etcd.endpoints)
+ }
+ }
}
}
}