aboutsummaryrefslogtreecommitdiff
path: root/plugin/etcd
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/etcd')
-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)
+ }
+ }
}
}
}