veyron/runtimes/google/rt: Preserve namespace cache settings across recreations.
Change-Id: I1d4057e356db200d0469a986a41c991c9ece02b2
diff --git a/runtimes/google/rt/runtime.go b/runtimes/google/rt/runtime.go
index fceb78e..8820293 100644
--- a/runtimes/google/rt/runtime.go
+++ b/runtimes/google/rt/runtime.go
@@ -341,9 +341,13 @@
return cl
}
-func (*Runtime) setNewNamespace(ctx *context.T, roots ...string) (*context.T, naming.Namespace, error) {
+func (r *Runtime) setNewNamespace(ctx *context.T, roots ...string) (*context.T, naming.Namespace, error) {
ns, err := namespace.New(roots...)
- // TODO(mattr): Copy cache settings.
+
+ if oldNS := r.GetNamespace(ctx); oldNS != nil {
+ ns.CacheCtl(oldNS.CacheCtl()...)
+ }
+
if err == nil {
ctx = context.WithValue(ctx, namespaceKey, ns)
}
diff --git a/runtimes/google/rt/runtime_test.go b/runtimes/google/rt/runtime_test.go
index 4f41e20..905bbf8 100644
--- a/runtimes/google/rt/runtime_test.go
+++ b/runtimes/google/rt/runtime_test.go
@@ -5,6 +5,7 @@
"v.io/core/veyron2"
"v.io/core/veyron2/context"
+ "v.io/core/veyron2/naming"
"v.io/core/veyron/lib/flags"
tsecurity "v.io/core/veyron/lib/testutil/security"
@@ -104,6 +105,7 @@
defer shutdown()
orig := r.GetNamespace(ctx)
+ orig.CacheCtl(naming.DisableCache(true))
newroots := []string{"/newroot1", "/newroot2"}
c2, ns, err := r.SetNewNamespace(ctx, newroots...)
@@ -125,6 +127,13 @@
t.Errorf("root %s found in ns, but we expected: %v", root, newroots)
}
}
+ opts := ns.CacheCtl()
+ if len(opts) != 1 {
+ t.Fatalf("Expected one option for cache control, got %v", opts)
+ }
+ if disable, ok := opts[0].(naming.DisableCache); !ok || !bool(disable) {
+ t.Errorf("expected a disable(true) message got %#v", opts[0])
+ }
}
func TestBackgroundContext(t *testing.T) {