Fix stubzone retention (#198)
Make the receiver a pointer so that the uptdateStubZones map update will retain the stubzones found, unlike the current case where the update will be applied and then promptly forgotten, because it is working on a copy. Add test/etcd_test.go to test a large part of the code. This didn't catch the chaos middleware hack though. The chaos middleware zones are now *not* automatically added. You have to take care of that by yourself (docs updates). When using debug queries and falling through to the next middleware in etcd, restore the original (with o-o.debug) query before passing it on.
This commit is contained in:
parent
c079de65b5
commit
ad76aef5fc
18 changed files with 210 additions and 104 deletions
|
@ -20,7 +20,7 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
etc Etcd
|
||||
etc *Etcd
|
||||
client etcdc.KeysAPI
|
||||
ctxt context.Context
|
||||
)
|
||||
|
@ -32,7 +32,7 @@ func init() {
|
|||
Endpoints: []string{"http://localhost:2379"},
|
||||
}
|
||||
cli, _ := etcdc.New(etcdCfg)
|
||||
etc = Etcd{
|
||||
etc = &Etcd{
|
||||
Proxy: proxy.New([]string{"8.8.8.8:53"}),
|
||||
PathPrefix: "skydns",
|
||||
Ctx: context.Background(),
|
||||
|
@ -42,7 +42,7 @@ func init() {
|
|||
}
|
||||
}
|
||||
|
||||
func set(t *testing.T, e Etcd, k string, ttl time.Duration, m *msg.Service) {
|
||||
func set(t *testing.T, e *Etcd, k string, ttl time.Duration, m *msg.Service) {
|
||||
b, err := json.Marshal(m)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -51,7 +51,7 @@ func set(t *testing.T, e Etcd, k string, ttl time.Duration, m *msg.Service) {
|
|||
e.Client.Set(ctxt, path, string(b), &etcdc.SetOptions{TTL: ttl})
|
||||
}
|
||||
|
||||
func delete(t *testing.T, e Etcd, k string) {
|
||||
func delete(t *testing.T, e *Etcd, k string) {
|
||||
path, _ := msg.PathWithWildcard(k, e.PathPrefix)
|
||||
e.Client.Delete(ctxt, path, &etcdc.DeleteOptions{Recursive: false})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue