Merge "veyron2/context: Remove the runtime from the context. It is no longer used."
diff --git a/runtimes/google/ipc/full_test.go b/runtimes/google/ipc/full_test.go
index 7000830..cbb9a69 100644
--- a/runtimes/google/ipc/full_test.go
+++ b/runtimes/google/ipc/full_test.go
@@ -39,7 +39,6 @@
"v.io/core/veyron/runtimes/google/lib/publisher"
inaming "v.io/core/veyron/runtimes/google/naming"
tnaming "v.io/core/veyron/runtimes/google/testing/mocks/naming"
- truntime "v.io/core/veyron/runtimes/google/testing/mocks/runtime"
ivtrace "v.io/core/veyron/runtimes/google/vtrace"
)
@@ -89,7 +88,7 @@
}
func testContextWithoutDeadline() *context.T {
- ctx := context.NewUninitializedContext(&truntime.PanicRuntime{})
+ var ctx *context.T
ctx = ivtrace.Init(ctx, flags.VtraceFlags{})
ctx, _ = vtrace.SetNewTrace(ctx)
return ctx
diff --git a/runtimes/google/lib/publisher/publisher_test.go b/runtimes/google/lib/publisher/publisher_test.go
index 15f4655..fadbf29 100644
--- a/runtimes/google/lib/publisher/publisher_test.go
+++ b/runtimes/google/lib/publisher/publisher_test.go
@@ -13,12 +13,11 @@
"v.io/core/veyron/lib/flags"
"v.io/core/veyron/runtimes/google/lib/publisher"
tnaming "v.io/core/veyron/runtimes/google/testing/mocks/naming"
- "v.io/core/veyron/runtimes/google/testing/mocks/runtime"
ivtrace "v.io/core/veyron/runtimes/google/vtrace"
)
func testContext() *context.T {
- ctx := context.NewUninitializedContext(&runtime.PanicRuntime{})
+ var ctx *context.T
ctx = ivtrace.Init(ctx, flags.VtraceFlags{})
ctx, _ = vtrace.SetNewSpan(ctx, "")
ctx, _ = context.WithDeadline(ctx, time.Now().Add(20*time.Second))
diff --git a/runtimes/google/rt/ipc.go b/runtimes/google/rt/ipc.go
index c7ac058..94771ea 100644
--- a/runtimes/google/rt/ipc.go
+++ b/runtimes/google/rt/ipc.go
@@ -44,7 +44,7 @@
}
func (rt *vrt) NewContext() *context.T {
- ctx := context.NewUninitializedContext(rt)
+ var ctx *context.T
ctx = i18n.ContextWithLangID(ctx, rt.lang)
ctx = verror2.ContextWithComponentName(ctx, rt.program)
ctx = ivtrace.DeprecatedInit(ctx, rt.traceStore)
diff --git a/runtimes/google/testing/mocks/ipc/simple_client_test.go b/runtimes/google/testing/mocks/ipc/simple_client_test.go
index 2ef7ba5..0cf23e6 100644
--- a/runtimes/google/testing/mocks/ipc/simple_client_test.go
+++ b/runtimes/google/testing/mocks/ipc/simple_client_test.go
@@ -4,10 +4,16 @@
"testing"
"v.io/core/veyron2/context"
-
- "v.io/core/veyron/runtimes/google/testing/mocks/runtime"
)
+func testContext() *context.T {
+ // The nil context is not directly usable, we need to create
+ // a context specially.
+ type key struct{}
+ var ctx *context.T
+ return context.WithValue(ctx, key{}, nil)
+}
+
func TestSuccessfulCalls(t *testing.T) {
method1ExpectedResult := []interface{}{"one", 2}
@@ -20,7 +26,7 @@
"method3": method3ExpectedResult,
})
- ctx := context.NewUninitializedContext(&runtime.PanicRuntime{})
+ ctx := testContext()
// method1
method1Call, err := client.StartCall(ctx, "name/obj", "method1", []interface{}{})
@@ -76,7 +82,7 @@
sampleStruct{name: "bar"},
},
})
- ctx := context.NewUninitializedContext(&runtime.PanicRuntime{})
+ ctx := testContext()
call, _ := client.StartCall(ctx, "name/obj", "foo", []interface{}{})
var result sampleStruct
call.Finish(&result)
@@ -90,7 +96,7 @@
client := NewSimpleClient(map[string][]interface{}{
"bar": []interface{}{},
})
- ctx := context.NewUninitializedContext(&runtime.PanicRuntime{})
+ ctx := testContext()
_, err := client.StartCall(ctx, "name/obj", "wrongMethodName", []interface{}{})
if err == nil {
t.Errorf(`StartCall: should have returned an error on invalid method name`)
@@ -105,7 +111,7 @@
})
errMsg := "Expected method to be called %d times but it was called %d"
- ctx := context.NewUninitializedContext(&runtime.PanicRuntime{})
+ ctx := testContext()
// method 1
if n := client.TimesCalled("method1"); n != 0 {
diff --git a/runtimes/google/testing/mocks/runtime/panic_runtime.go b/runtimes/google/testing/mocks/runtime/panic_runtime.go
deleted file mode 100644
index 03a6ec9..0000000
--- a/runtimes/google/testing/mocks/runtime/panic_runtime.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package runtime
-
-import (
- "v.io/core/veyron2"
- "v.io/core/veyron2/config"
- "v.io/core/veyron2/context"
- "v.io/core/veyron2/ipc"
- "v.io/core/veyron2/ipc/stream"
- "v.io/core/veyron2/naming"
- "v.io/core/veyron2/security"
- "v.io/core/veyron2/uniqueid"
- "v.io/core/veyron2/vlog"
- "v.io/core/veyron2/vtrace"
-)
-
-// PanicRuntime is a dummy implementation of veyron2.Runtime that panics on every
-// operation. This is useful when you want to pass around a non-nil runtime
-// implementation but you don't want it to be used.
-type PanicRuntime struct {
- unique int // Make non-empty to ensure pointer instances are unique.
-
-}
-
-const badRuntime = "The runtime implmentation should not call methods on runtime intances."
-
-func (*PanicRuntime) Profile() veyron2.Profile { panic(badRuntime) }
-func (*PanicRuntime) AppCycle() veyron2.AppCycle { panic(badRuntime) }
-func (*PanicRuntime) Publisher() *config.Publisher { panic(badRuntime) }
-func (*PanicRuntime) Principal() security.Principal { panic(badRuntime) }
-func (*PanicRuntime) NewClient(opts ...ipc.ClientOpt) (ipc.Client, error) { panic(badRuntime) }
-func (*PanicRuntime) NewServer(opts ...ipc.ServerOpt) (ipc.Server, error) { panic(badRuntime) }
-func (*PanicRuntime) Client() ipc.Client { panic(badRuntime) }
-func (*PanicRuntime) NewContext() *context.T { panic(badRuntime) }
-
-func (PanicRuntime) SetNewSpan(c *context.T, m string) (*context.T, vtrace.Span) { return c, &span{m} }
-
-func (*PanicRuntime) SpanFromContext(*context.T) vtrace.Span { return &span{} }
-func (*PanicRuntime) NewStreamManager(opts ...stream.ManagerOpt) (stream.Manager, error) {
- panic(badRuntime)
-}
-func (*PanicRuntime) NewEndpoint(ep string) (naming.Endpoint, error) { panic(badRuntime) }
-func (*PanicRuntime) Namespace() naming.Namespace { panic(badRuntime) }
-func (*PanicRuntime) Logger() vlog.Logger { panic(badRuntime) }
-func (*PanicRuntime) NewLogger(name string, opts ...vlog.LoggingOpts) (vlog.Logger, error) {
- panic(badRuntime)
-}
-func (*PanicRuntime) ConfigureReservedName(ipc.Dispatcher, ...ipc.ServerOpt) {
- panic(badRuntime)
-}
-func (*PanicRuntime) VtraceStore() vtrace.Store { panic(badRuntime) }
-func (*PanicRuntime) Cleanup() { panic(badRuntime) }
-
-type span struct{ m string }
-
-func (s *span) Name() string { return s.m + ".panic" }
-func (*span) ID() uniqueid.ID { return uniqueid.ID{} }
-func (s *span) Parent() uniqueid.ID { return s.ID() }
-func (*span) Annotate(string) {}
-func (*span) Annotatef(string, ...interface{}) {}
-func (*span) Finish() {}
-func (*span) Trace() uniqueid.ID { return uniqueid.ID{} }
-func (*span) ForceCollect() {}
diff --git a/runtimes/google/vtrace/vtrace_test.go b/runtimes/google/vtrace/vtrace_test.go
index f8da2f5..659ed1f 100644
--- a/runtimes/google/vtrace/vtrace_test.go
+++ b/runtimes/google/vtrace/vtrace_test.go
@@ -18,7 +18,6 @@
iipc "v.io/core/veyron/runtimes/google/ipc"
"v.io/core/veyron/runtimes/google/ipc/stream/manager"
tnaming "v.io/core/veyron/runtimes/google/testing/mocks/naming"
- truntime "v.io/core/veyron/runtimes/google/testing/mocks/runtime"
ivtrace "v.io/core/veyron/runtimes/google/vtrace"
)
@@ -27,9 +26,8 @@
// so we use a fake one that panics if used. The runtime
// implementation should not ever use the Runtime from a context.
func testContext() *context.T {
- ctx := context.NewUninitializedContext(&truntime.PanicRuntime{})
- ctx = ivtrace.Init(ctx, flags.VtraceFlags{CacheSize: 100})
- return ctx
+ var ctx *context.T
+ return ivtrace.Init(ctx, flags.VtraceFlags{CacheSize: 100})
}
func TestNewFromContext(t *testing.T) {