Merge "core: Make cmdline.Command.Main return an exit code instead of exiting."
diff --git a/lib/exec/config.go b/lib/exec/config.go
index 52c622f..71fffd5 100644
--- a/lib/exec/config.go
+++ b/lib/exec/config.go
@@ -1,12 +1,10 @@
package exec
import (
- "bytes"
- "strings"
"sync"
"v.io/core/veyron2/verror2"
- "v.io/core/veyron2/vom"
+ "v.io/core/veyron2/vom2"
)
// Config defines a simple key-value configuration. Keys and values are
@@ -52,13 +50,13 @@
return &cfg{m: make(map[string]string)}
}
-func (c cfg) Set(key, value string) {
+func (c *cfg) Set(key, value string) {
c.Lock()
defer c.Unlock()
c.m[key] = value
}
-func (c cfg) Get(key string) (string, error) {
+func (c *cfg) Get(key string) (string, error) {
c.RLock()
defer c.RUnlock()
v, ok := c.m[key]
@@ -68,7 +66,7 @@
return v, nil
}
-func (c cfg) Dump() (res map[string]string) {
+func (c *cfg) Dump() (res map[string]string) {
res = make(map[string]string)
c.RLock()
defer c.RUnlock()
@@ -78,31 +76,31 @@
return
}
-func (c cfg) Clear(key string) {
+func (c *cfg) Clear(key string) {
c.Lock()
defer c.Unlock()
delete(c.m, key)
}
-func (c cfg) Serialize() (string, error) {
- var buf bytes.Buffer
+func (c *cfg) Serialize() (string, error) {
c.RLock()
- defer c.RUnlock()
- if err := vom.NewEncoder(&buf).Encode(c.m); err != nil {
+ data, err := vom2.Encode(c.m)
+ c.RUnlock()
+ if err != nil {
return "", err
}
- return buf.String(), nil
+ return string(data), nil
}
-func (c cfg) MergeFrom(serialized string) error {
+func (c *cfg) MergeFrom(serialized string) error {
var newM map[string]string
- if err := vom.NewDecoder(strings.NewReader(serialized)).Decode(&newM); err != nil {
+ if err := vom2.Decode([]byte(serialized), &newM); err != nil {
return err
}
c.Lock()
- defer c.Unlock()
for k, v := range newM {
c.m[k] = v
}
+ c.Unlock()
return nil
}
diff --git a/lib/exec/exec_test.go b/lib/exec/exec_test.go
index c4e546e..90e5bff 100644
--- a/lib/exec/exec_test.go
+++ b/lib/exec/exec_test.go
@@ -8,6 +8,7 @@
"os/exec"
"strings"
"sync"
+ "syscall"
"testing"
"time"
@@ -19,14 +20,22 @@
// We always expect there to be exactly three open file descriptors
// when the test starts out: STDIN, STDOUT, and STDERR. This
// assumption is tested in init below, and in the rare cases where it
-// is wrong, we bail out.
+// is wrong, we try to close all additional file descriptors, and bail
+// out if that fails.
const baselineOpenFiles = 3
func init() {
if os.Getenv("GO_WANT_HELPER_PROCESS_EXEC") == "1" {
return
}
- if want, got := baselineOpenFiles, openFiles(); want != got {
+ want, got := baselineOpenFiles, openFiles()
+ if want == got {
+ return
+ }
+ for i := want; i < got; i++ {
+ syscall.Close(i)
+ }
+ if want, got = baselineOpenFiles, openFiles(); want != got {
message := `Test expected to start with %d open files, found %d instead.
This can happen if parent process has any open file descriptors,
e.g. pipes, that are being inherited.`
diff --git a/lib/testutil/init.go b/lib/testutil/init.go
index c2777d7..dbc7a18 100644
--- a/lib/testutil/init.go
+++ b/lib/testutil/init.go
@@ -87,3 +87,10 @@
}
once.Do(init)
}
+
+// UnsetPrincipalEnvVars unsets all environment variables pertaining to principal
+// initialization.
+func UnsetPrincipalEnvVars() {
+ os.Setenv("VEYRON_CREDENTIALS", "")
+ os.Setenv("VEYRON_AGENT_FD", "")
+}
diff --git a/lib/testutil/integration/util.go b/lib/testutil/integration/util.go
index 4f7eb6f..61de99d 100644
--- a/lib/testutil/integration/util.go
+++ b/lib/testutil/integration/util.go
@@ -1,3 +1,24 @@
+// This package provides support for writing end-to-end style tests. The
+// TestEnvironment type is the root of the API, you can use this type to set up
+// your test environment and to perform operations within the environment. To
+// create a new test environment, use the NewTestEnvironment method, e.g.
+//
+// func TestFoo(t *testing.T) {
+// env := integration.NewTestEnvironment(t)
+// defer env.Cleanup()
+//
+// ...
+// }
+//
+// The methods in this API typically do not return error in the case of
+// failure. Instead, the current test will fail with an appropriate error
+// message. This alleviates the need to handle errors in the test itself.
+//
+// End-to-end style tests may involve several communicating processes. These
+// kinds of tests can be hard to debug using Go alone. The TestEnvironment
+// interface provides a DebugShell() to assist in test debugging. This method
+// will pause the current test and spawn a new shell that can be used to
+// manually inspect and interact with the test environment.
package integration
import (
@@ -362,6 +383,19 @@
return f
}
+// Creates a new local testing environment. A local testing environment has a
+// root mounttable endpoint at RootMT() and a security principle available via
+// Principal().
+//
+// You should clean up the returned environment using the env.Cleanup() method.
+// A typical end-to-end test will begin like:
+//
+// func TestFoo(t *testing.T) {
+// env := integration.NewTestEnvironment(t)
+// defer env.Cleanup()
+//
+// ...
+// }
func NewTestEnvironment(t *testing.T) TestEnvironment {
t.Log("creating root principal")
principal := tsecurity.NewPrincipal("root")
diff --git a/profiles/chrome/chromeinit.go b/profiles/chrome/chromeinit.go
index b18108d..6ec957d 100644
--- a/profiles/chrome/chromeinit.go
+++ b/profiles/chrome/chromeinit.go
@@ -15,7 +15,7 @@
}
func Init(ctx *context.T) (veyron2.RuntimeX, *context.T, veyron2.Shutdown, error) {
- runtime, ctx, shutdown, err := grt.Init(ctx, nil)
+ runtime, ctx, shutdown, err := grt.Init(ctx, nil, nil, nil, nil)
if err != nil {
return nil, nil, shutdown, err
}
diff --git a/profiles/gce/initx.go b/profiles/gce/initx.go
index 4aa63c8..45d9b23 100644
--- a/profiles/gce/initx.go
+++ b/profiles/gce/initx.go
@@ -8,10 +8,12 @@
"flag"
"fmt"
"net"
+ "os"
"v.io/core/veyron2"
"v.io/core/veyron2/context"
"v.io/core/veyron2/ipc"
+ "v.io/core/veyron2/vlog"
"v.io/core/veyron/lib/appcycle"
"v.io/core/veyron/lib/flags"
@@ -33,16 +35,14 @@
}
func Init(ctx *context.T) (veyron2.RuntimeX, *context.T, veyron2.Shutdown, error) {
+ vlog.Log.VI(1).Infof("Initializing GCE profile.")
if !gce.RunningOnGCE() {
return nil, nil, nil, fmt.Errorf("GCE profile used on a non-GCE system")
}
- runtime, ctx, shutdown, err := grt.Init(ctx, nil)
- if err != nil {
- return nil, nil, shutdown, err
- }
- runtime.GetLogger(ctx).VI(1).Infof("Initializing GCE profile.")
+ ac := appcycle.New()
+ commonFlags.Parse(os.Args[1:], nil)
lf := commonFlags.ListenFlags()
listenSpec := ipc.ListenSpec{
Addrs: ipc.ListenAddrs(lf.Addrs),
@@ -50,20 +50,21 @@
}
if ip, err := gce.ExternalIPAddress(); err != nil {
- return nil, nil, shutdown, err
+ return nil, nil, nil, err
} else {
listenSpec.AddressChooser = func(network string, addrs []ipc.Address) ([]ipc.Address, error) {
return []ipc.Address{&netstate.AddrIfc{&net.IPAddr{IP: ip}, "gce-nat", nil}}, nil
}
}
- ctx = runtime.SetListenSpec(ctx, listenSpec)
- ac := appcycle.New()
- ctx = runtime.SetAppCycle(ctx, ac)
+ runtime, ctx, shutdown, err := grt.Init(ctx, ac, nil, &listenSpec, nil)
+ if err != nil {
+ return nil, nil, shutdown, err
+ }
profileShutdown := func() {
- shutdown()
ac.Shutdown()
+ shutdown()
}
return runtime, ctx, profileShutdown, nil
diff --git a/profiles/genericinit.go b/profiles/genericinit.go
index cbd7312..257974a 100644
--- a/profiles/genericinit.go
+++ b/profiles/genericinit.go
@@ -3,8 +3,10 @@
import (
"v.io/core/veyron2"
"v.io/core/veyron2/context"
+ "v.io/core/veyron2/ipc"
"v.io/core/veyron/lib/appcycle"
+ "v.io/core/veyron/profiles/internal"
_ "v.io/core/veyron/runtimes/google/ipc/protocols/tcp"
_ "v.io/core/veyron/runtimes/google/ipc/protocols/ws"
_ "v.io/core/veyron/runtimes/google/ipc/protocols/wsh"
@@ -16,18 +18,24 @@
}
func Init(ctx *context.T) (veyron2.RuntimeX, *context.T, veyron2.Shutdown, error) {
- runtime, ctx, shutdown, err := grt.Init(ctx, nil)
+ ac := appcycle.New()
+
+ runtime, ctx, shutdown, err := grt.Init(ctx,
+ ac,
+ nil,
+ &ipc.ListenSpec{
+ Addrs: ipc.ListenAddrs{{"tcp", "127.0.0.1:0"}},
+ AddressChooser: internal.IPAddressChooser,
+ },
+ nil)
if err != nil {
return nil, nil, nil, err
}
runtime.GetLogger(ctx).VI(1).Infof("Initializing generic profile.")
- ac := appcycle.New()
- ctx = runtime.SetAppCycle(ctx, ac)
-
profileShutdown := func() {
- shutdown()
ac.Shutdown()
+ shutdown()
}
return runtime, ctx, profileShutdown, nil
}
diff --git a/profiles/roaming/roaminginit.go b/profiles/roaming/roaminginit.go
index 533cabb..8dbe076 100644
--- a/profiles/roaming/roaminginit.go
+++ b/profiles/roaming/roaminginit.go
@@ -12,11 +12,13 @@
import (
"flag"
+ "os"
"v.io/core/veyron2"
"v.io/core/veyron2/config"
"v.io/core/veyron2/context"
"v.io/core/veyron2/ipc"
+ "v.io/core/veyron2/vlog"
"v.io/core/veyron/lib/appcycle"
"v.io/core/veyron/lib/flags"
@@ -47,14 +49,10 @@
}
func Init(ctx *context.T) (veyron2.RuntimeX, *context.T, veyron2.Shutdown, error) {
- runtime, ctx, shutdown, err := grt.Init(ctx, nil)
- if err != nil {
- return nil, nil, shutdown, err
- }
- log := runtime.GetLogger(ctx)
+ log := vlog.Log
+ reservedDispatcher := debug.NewDispatcher(log.LogDir(), sflag.NewAuthorizerOrDie())
- ctx = runtime.SetReservedNameDispatcher(ctx, debug.NewDispatcher(log.LogDir(), sflag.NewAuthorizerOrDie()))
-
+ commonFlags.Parse(os.Args[1:], nil)
lf := commonFlags.ListenFlags()
listenSpec := ipc.ListenSpec{
Addrs: ipc.ListenAddrs(lf.Addrs),
@@ -62,7 +60,6 @@
}
ac := appcycle.New()
- ctx = runtime.SetAppCycle(ctx, ac)
// Our address is private, so we test for running on GCE and for its
// 1:1 NAT configuration.
@@ -71,36 +68,40 @@
listenSpec.AddressChooser = func(string, []ipc.Address) ([]ipc.Address, error) {
return []ipc.Address{&netstate.AddrIfc{addr, "nat", nil}}, nil
}
- ctx = runtime.SetListenSpec(ctx, listenSpec)
- return runtime, ctx, shutdown, nil
+ runtime, ctx, shutdown, err := grt.Init(ctx, ac, nil, &listenSpec, reservedDispatcher)
+ if err != nil {
+ return nil, nil, shutdown, err
+ }
+ profileShutdown := func() {
+ ac.Shutdown()
+ shutdown()
+ }
+ return runtime, ctx, profileShutdown, nil
}
}
- publisher := runtime.GetPublisher(ctx)
+ publisher := config.NewPublisher()
// Create stream in Init function to avoid a race between any
// goroutines started here and consumers started after Init returns.
ch := make(chan config.Setting)
stop, err := publisher.CreateStream(SettingsStreamName, SettingsStreamName, ch)
if err != nil {
- log.Errorf("failed to create publisher: %s", err)
ac.Shutdown()
- return nil, nil, shutdown, err
+ return nil, nil, nil, err
}
prev, err := netstate.GetAccessibleIPs()
if err != nil {
- log.VI(2).Infof("failed to determine network state")
ac.Shutdown()
- return nil, nil, shutdown, err
+ return nil, nil, nil, err
}
// Start the dhcp watcher.
watcher, err := netconfig.NewNetConfigWatcher()
if err != nil {
- log.VI(2).Infof("Failed to get new config watcher: %s", err)
ac.Shutdown()
- return nil, nil, shutdown, err
+ return nil, nil, nil, err
}
cleanupCh := make(chan struct{})
@@ -110,13 +111,16 @@
listenSpec.StreamName = SettingsStreamName
listenSpec.AddressChooser = internal.IPAddressChooser
- ctx = runtime.SetListenSpec(ctx, listenSpec)
+ runtime, ctx, shutdown, err := grt.Init(ctx, ac, nil, &listenSpec, reservedDispatcher)
+ if err != nil {
+ return nil, nil, shutdown, err
+ }
go monitorNetworkSettingsX(runtime, ctx, watcher, prev, stop, cleanupCh, watcherCh, ch)
profileShutdown := func() {
close(cleanupCh)
- shutdown()
ac.Shutdown()
+ shutdown()
<-watcherCh
}
return runtime, ctx, profileShutdown, nil
diff --git a/profiles/static/staticinit.go b/profiles/static/staticinit.go
index 4def643..4f84141 100644
--- a/profiles/static/staticinit.go
+++ b/profiles/static/staticinit.go
@@ -2,10 +2,12 @@
import (
"flag"
+ "os"
"v.io/core/veyron2"
"v.io/core/veyron2/context"
"v.io/core/veyron2/ipc"
+ "v.io/core/veyron2/vlog"
"v.io/core/veyron/lib/appcycle"
"v.io/core/veyron/lib/flags"
@@ -31,14 +33,11 @@
}
func Init(ctx *context.T) (veyron2.RuntimeX, *context.T, veyron2.Shutdown, error) {
- runtime, ctx, shutdown, err := grt.Init(ctx, nil)
- if err != nil {
- return nil, nil, nil, err
- }
- log := runtime.GetLogger(ctx)
+ log := vlog.Log
- ctx = runtime.SetReservedNameDispatcher(ctx, debug.NewDispatcher(log.LogDir(), sflag.NewAuthorizerOrDie()))
+ reservedDispatcher := debug.NewDispatcher(log.LogDir(), sflag.NewAuthorizerOrDie())
+ commonFlags.Parse(os.Args[1:], nil)
lf := commonFlags.ListenFlags()
listenSpec := ipc.ListenSpec{
Addrs: ipc.ListenAddrs(lf.Addrs),
@@ -46,7 +45,6 @@
}
ac := appcycle.New()
- ctx = runtime.SetAppCycle(ctx, ac)
// Our address is private, so we test for running on GCE and for its 1:1 NAT
// configuration. GCEPublicAddress returns a non-nil addr if we are running on GCE.
@@ -55,15 +53,23 @@
listenSpec.AddressChooser = func(string, []ipc.Address) ([]ipc.Address, error) {
return []ipc.Address{&netstate.AddrIfc{addr, "nat", nil}}, nil
}
+ runtime, ctx, shutdown, err := grt.Init(ctx, ac, nil, &listenSpec, reservedDispatcher)
+ if err != nil {
+ return nil, nil, nil, err
+ }
return runtime, ctx, shutdown, nil
}
}
listenSpec.AddressChooser = internal.IPAddressChooser
- ctx = runtime.SetListenSpec(ctx, listenSpec)
+
+ runtime, ctx, shutdown, err := grt.Init(ctx, ac, nil, &listenSpec, reservedDispatcher)
+ if err != nil {
+ return nil, nil, shutdown, err
+ }
profileShutdown := func() {
- shutdown()
ac.Shutdown()
+ shutdown()
}
return runtime, ctx, profileShutdown, nil
}
diff --git a/runtimes/google/ipc/benchmark/benchmark_test.go b/runtimes/google/ipc/benchmark/benchmark_test.go
index 89b1e4f..941a22d 100644
--- a/runtimes/google/ipc/benchmark/benchmark_test.go
+++ b/runtimes/google/ipc/benchmark/benchmark_test.go
@@ -5,6 +5,7 @@
"testing"
"v.io/core/veyron/lib/testutil/benchmark"
+ tsecurity "v.io/core/veyron/lib/testutil/security"
"v.io/core/veyron/profiles"
"v.io/core/veyron2"
@@ -106,6 +107,9 @@
panic(err)
}
ctx := vrt.NewContext()
+ if ctx, err = veyron2.SetPrincipal(ctx, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ panic(err)
+ }
var serverStop func()
serverAddr, serverStop = StartServer(ctx, profiles.LocalListenSpec)
diff --git a/runtimes/google/ipc/benchmark/glob/glob_test.go b/runtimes/google/ipc/benchmark/glob/glob_test.go
index db032b3..951b16d 100644
--- a/runtimes/google/ipc/benchmark/glob/glob_test.go
+++ b/runtimes/google/ipc/benchmark/glob/glob_test.go
@@ -11,6 +11,7 @@
"v.io/core/veyron2/rt"
"v.io/core/veyron2/security"
+ tsecurity "v.io/core/veyron/lib/testutil/security"
"v.io/core/veyron/profiles"
)
@@ -161,6 +162,9 @@
}
defer runtime.Cleanup()
ctx := runtime.NewContext()
+ if ctx, err = veyron2.SetPrincipal(ctx, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ panic(err)
+ }
addr, stop, err := startServer(b, ctx, obj)
if err != nil {
diff --git a/runtimes/google/ipc/benchmark/service.vdl.go b/runtimes/google/ipc/benchmark/service.vdl.go
index cea2802..a09b115 100644
--- a/runtimes/google/ipc/benchmark/service.vdl.go
+++ b/runtimes/google/ipc/benchmark/service.vdl.go
@@ -14,14 +14,8 @@
__context "v.io/core/veyron2/context"
__ipc "v.io/core/veyron2/ipc"
__vdlutil "v.io/core/veyron2/vdl/vdlutil"
- __wiretype "v.io/core/veyron2/wiretype"
)
-// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where __wiretype is unused in VDL pacakges where only
-// bootstrap types are used on interfaces.
-const _ = __wiretype.TypeIDInvalid
-
// BenchmarkClientMethods is the client interface
// containing Benchmark methods.
type BenchmarkClientMethods interface {
@@ -80,17 +74,6 @@
return
}
-func (c implBenchmarkClientStub) Signature(ctx *__context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
- var call __ipc.Call
- if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&o0, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
// BenchmarkEchoStreamClientStream is the client stream for Benchmark.EchoStream.
type BenchmarkEchoStreamClientStream interface {
// RecvStream returns the receiver side of the Benchmark.EchoStream client stream.
@@ -220,8 +203,6 @@
BenchmarkServerStubMethods
// Describe the Benchmark interfaces.
Describe__() []__ipc.InterfaceDesc
- // Signature will be replaced with Describe__.
- Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error)
}
// BenchmarkServer returns a server stub for Benchmark.
@@ -293,33 +274,6 @@
},
}
-func (s implBenchmarkServerStub) Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) {
- // TODO(toddw): Replace with new Describe__ implementation.
- result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
- result.Methods["Echo"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "Payload", Type: 66},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 66},
- {Name: "", Type: 67},
- },
- }
- result.Methods["EchoStream"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{},
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 67},
- },
- InStream: 66,
- OutStream: 66,
- }
-
- result.TypeDefs = []__vdlutil.Any{
- __wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x41, Name: "", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
-
- return result, nil
-}
-
// BenchmarkEchoStreamServerStream is the server stream for Benchmark.EchoStream.
type BenchmarkEchoStreamServerStream interface {
// RecvStream returns the receiver side of the Benchmark.EchoStream server stream.
diff --git a/runtimes/google/ipc/client.go b/runtimes/google/ipc/client.go
index 65b9d0a..2199a8d 100644
--- a/runtimes/google/ipc/client.go
+++ b/runtimes/google/ipc/client.go
@@ -21,7 +21,6 @@
old_verror "v.io/core/veyron2/verror"
verror "v.io/core/veyron2/verror2"
"v.io/core/veyron2/vlog"
- "v.io/core/veyron2/vom"
"v.io/core/veyron2/vom2"
"v.io/core/veyron2/vtrace"
@@ -399,8 +398,8 @@
var servers []string
var pattern security.BlessingPattern
- if resolved, err := c.ns.ResolveX(ctx, name, resolveOpts...); err != nil {
- vlog.Errorf("ResolveX: %v", err)
+ if resolved, err := c.ns.Resolve(ctx, name, resolveOpts...); err != nil {
+ vlog.Errorf("Resolve: %v", err)
if verror.Is(err, naming.ErrNoSuchName.ID) {
return nil, verror.RetryRefetch, verror.Make(verror.NoServers, ctx, name)
}
@@ -674,12 +673,12 @@
// flowClient implements the RPC client-side protocol for a single RPC, over a
// flow that's already connected to the server.
type flowClient struct {
- ctx *context.T // context to annotate with call details
- dec vomDecoder // to decode responses and results from the server
- enc vomEncoder // to encode requests and args to the server
- server []string // Blessings bound to the server that authorize it to receive the IPC request from the client.
- flow stream.Flow // the underlying flow
- response ipc.Response // each decoded response message is kept here
+ ctx *context.T // context to annotate with call details
+ dec *vom2.Decoder // to decode responses and results from the server
+ enc *vom2.Encoder // to encode requests and args to the server
+ server []string // Blessings bound to the server that authorize it to receive the IPC request from the client.
+ flow stream.Flow // the underlying flow
+ response ipc.Response // each decoded response message is kept here
discharges []security.Discharge // discharges used for this request
dc vc.DischargeClient // client-global discharge-client
@@ -697,25 +696,18 @@
func newFlowClient(ctx *context.T, server []string, flow stream.Flow, dc vc.DischargeClient) (*flowClient, error) {
fc := &flowClient{
ctx: ctx,
- dec: vom.NewDecoder(flow),
- enc: vom.NewEncoder(flow),
server: server,
flow: flow,
dc: dc,
}
- if vom2.IsEnabled() {
- var err error
- if fc.enc, err = vom2.NewBinaryEncoder(flow); err != nil {
- berr := verror.Make(verror.BadProtocol, fc.ctx, verror.Make(errVomEncoder, fc.ctx, err))
- return nil, fc.close(berr)
- }
- if fc.dec, err = vom2.NewDecoder(flow); err != nil {
- berr := verror.Make(verror.BadProtocol, fc.ctx, verror.Make(errVomDecoder, fc.ctx, err))
- return nil, fc.close(berr)
- }
- } else {
- fc.dec = vom.NewDecoder(flow)
- fc.enc = vom.NewEncoder(flow)
+ var err error
+ if fc.enc, err = vom2.NewBinaryEncoder(flow); err != nil {
+ berr := verror.Make(verror.BadProtocol, fc.ctx, verror.Make(errVomEncoder, fc.ctx, err))
+ return nil, fc.close(berr)
+ }
+ if fc.dec, err = vom2.NewDecoder(flow); err != nil {
+ berr := verror.Make(verror.BadProtocol, fc.ctx, verror.Make(errVomDecoder, fc.ctx, err))
+ return nil, fc.close(berr)
}
return fc, nil
}
diff --git a/runtimes/google/ipc/client_test.go b/runtimes/google/ipc/client_test.go
index a124355..499c7bc 100644
--- a/runtimes/google/ipc/client_test.go
+++ b/runtimes/google/ipc/client_test.go
@@ -27,17 +27,22 @@
inaming "v.io/core/veyron/runtimes/google/naming"
)
-var r veyron2.Runtime
-var gctx *context.T
-
func init() {
modules.RegisterChild("ping", "<name>", childPing)
- var err error
- if r, err = rt.New(); err != nil {
+}
+
+func newCtx() (*context.T, veyron2.Shutdown) {
+ r, err := rt.New()
+ if err != nil {
panic(err)
}
- gctx = r.NewContext()
- veyron2.GetNamespace(gctx).CacheCtl(naming.DisableCache(true))
+ ctx := r.NewContext()
+ if ctx, err = veyron2.SetPrincipal(ctx, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ panic(err)
+ }
+
+ veyron2.GetNamespace(ctx).CacheCtl(naming.DisableCache(true))
+ return ctx, r.Cleanup
}
func testArgs(args ...string) []string {
@@ -97,8 +102,8 @@
return nil
}
-func numServers(t *testing.T, name string) int {
- me, err := veyron2.GetNamespace(gctx).ResolveX(gctx, name)
+func numServers(t *testing.T, ctx *context.T, name string) int {
+ me, err := veyron2.GetNamespace(ctx).Resolve(ctx, name)
if err != nil {
return 0
}
@@ -108,7 +113,9 @@
// TODO(cnicolaou): figure out how to test and see what the internals
// of tryCall are doing - e.g. using stats counters.
func TestMultipleEndpoints(t *testing.T) {
- sh, fn := runMountTable(t, gctx)
+ ctx, shutdown := newCtx()
+ defer shutdown()
+ sh, fn := runMountTable(t, ctx)
defer fn()
srv, err := sh.Start(core.EchoServerCommand, nil, testArgs("echoServer", "echoServer")...)
if err != nil {
@@ -119,7 +126,7 @@
s.ExpectVar("NAME")
// Verify that there are 1 entries for echoServer in the mount table.
- if got, want := numServers(t, "echoServer"), 1; got != want {
+ if got, want := numServers(t, ctx, "echoServer"), 1; got != want {
t.Fatalf("got: %q, want: %q", got, want)
}
@@ -130,13 +137,13 @@
// 203.0.113.0 is TEST-NET-3 from RFC5737
ep := naming.FormatEndpoint("tcp", fmt.Sprintf("203.0.113.%d:443", i))
n := naming.JoinAddressName(ep, "")
- if err := veyron2.GetNamespace(gctx).Mount(gctx, "echoServer", n, time.Hour); err != nil {
+ if err := veyron2.GetNamespace(ctx).Mount(ctx, "echoServer", n, time.Hour); err != nil {
t.Fatalf("unexpected error: %s", err)
}
}
// Verify that there are 101 entries for echoServer in the mount table.
- if got, want := numServers(t, "echoServer"), 101; got != want {
+ if got, want := numServers(t, ctx, "echoServer"), 101; got != want {
t.Fatalf("got: %q, want: %q", got, want)
}
@@ -151,13 +158,15 @@
srv.Shutdown(nil, nil)
// Verify that there are 100 entries for echoServer in the mount table.
- if got, want := numServers(t, "echoServer"), 100; got != want {
+ if got, want := numServers(t, ctx, "echoServer"), 100; got != want {
t.Fatalf("got: %d, want: %d", got, want)
}
}
func TestTimeoutCall(t *testing.T) {
- ctx, _ := context.WithTimeout(gctx, 100*time.Millisecond)
+ ctx, shutdown := newCtx()
+ defer shutdown()
+ ctx, _ = context.WithTimeout(ctx, 100*time.Millisecond)
name := naming.JoinAddressName(naming.FormatEndpoint("tcp", "203.0.113.10:443"), "")
client := veyron2.GetClient(ctx)
_, err := client.StartCall(ctx, name, "echo", []interface{}{"args don't matter"})
@@ -167,8 +176,15 @@
}
func childPing(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
+ r, err := rt.New()
+ if err != nil {
+ panic(err)
+ }
+ ctx := r.NewContext()
+ veyron2.GetNamespace(ctx).CacheCtl(naming.DisableCache(true))
+
name := args[1]
- call, err := veyron2.GetClient(gctx).StartCall(gctx, name, "Ping", nil)
+ call, err := veyron2.GetClient(ctx).StartCall(ctx, name, "Ping", nil)
if err != nil {
fmt.Errorf("unexpected error: %s", err)
}
@@ -223,9 +239,11 @@
}
func TestTimeoutResponse(t *testing.T) {
- name, fn := initServer(t, gctx)
+ ctx, shutdown := newCtx()
+ defer shutdown()
+ name, fn := initServer(t, ctx)
defer fn()
- ctx, _ := context.WithTimeout(gctx, 100*time.Millisecond)
+ ctx, _ = context.WithTimeout(ctx, 100*time.Millisecond)
call, err := veyron2.GetClient(ctx).StartCall(ctx, name, "Sleep", nil)
if err != nil {
testForVerror(t, err, verror.Timeout, verror.BadProtocol)
@@ -237,17 +255,19 @@
}
func TestArgsAndResponses(t *testing.T) {
- name, fn := initServer(t, gctx)
+ ctx, shutdown := newCtx()
+ defer shutdown()
+ name, fn := initServer(t, ctx)
defer fn()
- call, err := veyron2.GetClient(gctx).StartCall(gctx, name, "Sleep", []interface{}{"too many args"})
+ call, err := veyron2.GetClient(ctx).StartCall(ctx, name, "Sleep", []interface{}{"too many args"})
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
verr := call.Finish(&err)
testForVerror(t, verr, verror.BadProtocol)
- call, err = veyron2.GetClient(gctx).StartCall(gctx, name, "Ping", nil)
+ call, err = veyron2.GetClient(ctx).StartCall(ctx, name, "Ping", nil)
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
@@ -264,10 +284,19 @@
// The server and client use different runtimes and hence different
// principals and without any shared blessings the server will deny
// access to the client
- name, fn := initServer(t, r1.NewContext())
+ ctx1 := r1.NewContext()
+ var err error
+ if ctx1, err = veyron2.SetPrincipal(ctx1, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ t.Fatal(err)
+ }
+
+ name, fn := initServer(t, ctx1)
defer fn()
ctx2 := r2.NewContext()
+ if ctx2, err = veyron2.SetPrincipal(ctx2, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ t.Fatal(err)
+ }
client2 := veyron2.GetClient(ctx2)
call, err := client2.StartCall(ctx2, name, "Sleep", nil)
if err != nil {
@@ -278,10 +307,12 @@
}
func TestCancelledBeforeFinish(t *testing.T) {
- name, fn := initServer(t, gctx)
+ ctx, shutdown := newCtx()
+ defer shutdown()
+ name, fn := initServer(t, ctx)
defer fn()
- ctx, cancel := context.WithCancel(gctx)
+ ctx, cancel := context.WithCancel(ctx)
call, err := veyron2.GetClient(ctx).StartCall(ctx, name, "Sleep", nil)
if err != nil {
t.Fatalf("unexpected error: %s", err)
@@ -294,10 +325,12 @@
}
func TestCancelledDuringFinish(t *testing.T) {
- name, fn := initServer(t, gctx)
+ ctx, shutdown := newCtx()
+ defer shutdown()
+ name, fn := initServer(t, ctx)
defer fn()
- ctx, cancel := context.WithCancel(gctx)
+ ctx, cancel := context.WithCancel(ctx)
call, err := veyron2.GetClient(ctx).StartCall(ctx, name, "Sleep", nil)
if err != nil {
t.Fatalf("unexpected error: %s", err)
@@ -313,7 +346,9 @@
}
func TestRendezvous(t *testing.T) {
- sh, fn := runMountTable(t, gctx)
+ ctx, shutdown := newCtx()
+ defer shutdown()
+ sh, fn := runMountTable(t, ctx)
defer fn()
name := "echoServer"
@@ -330,7 +365,7 @@
}
go startServer()
- call, err := veyron2.GetClient(gctx).StartCall(gctx, name, "Echo", []interface{}{"hello"})
+ call, err := veyron2.GetClient(ctx).StartCall(ctx, name, "Echo", []interface{}{"hello"})
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
@@ -347,10 +382,12 @@
}
func TestCallback(t *testing.T) {
- sh, fn := runMountTable(t, gctx)
+ ctx, shutdown := newCtx()
+ defer shutdown()
+ sh, fn := runMountTable(t, ctx)
defer fn()
- name, fn := initServer(t, gctx)
+ name, fn := initServer(t, ctx)
defer fn()
srv, err := sh.Start("ping", nil, name)
@@ -364,11 +401,13 @@
}
func TestStreamTimeout(t *testing.T) {
- name, fn := initServer(t, gctx)
+ ctx, shutdown := newCtx()
+ defer shutdown()
+ name, fn := initServer(t, ctx)
defer fn()
want := 10
- ctx, _ := context.WithTimeout(gctx, 300*time.Millisecond)
+ ctx, _ = context.WithTimeout(ctx, 300*time.Millisecond)
call, err := veyron2.GetClient(ctx).StartCall(ctx, name, "Source", []interface{}{want})
if err != nil {
if !verror.Is(err, verror.Timeout.ID) && !verror.Is(err, verror.BadProtocol.ID) {
@@ -397,10 +436,12 @@
}
func TestStreamAbort(t *testing.T) {
- name, fn := initServer(t, gctx)
+ ctx, shutdown := newCtx()
+ defer shutdown()
+ name, fn := initServer(t, ctx)
defer fn()
- call, err := veyron2.GetClient(gctx).StartCall(gctx, name, "Sink", nil)
+ call, err := veyron2.GetClient(ctx).StartCall(ctx, name, "Sink", nil)
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
@@ -434,10 +475,12 @@
}
func TestNoServersAvailable(t *testing.T) {
- _, fn := runMountTable(t, gctx)
+ ctx, shutdown := newCtx()
+ defer shutdown()
+ _, fn := runMountTable(t, ctx)
defer fn()
name := "noservers"
- ctx, _ := context.WithTimeout(gctx, 300*time.Millisecond)
+ ctx, _ = context.WithTimeout(ctx, 300*time.Millisecond)
call, verr := veyron2.GetClient(ctx).StartCall(ctx, name, "Sleep", nil)
if verr != nil {
testForVerror(t, verr, verror.Timeout, verror.BadProtocol, verror.NoExist)
@@ -448,11 +491,13 @@
}
func TestNoMountTable(t *testing.T) {
- veyron2.GetNamespace(gctx).SetRoots()
+ ctx, shutdown := newCtx()
+ defer shutdown()
+ veyron2.GetNamespace(ctx).SetRoots()
name := "a_mount_table_entry"
// If there is no mount table, then we'll get a NoServers error message.
- ctx, _ := context.WithTimeout(gctx, 300*time.Millisecond)
+ ctx, _ = context.WithTimeout(ctx, 300*time.Millisecond)
_, verr := veyron2.GetClient(ctx).StartCall(ctx, name, "Sleep", nil)
testForVerror(t, verr, verror.NoServers)
}
diff --git a/runtimes/google/ipc/full_test.go b/runtimes/google/ipc/full_test.go
index 3db30e5..e8d702d 100644
--- a/runtimes/google/ipc/full_test.go
+++ b/runtimes/google/ipc/full_test.go
@@ -233,7 +233,7 @@
}
func verifyMount(t *testing.T, ns naming.Namespace, name string) []string {
- me, err := ns.ResolveX(testContext(), name)
+ me, err := ns.Resolve(testContext(), name)
if err != nil {
t.Errorf("%s: %s not found in mounttable", loc(1), name)
return nil
@@ -242,7 +242,7 @@
}
func verifyMountMissing(t *testing.T, ns naming.Namespace, name string) {
- if me, err := ns.ResolveX(testContext(), name); err == nil {
+ if me, err := ns.Resolve(testContext(), name); err == nil {
names := me.Names()
t.Errorf("%s: %s not supposed to be found in mounttable; got %d servers instead: %v", loc(1), name, len(names), names)
}
@@ -280,7 +280,7 @@
// It must return a name since it'll be passed to StartCall.
func fakeWSName(ns naming.Namespace, name string) (string, error) {
// Find the ws endpoint and use that.
- me, err := ns.ResolveX(testContext(), name)
+ me, err := ns.Resolve(testContext(), name)
if err != nil {
return "", err
}
diff --git a/runtimes/google/ipc/glob_test.go b/runtimes/google/ipc/glob_test.go
index 20b60af..799a67e 100644
--- a/runtimes/google/ipc/glob_test.go
+++ b/runtimes/google/ipc/glob_test.go
@@ -15,6 +15,7 @@
"v.io/core/veyron/lib/glob"
"v.io/core/veyron/lib/testutil"
+ tsecurity "v.io/core/veyron/lib/testutil/security"
"v.io/core/veyron/profiles"
)
@@ -41,6 +42,9 @@
}
defer runtime.Cleanup()
ctx := runtime.NewContext()
+ if ctx, err = veyron2.SetPrincipal(ctx, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ t.Fatal(err)
+ }
namespace := []string{
"a/b/c1/d1",
diff --git a/runtimes/google/ipc/resolve_test.go b/runtimes/google/ipc/resolve_test.go
index ab64566..53dfdbc 100644
--- a/runtimes/google/ipc/resolve_test.go
+++ b/runtimes/google/ipc/resolve_test.go
@@ -12,6 +12,7 @@
"v.io/core/veyron/lib/expect"
"v.io/core/veyron/lib/modules"
"v.io/core/veyron/lib/modules/core"
+ tsecurity "v.io/core/veyron/lib/testutil/security"
iipc "v.io/core/veyron/runtimes/google/ipc"
inaming "v.io/core/veyron/runtimes/google/naming"
)
@@ -40,6 +41,9 @@
}
defer runtime.Cleanup()
ctx := runtime.NewContext()
+ if ctx, err = veyron2.SetPrincipal(ctx, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ t.Fatal(err)
+ }
ns := veyron2.GetNamespace(ctx)
ns.SetRoots(root)
diff --git a/runtimes/google/ipc/server.go b/runtimes/google/ipc/server.go
index 8a65932..d6df99b 100644
--- a/runtimes/google/ipc/server.go
+++ b/runtimes/google/ipc/server.go
@@ -22,7 +22,6 @@
old_verror "v.io/core/veyron2/verror"
verror "v.io/core/veyron2/verror2"
"v.io/core/veyron2/vlog"
- "v.io/core/veyron2/vom"
"v.io/core/veyron2/vom2"
"v.io/core/veyron2/vtrace"
@@ -35,7 +34,6 @@
// TODO(cnicolaou): finish verror -> verror2 transition, in particular
// for communicating from server to client.
- // TODO(cnicolaou): remove the vom1 code now that vom2 is in place.
)
var (
@@ -157,7 +155,7 @@
if s.ns != nil {
var entry *naming.MountEntry
var err error
- if entry, err = s.ns.ResolveX(s.ctx, address); err != nil {
+ if entry, err = s.ns.Resolve(s.ctx, address); err != nil {
return "", err
}
names = entry.Names()
@@ -795,23 +793,14 @@
return nil
}
-// TODO(toddw): Remove these interfaces after the vom2 transition.
-type vomEncoder interface {
- Encode(v interface{}) error
-}
-
-type vomDecoder interface {
- Decode(v interface{}) error
-}
-
// flowServer implements the RPC server-side protocol for a single RPC, over a
// flow that's already connected to the client.
type flowServer struct {
*context.T
server *server // ipc.Server that this flow server belongs to
disp ipc.Dispatcher // ipc.Dispatcher that will serve RPCs on this flow
- dec vomDecoder // to decode requests and args from the client
- enc vomEncoder // to encode responses and results to the client
+ dec *vom2.Decoder // to decode requests and args from the client
+ enc *vom2.Encoder // to encode responses and results to the client
flow stream.Flow // underlying flow
// Fields filled in during the server invocation.
@@ -840,66 +829,18 @@
flow: flow,
discharges: make(map[string]security.Discharge),
}
- if vom2.IsEnabled() {
- var err error
- if fs.dec, err = vom2.NewDecoder(flow); err != nil {
- flow.Close()
- return nil, err
- }
- if fs.enc, err = vom2.NewBinaryEncoder(flow); err != nil {
- flow.Close()
- return nil, err
- }
- } else {
- fs.dec = vom.NewDecoder(flow)
- fs.enc = vom.NewEncoder(flow)
+ var err error
+ if fs.dec, err = vom2.NewDecoder(flow); err != nil {
+ flow.Close()
+ return nil, err
+ }
+ if fs.enc, err = vom2.NewBinaryEncoder(flow); err != nil {
+ flow.Close()
+ return nil, err
}
return fs, nil
}
-// Vom does not encode untyped nils.
-// Consequently, the ipc system does not allow nil results with an interface
-// type from server methods. The one exception being errors.
-//
-// For now, the following hacky assumptions are made, which will be revisited when
-// a decision is made on how untyped nils should be encoded/decoded in
-// vom/vom2:
-//
-// - Server methods return 0 or more results
-// - Any values returned by the server that have an interface type are either
-// non-nil or of type error.
-func vomErrorHack(res interface{}) vom.Value {
- v := vom.ValueOf(res)
- if !v.IsValid() {
- // Untyped nils are assumed to be nil-errors.
- var boxed old_verror.E
- return vom.ValueOf(&boxed).Elem()
- }
- if err, iserr := res.(error); iserr {
- // Convert errors to verror since errors are often not
- // serializable via vom/gob (errors.New and fmt.Errorf return a
- // type with no exported fields).
- return vom.ValueOf(old_verror.Convert(err))
- }
- return v
-}
-
-// TODO(toddw): Remove this function and encodeValueHack after the vom2 transition.
-func vom2ErrorHack(res interface{}) interface{} {
- if err, ok := res.(error); ok {
- return &err
- }
- return res
-}
-
-// TODO(toddw): Remove this function and vom2ErrorHack after the vom2 transition.
-func (fs *flowServer) encodeValueHack(res interface{}) error {
- if vom2.IsEnabled() {
- return fs.enc.Encode(vom2ErrorHack(res))
- }
- return fs.enc.(*vom.Encoder).EncodeValue(vomErrorHack(res))
-}
-
func (fs *flowServer) serve() error {
defer fs.flow.Close()
@@ -930,7 +871,7 @@
return response.Error
}
for ix, res := range results {
- if err := fs.encodeValueHack(res); err != nil {
+ if err := fs.enc.Encode(res); err != nil {
if err == io.EOF {
return err
}
diff --git a/runtimes/google/ipc/server_test.go b/runtimes/google/ipc/server_test.go
index 1f362be..b71aed9 100644
--- a/runtimes/google/ipc/server_test.go
+++ b/runtimes/google/ipc/server_test.go
@@ -198,7 +198,7 @@
waitfor := func(expect int) {
then := time.Now().Add(time.Minute)
for {
- me, err := ns.ResolveX(testContext(), name)
+ me, err := ns.Resolve(testContext(), name)
if err == nil && len(me.Servers) == expect {
close(ch)
return
@@ -268,7 +268,7 @@
}
for {
- if _, err := ns.ResolveX(testContext(), name); err != nil {
+ if _, err := ns.Resolve(testContext(), name); err != nil {
break
}
time.Sleep(10 * time.Millisecond)
diff --git a/runtimes/google/ipc/signature_test.go b/runtimes/google/ipc/signature_test.go
index 26a5ec5..a0604c8 100644
--- a/runtimes/google/ipc/signature_test.go
+++ b/runtimes/google/ipc/signature_test.go
@@ -15,6 +15,7 @@
"v.io/core/veyron2/vdl/vdlroot/src/signature"
"v.io/core/veyron/lib/testutil"
+ tsecurity "v.io/core/veyron/lib/testutil/security"
"v.io/core/veyron/profiles"
)
@@ -65,7 +66,9 @@
}
defer runtime.Cleanup()
ctx := runtime.NewContext()
-
+ if ctx, err = veyron2.SetPrincipal(ctx, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ t.Fatal(err)
+ }
ep, stop, err := startSigServer(ctx, sigImpl{})
if err != nil {
t.Fatalf("startSigServer: %v", err)
@@ -116,7 +119,9 @@
}
defer runtime.Cleanup()
ctx := runtime.NewContext()
-
+ if ctx, err = veyron2.SetPrincipal(ctx, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ t.Fatal(err)
+ }
ep, stop, err := startSigServer(ctx, sigImpl{})
if err != nil {
t.Fatalf("startSigServer: %v", err)
diff --git a/runtimes/google/ipc/simple_test.go b/runtimes/google/ipc/simple_test.go
index 39b1147..15b2a3b 100644
--- a/runtimes/google/ipc/simple_test.go
+++ b/runtimes/google/ipc/simple_test.go
@@ -67,11 +67,13 @@
}
func TestSimpleRPC(t *testing.T) {
- name, fn := initServer(t, gctx)
+ ctx, shutdown := newCtx()
+ defer shutdown()
+ name, fn := initServer(t, ctx)
defer fn()
- client := veyron2.GetClient(r.NewContext())
- call, err := client.StartCall(r.NewContext(), name, "Ping", nil)
+ client := veyron2.GetClient(ctx)
+ call, err := client.StartCall(ctx, name, "Ping", nil)
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
@@ -87,12 +89,13 @@
}
func TestSimpleStreaming(t *testing.T) {
- name, fn := initServer(t, gctx)
+ ctx, shutdown := newCtx()
+ defer shutdown()
+ name, fn := initServer(t, ctx)
defer fn()
- ctx := r.NewContext()
inc := 1
- call, err := veyron2.GetClient(r.NewContext()).StartCall(ctx, name, "Inc", []interface{}{inc})
+ call, err := veyron2.GetClient(ctx).StartCall(ctx, name, "Inc", []interface{}{inc})
if err != nil {
t.Fatalf("unexpected error: %s", err)
}
diff --git a/runtimes/google/lib/deque/deque.go b/runtimes/google/lib/deque/deque.go
index 54ddbfb..a104de2 100644
--- a/runtimes/google/lib/deque/deque.go
+++ b/runtimes/google/lib/deque/deque.go
@@ -105,10 +105,9 @@
q.contents = make([]interface{}, initialQueueSize)
return
}
- contents := make([]interface{}, len(q.contents)*2)
- for i := 0; i != q.size; i++ {
- contents[i] = q.contents[(q.fx+i)%len(q.contents)]
- }
+ contents := make([]interface{}, q.size*2)
+ i := copy(contents[:], q.contents[q.fx:])
+ copy(contents[i:], q.contents[:q.fx])
q.contents = contents
q.fx = 0
q.bx = q.size
diff --git a/runtimes/google/lib/deque/deque_test.go b/runtimes/google/lib/deque/deque_test.go
index 2e34c41..ae0d4d3 100644
--- a/runtimes/google/lib/deque/deque_test.go
+++ b/runtimes/google/lib/deque/deque_test.go
@@ -209,3 +209,41 @@
t.Errorf("Iteration did not stop correctly,expected 6 iterations, got %d", iterations)
}
}
+
+func BenchmarkPushFront(b *testing.B) {
+ var q T
+ for i := 0; i < b.N; i++ {
+ q.PushFront(i)
+ }
+}
+
+func BenchmarkPushBack(b *testing.B) {
+ var q T
+ for i := 0; i < b.N; i++ {
+ q.PushBack(i)
+ }
+}
+
+func BenchmarkPopFront(b *testing.B) {
+ var q T
+ for i := 0; i < b.N; i++ {
+ q.PushBack(i)
+ }
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ q.PopFront()
+ }
+}
+
+func BenchmarkPopBack(b *testing.B) {
+ var q T
+ for i := 0; i < b.N; i++ {
+ q.PushFront(i)
+ }
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ q.PopBack()
+ }
+}
diff --git a/runtimes/google/lib/publisher/publisher.go b/runtimes/google/lib/publisher/publisher.go
index c5d35ed..5ccf6e7 100644
--- a/runtimes/google/lib/publisher/publisher.go
+++ b/runtimes/google/lib/publisher/publisher.go
@@ -342,7 +342,7 @@
func (ps *pubState) published() []string {
var ret []string
for name, _ := range ps.names {
- e, err := ps.ns.ResolveToMountTableX(ps.ctx, name)
+ e, err := ps.ns.ResolveToMountTable(ps.ctx, name)
if err != nil {
vlog.Errorf("ipc pub: couldn't resolve %v to mount table: %v", name, err)
continue
diff --git a/runtimes/google/lib/publisher/publisher_test.go b/runtimes/google/lib/publisher/publisher_test.go
index c0d0c4d..a947799 100644
--- a/runtimes/google/lib/publisher/publisher_test.go
+++ b/runtimes/google/lib/publisher/publisher_test.go
@@ -28,11 +28,11 @@
}
func resolve(t *testing.T, ns naming.Namespace, name string) []string {
- servers, err := ns.Resolve(testContext(), name)
+ me, err := ns.Resolve(testContext(), name)
if err != nil {
t.Fatalf("failed to resolve %q", name)
}
- return servers
+ return me.Names()
}
func TestAddAndRemove(t *testing.T) {
diff --git a/runtimes/google/naming/namespace/all_test.go b/runtimes/google/naming/namespace/all_test.go
index 406a884..4590568 100644
--- a/runtimes/google/naming/namespace/all_test.go
+++ b/runtimes/google/naming/namespace/all_test.go
@@ -18,6 +18,7 @@
"v.io/core/veyron2/vlog"
"v.io/core/veyron/lib/testutil"
+ tsecurity "v.io/core/veyron/lib/testutil/security"
"v.io/core/veyron/profiles"
"v.io/core/veyron/runtimes/google/naming/namespace"
vsecurity "v.io/core/veyron/security"
@@ -35,6 +36,9 @@
t.Fatalf("Could not initialize runtime: %v", err)
}
sc = sr.NewContext()
+ if sc, err = veyron2.SetPrincipal(sc, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ t.Fatal(err)
+ }
// We use a different runtime for the client side.
r, err := rt.New()
@@ -42,6 +46,9 @@
t.Fatalf("Could not initialize runtime: %v", err)
}
c = r.NewContext()
+ if c, err = veyron2.SetPrincipal(c, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ t.Fatal(err)
+ }
return sc, c, func() {
sr.Cleanup()
@@ -149,19 +156,19 @@
}
func testResolveToMountTable(t *testing.T, ctx *context.T, ns naming.Namespace, name string, want ...string) {
- doResolveTest(t, "ResolveToMountTable", ns.ResolveToMountTableX, ctx, name, want)
+ doResolveTest(t, "ResolveToMountTable", ns.ResolveToMountTable, ctx, name, want)
}
func testResolveToMountTableWithPattern(t *testing.T, ctx *context.T, ns naming.Namespace, name string, pattern naming.ResolveOpt, want ...string) {
- doResolveTest(t, "ResolveToMountTable", ns.ResolveToMountTableX, ctx, name, want, pattern)
+ doResolveTest(t, "ResolveToMountTable", ns.ResolveToMountTable, ctx, name, want, pattern)
}
func testResolve(t *testing.T, ctx *context.T, ns naming.Namespace, name string, want ...string) {
- doResolveTest(t, "Resolve", ns.ResolveX, ctx, name, want)
+ doResolveTest(t, "Resolve", ns.Resolve, ctx, name, want)
}
func testResolveWithPattern(t *testing.T, ctx *context.T, ns naming.Namespace, name string, pattern naming.ResolveOpt, want ...string) {
- doResolveTest(t, "Resolve", ns.ResolveX, ctx, name, want, pattern)
+ doResolveTest(t, "Resolve", ns.Resolve, ctx, name, want, pattern)
}
type serverEntry struct {
@@ -562,7 +569,7 @@
for i := 0; i < 40; i++ {
cycle += "/c3/c4"
}
- if _, err := ns.ResolveX(c, "c1/"+cycle); !verror.Is(err, naming.ErrResolutionDepthExceeded.ID) {
+ if _, err := ns.Resolve(c, "c1/"+cycle); !verror.Is(err, naming.ErrResolutionDepthExceeded.ID) {
boom(t, "Failed to detect cycle")
}
diff --git a/runtimes/google/naming/namespace/mount.go b/runtimes/google/naming/namespace/mount.go
index 9b7d186..66bf6d0 100644
--- a/runtimes/google/naming/namespace/mount.go
+++ b/runtimes/google/naming/namespace/mount.go
@@ -85,10 +85,11 @@
// dispatch executes f in parallel for each mount table implementing mTName.
func (ns *namespace) dispatch(ctx *context.T, mTName string, f func(*context.T, string, string) status) error {
// Resolve to all the mount tables implementing name.
- mts, err := ns.ResolveToMountTable(ctx, mTName)
+ me, err := ns.ResolveToMountTable(ctx, mTName)
if err != nil {
return err
}
+ mts := me.Names()
// Apply f to each of the returned mount tables.
c := make(chan status, len(mts))
for _, mt := range mts {
diff --git a/runtimes/google/naming/namespace/resolve.go b/runtimes/google/naming/namespace/resolve.go
index 5c2d26a..97f8e9b 100644
--- a/runtimes/google/naming/namespace/resolve.go
+++ b/runtimes/google/naming/namespace/resolve.go
@@ -68,14 +68,14 @@
return len(e.Name) == 0
}
-// ResolveX implements veyron2/naming.Namespace.
-func (ns *namespace) ResolveX(ctx *context.T, name string, opts ...naming.ResolveOpt) (*naming.MountEntry, error) {
+// Resolve implements veyron2/naming.Namespace.
+func (ns *namespace) Resolve(ctx *context.T, name string, opts ...naming.ResolveOpt) (*naming.MountEntry, error) {
defer vlog.LogCall()()
e, _ := ns.rootMountEntry(name)
if vlog.V(2) {
_, file, line, _ := runtime.Caller(1)
- vlog.Infof("ResolveX(%s) called from %s:%d", name, file, line)
- vlog.Infof("ResolveX(%s) -> rootMountEntry %v", name, *e)
+ vlog.Infof("Resolve(%s) called from %s:%d", name, file, line)
+ vlog.Infof("Resolve(%s) -> rootMountEntry %v", name, *e)
}
if skipResolve(opts) {
return e, nil
@@ -93,9 +93,9 @@
}
// Iterate walking through mount table servers.
for remaining := ns.maxResolveDepth; remaining > 0; remaining-- {
- vlog.VI(2).Infof("ResolveX(%s) loop %v", name, *e)
+ vlog.VI(2).Infof("Resolve(%s) loop %v", name, *e)
if !e.ServesMountTable() || terminal(e) {
- vlog.VI(1).Infof("ResolveX(%s) -> %v", name, *e)
+ vlog.VI(1).Infof("Resolve(%s) -> %v", name, *e)
return e, nil
}
var err error
@@ -104,13 +104,13 @@
// Lots of reasons why another error can happen. We are trying
// to single out "this isn't a mount table".
if notAnMT(err) {
- vlog.VI(1).Infof("ResolveX(%s) -> %v", name, curr)
+ vlog.VI(1).Infof("Resolve(%s) -> %v", name, curr)
return curr, nil
}
if verror.Is(err, naming.ErrNoSuchNameRoot.ID) {
err = verror.Make(naming.ErrNoSuchName, ctx, name)
}
- vlog.VI(1).Infof("ResolveX(%s) -> (%s: %v)", err, name, curr)
+ vlog.VI(1).Infof("Resolve(%s) -> (%s: %v)", err, name, curr)
return nil, err
}
pattern = ""
@@ -118,24 +118,14 @@
return nil, verror.Make(naming.ErrResolutionDepthExceeded, ctx)
}
-// Resolve implements veyron2/naming.Namespace.
-func (ns *namespace) Resolve(ctx *context.T, name string, opts ...naming.ResolveOpt) ([]string, error) {
- defer vlog.LogCall()()
- e, err := ns.ResolveX(ctx, name, opts...)
- if err != nil {
- return nil, err
- }
- return e.Names(), nil
-}
-
-// ResolveToMountTableX implements veyron2/naming.Namespace.
-func (ns *namespace) ResolveToMountTableX(ctx *context.T, name string, opts ...naming.ResolveOpt) (*naming.MountEntry, error) {
+// ResolveToMountTable implements veyron2/naming.Namespace.
+func (ns *namespace) ResolveToMountTable(ctx *context.T, name string, opts ...naming.ResolveOpt) (*naming.MountEntry, error) {
defer vlog.LogCall()()
e, _ := ns.rootMountEntry(name)
if vlog.V(2) {
_, file, line, _ := runtime.Caller(1)
- vlog.Infof("ResolveToMountTableX(%s) called from %s:%d", name, file, line)
- vlog.Infof("ResolveToMountTableX(%s) -> rootNames %v", name, e)
+ vlog.Infof("ResolveToMountTable(%s) called from %s:%d", name, file, line)
+ vlog.Infof("ResolveToMountTable(%s) -> rootNames %v", name, e)
}
if len(e.Servers) == 0 {
return nil, verror.Make(naming.ErrNoMountTable, ctx)
@@ -144,33 +134,33 @@
client := veyron2.GetClient(ctx)
last := e
for remaining := ns.maxResolveDepth; remaining > 0; remaining-- {
- vlog.VI(2).Infof("ResolveToMountTableX(%s) loop %v", name, e)
+ vlog.VI(2).Infof("ResolveToMountTable(%s) loop %v", name, e)
var err error
curr := e
// If the next name to resolve doesn't point to a mount table, we're done.
if !e.ServesMountTable() || terminal(e) {
- vlog.VI(1).Infof("ResolveToMountTableX(%s) -> %v", name, last)
+ vlog.VI(1).Infof("ResolveToMountTable(%s) -> %v", name, last)
return last, nil
}
if e, err = ns.resolveAgainstMountTable(ctx, client, e, pattern); err != nil {
if verror.Is(err, naming.ErrNoSuchNameRoot.ID) {
- vlog.VI(1).Infof("ResolveToMountTableX(%s) -> %v (NoSuchRoot: %v)", name, last, curr)
+ vlog.VI(1).Infof("ResolveToMountTable(%s) -> %v (NoSuchRoot: %v)", name, last, curr)
return last, nil
}
if verror.Is(err, naming.ErrNoSuchName.ID) {
- vlog.VI(1).Infof("ResolveToMountTableX(%s) -> %v (NoSuchName: %v)", name, curr, curr)
+ vlog.VI(1).Infof("ResolveToMountTable(%s) -> %v (NoSuchName: %v)", name, curr, curr)
return curr, nil
}
// Lots of reasons why another error can happen. We are trying
// to single out "this isn't a mount table".
if notAnMT(err) {
- vlog.VI(1).Infof("ResolveToMountTableX(%s) -> %v", name, last)
+ vlog.VI(1).Infof("ResolveToMountTable(%s) -> %v", name, last)
return last, nil
}
// TODO(caprita): If the server is unreachable for
// example, we may still want to return its parent
// mounttable rather than an error.
- vlog.VI(1).Infof("ResolveToMountTableX(%s) -> %v", name, err)
+ vlog.VI(1).Infof("ResolveToMountTable(%s) -> %v", name, err)
return nil, err
}
last = curr
@@ -179,16 +169,6 @@
return nil, verror.Make(naming.ErrResolutionDepthExceeded, ctx)
}
-// ResolveToMountTable implements veyron2/naming.Namespace.
-func (ns *namespace) ResolveToMountTable(ctx *context.T, name string, opts ...naming.ResolveOpt) ([]string, error) {
- defer vlog.LogCall()()
- e, err := ns.ResolveToMountTableX(ctx, name, opts...)
- if err != nil {
- return nil, err
- }
- return e.Names(), nil
-}
-
// FlushCache flushes the most specific entry found for name. It returns true if anything was
// actually flushed.
func (ns *namespace) FlushCacheEntry(name string) bool {
diff --git a/runtimes/google/rt/ipc_test.go b/runtimes/google/rt/ipc_test.go
index 70dd0d2..f62178a 100644
--- a/runtimes/google/rt/ipc_test.go
+++ b/runtimes/google/rt/ipc_test.go
@@ -10,7 +10,6 @@
"v.io/core/veyron2/context"
"v.io/core/veyron2/ipc"
"v.io/core/veyron2/naming"
- "v.io/core/veyron2/rt"
"v.io/core/veyron2/security"
"v.io/core/veyron/lib/testutil"
@@ -41,12 +40,12 @@
return ctx.LocalPrincipal().MintDischarge(c, security.UnconstrainedUse())
}
-func newRT() *context.T {
- r, err := rt.New()
+func newCtx(rootCtx *context.T) *context.T {
+ ctx, err := veyron2.SetPrincipal(rootCtx, tsecurity.NewPrincipal("defaultBlessings"))
if err != nil {
panic(err)
}
- return r.NewContext()
+ return ctx
}
func union(blessings ...security.Blessings) security.Blessings {
@@ -75,6 +74,13 @@
return cav
}
+func mkBlessings(blessings security.Blessings, err error) security.Blessings {
+ if err != nil {
+ panic(err)
+ }
+ return blessings
+}
+
func mkThirdPartyCaveat(discharger security.PublicKey, location string, caveats ...security.Caveat) security.Caveat {
if len(caveats) == 0 {
caveats = []security.Caveat{security.UnconstrainedUse()}
@@ -103,26 +109,23 @@
}
func TestClientServerBlessings(t *testing.T) {
- b := func(blessings security.Blessings, err error) security.Blessings {
- if err != nil {
- t.Fatal(err)
- }
- return blessings
- }
+ ctx, shutdown := veyron2.Init()
+ defer shutdown()
+
var (
rootAlpha, rootBeta, rootUnrecognized = tsecurity.NewIDProvider("alpha"), tsecurity.NewIDProvider("beta"), tsecurity.NewIDProvider("unrecognized")
- clientCtx, serverCtx = newRT(), newRT()
+ clientCtx, serverCtx = newCtx(ctx), newCtx(ctx)
pclient = veyron2.GetPrincipal(clientCtx)
pserver = veyron2.GetPrincipal(serverCtx)
// A bunch of blessings
- alphaClient = b(rootAlpha.NewBlessings(pclient, "client"))
- betaClient = b(rootBeta.NewBlessings(pclient, "client"))
- unrecognizedClient = b(rootUnrecognized.NewBlessings(pclient, "client"))
+ alphaClient = mkBlessings(rootAlpha.NewBlessings(pclient, "client"))
+ betaClient = mkBlessings(rootBeta.NewBlessings(pclient, "client"))
+ unrecognizedClient = mkBlessings(rootUnrecognized.NewBlessings(pclient, "client"))
- alphaServer = b(rootAlpha.NewBlessings(pserver, "server"))
- betaServer = b(rootBeta.NewBlessings(pserver, "server"))
- unrecognizedServer = b(rootUnrecognized.NewBlessings(pserver, "server"))
+ alphaServer = mkBlessings(rootAlpha.NewBlessings(pserver, "server"))
+ betaServer = mkBlessings(rootBeta.NewBlessings(pserver, "server"))
+ unrecognizedServer = mkBlessings(rootUnrecognized.NewBlessings(pserver, "server"))
)
// Setup the client's blessing store
pclient.BlessingStore().Set(alphaClient, "alpha/server")
@@ -196,14 +199,11 @@
}
func TestServerDischarges(t *testing.T) {
- b := func(blessings security.Blessings, err error) security.Blessings {
- if err != nil {
- t.Fatal(err)
- }
- return blessings
- }
+ ctx, shutdown := veyron2.Init()
+ defer shutdown()
+
var (
- dischargerCtx, clientCtx, serverCtx = newRT(), newRT(), newRT()
+ dischargerCtx, clientCtx, serverCtx = newCtx(ctx), newCtx(ctx), newCtx(ctx)
pdischarger = veyron2.GetPrincipal(dischargerCtx)
pclient = veyron2.GetPrincipal(clientCtx)
pserver = veyron2.GetPrincipal(serverCtx)
@@ -231,7 +231,7 @@
}
// Setup up the client's blessing store so that it can talk to the server.
- rootClient := b(root.NewBlessings(pclient, "client"))
+ rootClient := mkBlessings(root.NewBlessings(pclient, "client"))
if _, err := pclient.BlessingStore().Set(nil, security.AllPrincipals); err != nil {
t.Fatal(err)
}
@@ -270,7 +270,7 @@
t.Fatal(err)
}
- rootServerInvalidTPCaveat := b(root.NewBlessings(pserver, "server", mkThirdPartyCaveat(pdischarger.PublicKey(), dischargeServerName, mkCaveat(security.ExpiryCaveat(time.Now().Add(-1*time.Second))))))
+ rootServerInvalidTPCaveat := mkBlessings(root.NewBlessings(pserver, "server", mkThirdPartyCaveat(pdischarger.PublicKey(), dischargeServerName, mkCaveat(security.ExpiryCaveat(time.Now().Add(-1*time.Second))))))
if err := pserver.BlessingStore().SetDefault(rootServerInvalidTPCaveat); err != nil {
t.Fatal(err)
}
diff --git a/runtimes/google/rt/mgmt_test.go b/runtimes/google/rt/mgmt_test.go
index 6062899..f99ab44 100644
--- a/runtimes/google/rt/mgmt_test.go
+++ b/runtimes/google/rt/mgmt_test.go
@@ -14,20 +14,18 @@
"v.io/core/veyron2/ipc"
"v.io/core/veyron2/mgmt"
"v.io/core/veyron2/naming"
- "v.io/core/veyron2/options"
+ "v.io/core/veyron2/security"
"v.io/core/veyron2/services/mgmt/appcycle"
"v.io/core/veyron/lib/expect"
"v.io/core/veyron/lib/modules"
"v.io/core/veyron/lib/testutil"
+ tsecurity "v.io/core/veyron/lib/testutil/security"
"v.io/core/veyron/profiles"
- "v.io/core/veyron/runtimes/google/rt"
vflag "v.io/core/veyron/security/flag"
"v.io/core/veyron/services/mgmt/device"
)
-var profileOpt = options.Profile{profiles.New()}
-
const (
noWaitersCmd = "noWaiters"
forceStopCmd = "forceStop"
@@ -44,8 +42,13 @@
// TestBasic verifies that the basic plumbing works: LocalStop calls result in
// stop messages being sent on the channel passed to WaitForStop.
func TestBasic(t *testing.T) {
- r, _ := rt.New(profileOpt)
- ctx := r.NewContext()
+ ctx, shutdown := veyron2.Init()
+ defer shutdown()
+ var err error
+ if ctx, err = veyron2.SetPrincipal(ctx, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ t.Fatal(err)
+ }
+
m := veyron2.GetAppCycle(ctx)
ch := make(chan string, 1)
m.WaitForStop(ch)
@@ -65,8 +68,13 @@
// TestMultipleWaiters verifies that the plumbing works with more than one
// registered wait channel.
func TestMultipleWaiters(t *testing.T) {
- r, _ := rt.New(profileOpt)
- ctx := r.NewContext()
+ ctx, shutdown := veyron2.Init()
+ defer shutdown()
+ var err error
+ if ctx, err = veyron2.SetPrincipal(ctx, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ t.Fatal(err)
+ }
+
m := veyron2.GetAppCycle(ctx)
ch1 := make(chan string, 1)
m.WaitForStop(ch1)
@@ -87,8 +95,13 @@
// channel is not being drained: once the channel's buffer fills up, future
// Stops become no-ops.
func TestMultipleStops(t *testing.T) {
- r, _ := rt.New(profileOpt)
- ctx := r.NewContext()
+ ctx, shutdown := veyron2.Init()
+ defer shutdown()
+ var err error
+ if ctx, err = veyron2.SetPrincipal(ctx, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ t.Fatal(err)
+ }
+
m := veyron2.GetAppCycle(ctx)
ch := make(chan string, 1)
m.WaitForStop(ch)
@@ -106,8 +119,9 @@
}
func noWaiters(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
- r, _ := rt.New(profileOpt)
- ctx := r.NewContext()
+ ctx, shutdown := veyron2.Init()
+ defer shutdown()
+
m := veyron2.GetAppCycle(ctx)
fmt.Fprintf(stdout, "ready\n")
modules.WaitForEOF(stdin)
@@ -136,8 +150,9 @@
}
func forceStop(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
- r, _ := rt.New(profileOpt)
- ctx := r.NewContext()
+ ctx, shutdown := veyron2.Init()
+ defer shutdown()
+
m := veyron2.GetAppCycle(ctx)
fmt.Fprintf(stdout, "ready\n")
modules.WaitForEOF(stdin)
@@ -185,8 +200,12 @@
// TestProgress verifies that the ticker update/track logic works for a single
// tracker.
func TestProgress(t *testing.T) {
- r, _ := rt.New(profileOpt)
- ctx := r.NewContext()
+ ctx, shutdown := veyron2.Init()
+ var err error
+ if ctx, err = veyron2.SetPrincipal(ctx, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ t.Fatal(err)
+ }
+
m := veyron2.GetAppCycle(ctx)
m.AdvanceGoal(50)
ch := make(chan veyron2.Task, 1)
@@ -207,7 +226,7 @@
checkNoProgress(t, ch)
m.AdvanceGoal(0)
checkNoProgress(t, ch)
- r.Cleanup()
+ shutdown()
if _, ok := <-ch; ok {
t.Errorf("Expected channel to be closed")
}
@@ -217,8 +236,12 @@
// works for more than one tracker. It also ensures that the runtime doesn't
// block when the tracker channels are full.
func TestProgressMultipleTrackers(t *testing.T) {
- r, _ := rt.New(profileOpt)
- ctx := r.NewContext()
+ ctx, shutdown := veyron2.Init()
+ var err error
+ if ctx, err = veyron2.SetPrincipal(ctx, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ t.Fatal(err)
+ }
+
m := veyron2.GetAppCycle(ctx)
// ch1 is 1-buffered, ch2 is 2-buffered.
ch1, ch2 := make(chan veyron2.Task, 1), make(chan veyron2.Task, 2)
@@ -242,7 +265,7 @@
m.AdvanceGoal(4)
checkProgress(t, ch1, 11, 4)
checkProgress(t, ch2, 11, 4)
- r.Cleanup()
+ shutdown()
if _, ok := <-ch1; ok {
t.Errorf("Expected channel to be closed")
}
@@ -252,13 +275,10 @@
}
func app(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
- r, err := rt.New(profileOpt)
- if err != nil {
- return err
- }
- ctx := r.NewContext()
+ ctx, shutdown := veyron2.Init()
+ defer shutdown()
+
m := veyron2.GetAppCycle(ctx)
- defer r.Cleanup()
ch := make(chan string, 1)
m.WaitForStop(ch)
fmt.Fprintf(stdout, "Got %s\n", <-ch)
@@ -299,9 +319,12 @@
return server, eps[0].Name(), ch
}
-func setupRemoteAppCycleMgr(t *testing.T) (*context.T, modules.Handle, appcycle.AppCycleClientMethods, func()) {
- r, _ := rt.New(profileOpt)
- ctx := r.NewContext()
+func setupRemoteAppCycleMgr(t *testing.T, p security.Principal) (*context.T, modules.Handle, appcycle.AppCycleClientMethods, func()) {
+ ctx, shutdown := veyron2.Init()
+ var err error
+ if ctx, err = veyron2.SetPrincipal(ctx, p); err != nil {
+ t.Fatal(err)
+ }
configServer, configServiceName, ch := createConfigServer(t, ctx)
sh, err := modules.NewShell(ctx, veyron2.GetPrincipal(ctx))
@@ -325,15 +348,14 @@
return ctx, h, appCycle, func() {
configServer.Stop()
sh.Cleanup(os.Stderr, os.Stderr)
- // Don't do r.Cleanup() since the runtime needs to be used by
- // more than one test case.
+ shutdown()
}
}
// TestRemoteForceStop verifies that the child process exits when sending it
// a remote ForceStop rpc.
func TestRemoteForceStop(t *testing.T) {
- ctx, h, appCycle, cleanup := setupRemoteAppCycleMgr(t)
+ ctx, h, appCycle, cleanup := setupRemoteAppCycleMgr(t, tsecurity.NewPrincipal("test-blessing"))
defer cleanup()
if err := appCycle.ForceStop(ctx); err == nil || !strings.Contains(err.Error(), "EOF") {
t.Fatalf("Expected EOF error, got %v instead", err)
@@ -350,7 +372,7 @@
// TestRemoteStop verifies that the child shuts down cleanly when sending it
// a remote Stop rpc.
func TestRemoteStop(t *testing.T) {
- ctx, h, appCycle, cleanup := setupRemoteAppCycleMgr(t)
+ ctx, h, appCycle, cleanup := setupRemoteAppCycleMgr(t, tsecurity.NewPrincipal("test-blessing"))
defer cleanup()
stream, err := appCycle.Stop(ctx)
if err != nil {
diff --git a/runtimes/google/rt/mgmtx.go b/runtimes/google/rt/mgmtx.go
index cef0cb7..8795bc2 100644
--- a/runtimes/google/rt/mgmtx.go
+++ b/runtimes/google/rt/mgmtx.go
@@ -14,7 +14,7 @@
"v.io/core/veyron/lib/exec"
)
-func initMgmt(ctx *context.T, appCycle veyron2.AppCycle, handle *exec.ChildHandle) error {
+func (rt *RuntimeX) initMgmt(ctx *context.T, appCycle veyron2.AppCycle, handle *exec.ChildHandle) error {
// Do not initialize the mgmt runtime if the process has not
// been started through the veyron exec library by a device
// manager.
@@ -34,10 +34,10 @@
if err == nil && parentPeerPattern != "" {
// Grab the blessing from our blessing store that the parent
// told us to use so they can talk to us.
- serverBlessing := veyron2.GetPrincipal(ctx).BlessingStore().ForPeer(parentPeerPattern)
+ serverBlessing := rt.GetPrincipal(ctx).BlessingStore().ForPeer(parentPeerPattern)
serverOpts = append(serverOpts, options.ServerBlessings{serverBlessing})
}
- server, err := veyron2.NewServer(ctx, serverOpts...)
+ server, err := rt.NewServer(ctx, serverOpts...)
if err != nil {
return err
}
@@ -49,19 +49,12 @@
server.Stop()
return err
}
- err = callbackToParent(ctx, parentName, naming.JoinAddressName(eps[0].String(), ""))
+ err = rt.callbackToParent(ctx, parentName, naming.JoinAddressName(eps[0].String(), ""))
if err != nil {
server.Stop()
return err
}
- if done := ctx.Done(); done != nil {
- go func() {
- <-done
- server.Stop()
- }()
- }
-
return nil
}
@@ -84,9 +77,10 @@
return &ipc.ListenSpec{Addrs: ipc.ListenAddrs{{protocol, address}}}, nil
}
-func callbackToParent(ctx *context.T, parentName, myName string) error {
- ctx, _ = context.WithTimeout(ctx, 10*time.Second)
- call, err := veyron2.GetClient(ctx).StartCall(ctx, parentName, "Set", []interface{}{mgmt.AppCycleManagerConfigKey, myName})
+func (rt *RuntimeX) callbackToParent(ctx *context.T, parentName, myName string) error {
+ ctx, _ = context.WithTimeout(ctx, time.Minute)
+ call, err := rt.GetClient(ctx).StartCall(ctx, parentName, "Set", []interface{}{mgmt.AppCycleManagerConfigKey, myName}, options.NoResolve{})
+
if err != nil {
return err
}
diff --git a/runtimes/google/rt/rt_test.go b/runtimes/google/rt/rt_test.go
index 0d1c7a0..ce3a6a4 100644
--- a/runtimes/google/rt/rt_test.go
+++ b/runtimes/google/rt/rt_test.go
@@ -32,6 +32,7 @@
}
func TestInit(t *testing.T) {
+ testutil.UnsetPrincipalEnvVars()
ctx, shutdown := veyron2.Init()
defer shutdown()
diff --git a/runtimes/google/rt/runtimex.go b/runtimes/google/rt/runtimex.go
index ff35b2d..1e9bd5a 100644
--- a/runtimes/google/rt/runtimex.go
+++ b/runtimes/google/rt/runtimex.go
@@ -12,7 +12,6 @@
"time"
"v.io/core/veyron2"
- "v.io/core/veyron2/config"
"v.io/core/veyron2/context"
"v.io/core/veyron2/i18n"
"v.io/core/veyron2/ipc"
@@ -48,7 +47,6 @@
appCycleKey
listenSpecKey
protocolsKey
- publisherKey
backgroundKey
)
@@ -79,7 +77,6 @@
ctx = context.WithValue(ctx, namespaceKey, rt.ns)
ctx = context.WithValue(ctx, loggerKey, vlog.Log)
ctx = context.WithValue(ctx, principalKey, rt.principal)
- ctx = context.WithValue(ctx, publisherKey, rt.publisher)
ctx = context.WithValue(ctx, profileKey, rt.profile)
ctx = context.WithValue(ctx, appCycleKey, rt.ac)
return ctx
@@ -95,7 +92,13 @@
wait *sync.Cond
}
-func Init(ctx *context.T, protocols []string) (*RuntimeX, *context.T, veyron2.Shutdown, error) {
+type reservedNameDispatcher struct {
+ dispatcher ipc.Dispatcher
+ opts []ipc.ServerOpt
+}
+
+// TODO(mattr,suharshs): Decide if ROpts would be better than this.
+func Init(ctx *context.T, appCycle veyron2.AppCycle, protocols []string, listenSpec *ipc.ListenSpec, reservedDispatcher ipc.Dispatcher, dispatcherOpts ...ipc.ServerOpt) (*RuntimeX, *context.T, veyron2.Shutdown, error) {
r := &RuntimeX{}
r.wait = sync.NewCond(&r.mu)
@@ -124,11 +127,22 @@
r.initLogging(ctx)
ctx = context.WithValue(ctx, loggerKey, vlog.Log)
- // Set the preferred protocols.
+ if reservedDispatcher != nil {
+ ctx = context.WithValue(ctx, reservedNameKey, &reservedNameDispatcher{reservedDispatcher, dispatcherOpts})
+ }
+
+ if appCycle != nil {
+ ctx = context.WithValue(ctx, appCycleKey, appCycle)
+ }
+
if len(protocols) > 0 {
ctx = context.WithValue(ctx, protocolsKey, protocols)
}
+ if listenSpec != nil {
+ ctx = context.WithValue(ctx, listenSpecKey, listenSpec)
+ }
+
// Setup i18n.
ctx = i18n.ContextWithLangID(ctx, i18n.LangIDFromEnv())
if len(flags.I18nCatalogue) != 0 {
@@ -168,7 +182,7 @@
// The client we create here is incomplete (has a nil principal) and only works
// because the agent uses anonymous unix sockets and VCSecurityNone.
- // After security is initialized we will attach a real client.
+ // After security is initialized we attach a real client.
_, client, err := r.SetNewClient(ctx)
if err != nil {
return nil, nil, nil, err
@@ -188,13 +202,10 @@
}
// Initialize management.
- if err := initMgmt(ctx, r.GetAppCycle(ctx), handle); err != nil {
+ if err := r.initMgmt(ctx, r.GetAppCycle(ctx), handle); err != nil {
return nil, nil, nil, err
}
- // Initialize the config publisher.
- ctx = context.WithValue(ctx, publisherKey, config.NewPublisher())
-
ctx = r.SetBackgroundContext(ctx)
// TODO(suharshs,mattr): Go through the rt.Cleanup function and make sure everything
@@ -286,7 +297,7 @@
func (r *RuntimeX) NewServer(ctx *context.T, opts ...ipc.ServerOpt) (ipc.Server, error) {
// Create a new RoutingID (and StreamManager) for each server.
- _, sm, err := r.SetNewStreamManager(ctx)
+ sm, err := newStreamManager()
if err != nil {
return nil, fmt.Errorf("failed to create ipc/stream/Manager: %v", err)
}
@@ -311,6 +322,7 @@
if err := server.Stop(); err != nil {
vlog.Errorf("A server could not be stopped: %v", err)
}
+ sm.Shutdown()
}
if err = r.addChild(ctx, stop); err != nil {
return nil, err
@@ -318,17 +330,22 @@
return server, nil
}
-func (r *RuntimeX) setNewStreamManager(ctx *context.T, opts ...stream.ManagerOpt) (*context.T, stream.Manager, error) {
+func newStreamManager(opts ...stream.ManagerOpt) (stream.Manager, error) {
rid, err := naming.NewRoutingID()
if err != nil {
- return ctx, nil, err
+ return nil, err
}
sm := imanager.InternalNew(rid)
+ return sm, nil
+}
+
+func (r *RuntimeX) setNewStreamManager(ctx *context.T, opts ...stream.ManagerOpt) (*context.T, stream.Manager, error) {
+ sm, err := newStreamManager(opts...)
newctx := context.WithValue(ctx, streamManagerKey, sm)
if err = r.addChild(ctx, sm.Shutdown); err != nil {
return ctx, nil, err
}
- return newctx, sm, nil
+ return newctx, sm, err
}
func (r *RuntimeX) SetNewStreamManager(ctx *context.T, opts ...stream.ManagerOpt) (*context.T, stream.Manager, error) {
@@ -459,17 +476,6 @@
return logger
}
-type reservedNameDispatcher struct {
- dispatcher ipc.Dispatcher
- opts []ipc.ServerOpt
-}
-
-// TODO(mattr): Get this from the profile instead, then remove this
-// method from the interface.
-func (*RuntimeX) SetReservedNameDispatcher(ctx *context.T, server ipc.Dispatcher, opts ...ipc.ServerOpt) *context.T {
- return context.WithValue(ctx, reservedNameKey, &reservedNameDispatcher{server, opts})
-}
-
// SetProfile sets the profile used to create this runtime.
// TODO(suharshs, mattr): Determine if this is needed by functions after the new
// profile init function is in use. This will probably be easy to do because:
@@ -487,30 +493,14 @@
return profile
}
-// SetAppCycle attaches an appCycle to the context.
-func (r *RuntimeX) SetAppCycle(ctx *context.T, appCycle veyron2.AppCycle) *context.T {
- return context.WithValue(ctx, appCycleKey, appCycle)
-}
-
func (*RuntimeX) GetAppCycle(ctx *context.T) veyron2.AppCycle {
appCycle, _ := ctx.Value(appCycleKey).(veyron2.AppCycle)
return appCycle
}
-func (*RuntimeX) SetListenSpec(ctx *context.T, listenSpec ipc.ListenSpec) *context.T {
- return context.WithValue(ctx, listenSpecKey, listenSpec)
-}
-
func (*RuntimeX) GetListenSpec(ctx *context.T) ipc.ListenSpec {
- listenSpec, _ := ctx.Value(listenSpecKey).(ipc.ListenSpec)
- return listenSpec
-}
-
-// GetPublisher returns a configuration Publisher that can be used to access
-// configuration information.
-func (*RuntimeX) GetPublisher(ctx *context.T) *config.Publisher {
- publisher, _ := ctx.Value(publisherKey).(*config.Publisher)
- return publisher
+ listenSpec, _ := ctx.Value(listenSpecKey).(*ipc.ListenSpec)
+ return *listenSpec
}
func (*RuntimeX) SetBackgroundContext(ctx *context.T) *context.T {
diff --git a/runtimes/google/rt/runtimex_test.go b/runtimes/google/rt/runtimex_test.go
index ab1eba5..6562b52 100644
--- a/runtimes/google/rt/runtimex_test.go
+++ b/runtimes/google/rt/runtimex_test.go
@@ -6,6 +6,7 @@
"v.io/core/veyron2"
"v.io/core/veyron2/context"
+ tsecurity "v.io/core/veyron/lib/testutil/security"
"v.io/core/veyron/runtimes/google/rt"
"v.io/core/veyron/security"
)
@@ -13,10 +14,13 @@
// InitForTest creates a context for use in a test.
func InitForTest(t *testing.T) (*rt.RuntimeX, *context.T, veyron2.Shutdown) {
ctx, cancel := context.WithCancel(nil)
- r, ctx, shutdown, err := rt.Init(ctx, nil)
+ r, ctx, shutdown, err := rt.Init(ctx, nil, nil, nil, nil)
if err != nil {
t.Fatal(err)
}
+ if ctx, err = r.SetPrincipal(ctx, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ t.Fatal(err)
+ }
return r, ctx, func() {
cancel()
shutdown()
diff --git a/runtimes/google/rt/securityx.go b/runtimes/google/rt/securityx.go
index 040ca83..ab640df 100644
--- a/runtimes/google/rt/securityx.go
+++ b/runtimes/google/rt/securityx.go
@@ -40,7 +40,7 @@
if fd, err := agentFD(handle); err != nil {
return nil, err
} else if fd >= 0 {
- return agent.NewAgentPrincipal(ctx, fd, client)
+ return connectToAgent(ctx, fd, client)
}
if len(credentials) > 0 {
// TODO(ataly, ashankar): If multiple runtimes are getting
@@ -97,3 +97,17 @@
}
return fmt.Sprintf("%s-%d", name, os.Getpid())
}
+
+func connectToAgent(ctx *context.T, fd int, client ipc.Client) (security.Principal, error) {
+ // Dup the fd, so we can create multiple runtimes.
+ syscall.ForkLock.Lock()
+ newfd, err := syscall.Dup(fd)
+ if err == nil {
+ syscall.CloseOnExec(newfd)
+ }
+ syscall.ForkLock.Unlock()
+ if err != nil {
+ return nil, err
+ }
+ return agent.NewAgentPrincipal(ctx, newfd, client)
+}
diff --git a/runtimes/google/rt/shutdown_servers_test.go b/runtimes/google/rt/shutdown_servers_test.go
index 5e32689..37320fe 100644
--- a/runtimes/google/rt/shutdown_servers_test.go
+++ b/runtimes/google/rt/shutdown_servers_test.go
@@ -12,11 +12,11 @@
"v.io/core/veyron2"
"v.io/core/veyron2/context"
"v.io/core/veyron2/ipc"
- "v.io/core/veyron2/rt"
"v.io/core/veyron2/vlog"
"v.io/core/veyron/lib/modules"
"v.io/core/veyron/lib/signals"
+ tsecurity "v.io/core/veyron/lib/testutil/security"
"v.io/core/veyron/profiles"
)
@@ -72,23 +72,21 @@
// For a more typical server, see simpleServerProgram.
func complexServerProgram(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
// Initialize the runtime. This is boilerplate.
- r, err := rt.New()
- if err != nil {
- vlog.Fatalf("Could not initialize runtime: %s", err)
+ ctx, shutdown := veyron2.Init()
+ // shutdown is optional, but it's a good idea to clean up, especially
+ // since it takes care of flushing the logs before exiting.
+ defer shutdown()
+ var err error
+ if ctx, err = veyron2.SetPrincipal(ctx, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ vlog.Fatal(err)
}
- ctx := r.NewContext()
-
// This is part of the test setup -- we need a way to accept
// commands from the parent process to simulate Stop and
// RemoteStop commands that would normally be issued from
// application code.
defer remoteCmdLoop(ctx, stdin)()
- // r.Cleanup is optional, but it's a good idea to clean up, especially
- // since it takes care of flushing the logs before exiting.
- defer r.Cleanup()
-
// Create a couple servers, and start serving.
server1 := makeServer(ctx)
server2 := makeServer(ctx)
@@ -220,19 +218,18 @@
// complexServerProgram.
func simpleServerProgram(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
// Initialize the runtime. This is boilerplate.
- r, err := rt.New()
- if err != nil {
- vlog.Fatalf("Could not initialize runtime: %s", err)
- }
- // r.Cleanup is optional, but it's a good idea to clean up, especially
+ ctx, shutdown := veyron2.Init()
+ // Calling shutdown is optional, but it's a good idea to clean up, especially
// since it takes care of flushing the logs before exiting.
//
// We use defer to ensure this is the last thing in the program (to
// avoid shutting down the runtime while it may still be in use), and to
// allow it to execute even if a panic occurs down the road.
- defer r.Cleanup()
-
- ctx := r.NewContext()
+ defer shutdown()
+ var err error
+ if ctx, err = veyron2.SetPrincipal(ctx, tsecurity.NewPrincipal("test-blessing")); err != nil {
+ vlog.Fatal(err)
+ }
// This is part of the test setup -- we need a way to accept
// commands from the parent process to simulate Stop and
diff --git a/runtimes/google/rt/signal_test.go b/runtimes/google/rt/signal_test.go
index d9b296d..9cf77af 100644
--- a/runtimes/google/rt/signal_test.go
+++ b/runtimes/google/rt/signal_test.go
@@ -10,13 +10,10 @@
"time"
"v.io/core/veyron2"
- "v.io/core/veyron2/config"
- "v.io/core/veyron2/options"
- "v.io/core/veyron2/rt"
- "v.io/core/veyron/lib/appcycle"
"v.io/core/veyron/lib/expect"
"v.io/core/veyron/lib/modules"
+ _ "v.io/core/veyron/profiles"
)
func init() {
@@ -24,31 +21,6 @@
modules.RegisterChild("withoutRuntime", "", withoutRuntime)
}
-// A fack profile to explicitly request the Google runtime.
-type myprofile struct{}
-
-func (mp *myprofile) Name() string {
- return "test"
-}
-
-func (mp *myprofile) Runtime() (string, []veyron2.ROpt) {
- return "google", nil
-}
-
-func (mp *myprofile) Platform() *veyron2.Platform {
- return &veyron2.Platform{"google", nil, "v1", "any", "rel1", ".2", "who knows", "this host"}
-}
-
-func (mp *myprofile) String() string {
- return "myprofile on " + mp.Platform().String()
-}
-
-func (mp *myprofile) Init(veyron2.Runtime, *config.Publisher) (veyron2.AppCycle, error) {
- return appcycle.New(), nil
-}
-
-func (mp *myprofile) Cleanup() {}
-
func simpleEchoProgram(stdin io.Reader, stdout io.Writer) {
fmt.Fprintf(stdout, "ready\n")
scanner := bufio.NewScanner(stdin)
@@ -59,14 +31,9 @@
}
func withRuntime(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
- // Make sure that we use "google" runtime implementation in this
- // package even though we have to use the public API which supports
- // arbitrary runtime implementations.
- r, err := rt.New(options.Profile{&myprofile{}})
- if err != nil {
- return err
- }
- defer r.Cleanup()
+ _, shutdown := veyron2.Init()
+ defer shutdown()
+
simpleEchoProgram(stdin, stdout)
return nil
}
diff --git a/runtimes/google/testing/mocks/naming/namespace.go b/runtimes/google/testing/mocks/naming/namespace.go
index c46eca8..ad9a139 100644
--- a/runtimes/google/testing/mocks/naming/namespace.go
+++ b/runtimes/google/testing/mocks/naming/namespace.go
@@ -65,29 +65,9 @@
return nil
}
-func (ns *namespace) Resolve(ctx *context.T, name string, opts ...naming.ResolveOpt) ([]string, error) {
+func (ns *namespace) Resolve(ctx *context.T, name string, opts ...naming.ResolveOpt) (*naming.MountEntry, error) {
defer vlog.LogCall()()
- if address, _ := naming.SplitAddressName(name); len(address) > 0 {
- return []string{name}, nil
- }
- ns.Lock()
- defer ns.Unlock()
- for prefix, servers := range ns.mounts {
- if strings.HasPrefix(name, prefix) {
- suffix := strings.TrimLeft(strings.TrimPrefix(name, prefix), "/")
- var ret []string
- for _, s := range servers {
- ret = append(ret, naming.JoinAddressName(s, suffix))
- }
- return ret, nil
- }
- }
- return nil, verror.Make(naming.ErrNoSuchName, ctx, fmt.Sprintf("Resolve name %q not found in %v", name, ns.mounts))
-}
-
-func (ns *namespace) ResolveX(ctx *context.T, name string, opts ...naming.ResolveOpt) (*naming.MountEntry, error) {
- defer vlog.LogCall()()
- e, err := ns.ns.ResolveX(ctx, name, options.NoResolve{})
+ e, err := ns.ns.Resolve(ctx, name, options.NoResolve{})
if err != nil {
return e, err
}
@@ -111,14 +91,7 @@
return nil, verror.Make(naming.ErrNoSuchName, ctx, fmt.Sprintf("Resolve name %q not found in %v", name, ns.mounts))
}
-func (ns *namespace) ResolveToMountTableX(ctx *context.T, name string, opts ...naming.ResolveOpt) (*naming.MountEntry, error) {
- defer vlog.LogCall()()
- // TODO(mattr): Implement this method for tests that might need it.
- panic("ResolveToMountTable not implemented")
- return nil, nil
-}
-
-func (ns *namespace) ResolveToMountTable(ctx *context.T, name string, opts ...naming.ResolveOpt) ([]string, error) {
+func (ns *namespace) ResolveToMountTable(ctx *context.T, name string, opts ...naming.ResolveOpt) (*naming.MountEntry, error) {
defer vlog.LogCall()()
// TODO(mattr): Implement this method for tests that might need it.
panic("ResolveToMountTable not implemented")
diff --git a/security/agent/pingpong/wire.vdl.go b/security/agent/pingpong/wire.vdl.go
index 4344728..2f1915b 100644
--- a/security/agent/pingpong/wire.vdl.go
+++ b/security/agent/pingpong/wire.vdl.go
@@ -8,15 +8,8 @@
__veyron2 "v.io/core/veyron2"
__context "v.io/core/veyron2/context"
__ipc "v.io/core/veyron2/ipc"
- __vdlutil "v.io/core/veyron2/vdl/vdlutil"
- __wiretype "v.io/core/veyron2/wiretype"
)
-// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where __wiretype is unused in VDL pacakges where only
-// bootstrap types are used on interfaces.
-const _ = __wiretype.TypeIDInvalid
-
// PingPongClientMethods is the client interface
// containing PingPong methods.
//
@@ -65,17 +58,6 @@
return
}
-func (c implPingPongClientStub) Signature(ctx *__context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
- var call __ipc.Call
- if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&o0, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
// PingPongServerMethods is the interface a server writer
// implements for PingPong.
//
@@ -95,8 +77,6 @@
PingPongServerStubMethods
// Describe the PingPong interfaces.
Describe__() []__ipc.InterfaceDesc
- // Signature will be replaced with Describe__.
- Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error)
}
// PingPongServer returns a server stub for PingPong.
@@ -154,22 +134,3 @@
},
},
}
-
-func (s implPingPongServerStub) Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) {
- // TODO(toddw): Replace with new Describe__ implementation.
- result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
- result.Methods["Ping"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "message", Type: 3},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 3},
- {Name: "", Type: 65},
- },
- }
-
- result.TypeDefs = []__vdlutil.Any{
- __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
-
- return result, nil
-}
diff --git a/security/agent/server/wire.vdl.go b/security/agent/server/wire.vdl.go
index 1fa94ac..ddd4eab 100644
--- a/security/agent/server/wire.vdl.go
+++ b/security/agent/server/wire.vdl.go
@@ -11,14 +11,8 @@
__context "v.io/core/veyron2/context"
__ipc "v.io/core/veyron2/ipc"
__vdlutil "v.io/core/veyron2/vdl/vdlutil"
- __wiretype "v.io/core/veyron2/wiretype"
)
-// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where __wiretype is unused in VDL pacakges where only
-// bootstrap types are used on interfaces.
-const _ = __wiretype.TypeIDInvalid
-
// AgentClientMethods is the client interface
// containing Agent methods.
type AgentClientMethods interface {
@@ -257,17 +251,6 @@
return
}
-func (c implAgentClientStub) Signature(ctx *__context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
- var call __ipc.Call
- if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&o0, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
// AgentServerMethods is the interface a server writer
// implements for Agent.
type AgentServerMethods interface {
@@ -301,8 +284,6 @@
AgentServerStubMethods
// Describe the Agent interfaces.
Describe__() []__ipc.InterfaceDesc
- // Signature will be replaced with Describe__.
- Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error)
}
// AgentServer returns a server stub for Agent.
@@ -574,188 +555,3 @@
},
},
}
-
-func (s implAgentServerStub) Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) {
- // TODO(toddw): Replace with new Describe__ implementation.
- result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
- result.Methods["AddToRoots"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "blessing", Type: 74},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 75},
- },
- }
- result.Methods["Bless"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "key", Type: 66},
- {Name: "wit", Type: 74},
- {Name: "extension", Type: 3},
- {Name: "caveat", Type: 67},
- {Name: "additionalCaveats", Type: 68},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 74},
- {Name: "", Type: 75},
- },
- }
- result.Methods["BlessSelf"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "name", Type: 3},
- {Name: "caveats", Type: 68},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 74},
- {Name: "", Type: 75},
- },
- }
- result.Methods["BlessingRootsAdd"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "root", Type: 66},
- {Name: "pattern", Type: 77},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 75},
- },
- }
- result.Methods["BlessingRootsDebugString"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{},
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 3},
- {Name: "", Type: 75},
- },
- }
- result.Methods["BlessingRootsRecognized"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "root", Type: 66},
- {Name: "blessing", Type: 3},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 75},
- },
- }
- result.Methods["BlessingStoreDebugString"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{},
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 3},
- {Name: "", Type: 75},
- },
- }
- result.Methods["BlessingStoreDefault"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{},
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 74},
- {Name: "", Type: 75},
- },
- }
- result.Methods["BlessingStoreForPeer"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "peerBlessings", Type: 61},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 74},
- {Name: "", Type: 75},
- },
- }
- result.Methods["BlessingStorePeerBlessings"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{},
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 80},
- {Name: "", Type: 75},
- },
- }
- result.Methods["BlessingStoreSet"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "blessings", Type: 74},
- {Name: "forPeers", Type: 77},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 74},
- {Name: "", Type: 75},
- },
- }
- result.Methods["BlessingStoreSetDefault"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "blessings", Type: 74},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 75},
- },
- }
- result.Methods["BlessingsByName"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "name", Type: 77},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 78},
- {Name: "", Type: 75},
- },
- }
- result.Methods["BlessingsInfo"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "blessings", Type: 74},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 79},
- {Name: "", Type: 75},
- },
- }
- result.Methods["MintDischarge"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "tp", Type: 76},
- {Name: "caveat", Type: 67},
- {Name: "additionalCaveats", Type: 68},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 76},
- {Name: "", Type: 75},
- },
- }
- result.Methods["PublicKey"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{},
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 66},
- {Name: "", Type: 75},
- },
- }
- result.Methods["Sign"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "message", Type: 66},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 70},
- {Name: "", Type: 75},
- },
- }
-
- result.TypeDefs = []__vdlutil.Any{
- __wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x41, Name: "", Tags: []string(nil)}, __wiretype.StructType{
- []__wiretype.FieldType{
- __wiretype.FieldType{Type: 0x42, Name: "ValidatorVOM"},
- },
- "v.io/core/veyron2/security.Caveat", []string(nil)},
- __wiretype.SliceType{Elem: 0x43, Name: "", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x3, Name: "v.io/core/veyron2/security.Hash", Tags: []string(nil)}, __wiretype.StructType{
- []__wiretype.FieldType{
- __wiretype.FieldType{Type: 0x42, Name: "Purpose"},
- __wiretype.FieldType{Type: 0x45, Name: "Hash"},
- __wiretype.FieldType{Type: 0x42, Name: "R"},
- __wiretype.FieldType{Type: 0x42, Name: "S"},
- },
- "v.io/core/veyron2/security.Signature", []string(nil)},
- __wiretype.StructType{
- []__wiretype.FieldType{
- __wiretype.FieldType{Type: 0x3, Name: "Extension"},
- __wiretype.FieldType{Type: 0x42, Name: "PublicKey"},
- __wiretype.FieldType{Type: 0x44, Name: "Caveats"},
- __wiretype.FieldType{Type: 0x46, Name: "Signature"},
- },
- "v.io/core/veyron2/security.Certificate", []string(nil)},
- __wiretype.SliceType{Elem: 0x47, Name: "", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x48, Name: "", Tags: []string(nil)}, __wiretype.StructType{
- []__wiretype.FieldType{
- __wiretype.FieldType{Type: 0x49, Name: "CertificateChains"},
- },
- "v.io/core/veyron2/security.WireBlessings", []string(nil)},
- __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x1, Name: "anydata", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x3, Name: "v.io/core/veyron2/security.BlessingPattern", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x4a, Name: "", Tags: []string(nil)}, __wiretype.MapType{Key: 0x3, Elem: 0x44, Name: "", Tags: []string(nil)}, __wiretype.MapType{Key: 0x4d, Elem: 0x4a, Name: "", Tags: []string(nil)}}
-
- return result, nil
-}
diff --git a/services/identity/identity.vdl.go b/services/identity/identity.vdl.go
index c369461..97d9997 100644
--- a/services/identity/identity.vdl.go
+++ b/services/identity/identity.vdl.go
@@ -11,15 +11,8 @@
__veyron2 "v.io/core/veyron2"
__context "v.io/core/veyron2/context"
__ipc "v.io/core/veyron2/ipc"
- __vdlutil "v.io/core/veyron2/vdl/vdlutil"
- __wiretype "v.io/core/veyron2/wiretype"
)
-// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where __wiretype is unused in VDL pacakges where only
-// bootstrap types are used on interfaces.
-const _ = __wiretype.TypeIDInvalid
-
// OAuthBlesserClientMethods is the client interface
// containing OAuthBlesser methods.
//
@@ -82,17 +75,6 @@
return
}
-func (c implOAuthBlesserClientStub) Signature(ctx *__context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
- var call __ipc.Call
- if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&o0, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
// OAuthBlesserServerMethods is the interface a server writer
// implements for OAuthBlesser.
//
@@ -126,8 +108,6 @@
OAuthBlesserServerStubMethods
// Describe the OAuthBlesser interfaces.
Describe__() []__ipc.InterfaceDesc
- // Signature will be replaced with Describe__.
- Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error)
}
// OAuthBlesserServer returns a server stub for OAuthBlesser.
@@ -188,52 +168,6 @@
},
}
-func (s implOAuthBlesserServerStub) Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) {
- // TODO(toddw): Replace with new Describe__ implementation.
- result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
- result.Methods["BlessUsingAccessToken"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "token", Type: 3},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "blessing", Type: 74},
- {Name: "email", Type: 3},
- {Name: "err", Type: 75},
- },
- }
-
- result.TypeDefs = []__vdlutil.Any{
- __wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x41, Name: "", Tags: []string(nil)}, __wiretype.StructType{
- []__wiretype.FieldType{
- __wiretype.FieldType{Type: 0x42, Name: "ValidatorVOM"},
- },
- "v.io/core/veyron2/security.Caveat", []string(nil)},
- __wiretype.SliceType{Elem: 0x43, Name: "", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x3, Name: "v.io/core/veyron2/security.Hash", Tags: []string(nil)}, __wiretype.StructType{
- []__wiretype.FieldType{
- __wiretype.FieldType{Type: 0x42, Name: "Purpose"},
- __wiretype.FieldType{Type: 0x45, Name: "Hash"},
- __wiretype.FieldType{Type: 0x42, Name: "R"},
- __wiretype.FieldType{Type: 0x42, Name: "S"},
- },
- "v.io/core/veyron2/security.Signature", []string(nil)},
- __wiretype.StructType{
- []__wiretype.FieldType{
- __wiretype.FieldType{Type: 0x3, Name: "Extension"},
- __wiretype.FieldType{Type: 0x42, Name: "PublicKey"},
- __wiretype.FieldType{Type: 0x44, Name: "Caveats"},
- __wiretype.FieldType{Type: 0x46, Name: "Signature"},
- },
- "v.io/core/veyron2/security.Certificate", []string(nil)},
- __wiretype.SliceType{Elem: 0x47, Name: "", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x48, Name: "", Tags: []string(nil)}, __wiretype.StructType{
- []__wiretype.FieldType{
- __wiretype.FieldType{Type: 0x49, Name: "CertificateChains"},
- },
- "v.io/core/veyron2/security.WireBlessings", []string(nil)},
- __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
-
- return result, nil
-}
-
// MacaroonBlesserClientMethods is the client interface
// containing MacaroonBlesser methods.
//
@@ -284,17 +218,6 @@
return
}
-func (c implMacaroonBlesserClientStub) Signature(ctx *__context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
- var call __ipc.Call
- if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&o0, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
// MacaroonBlesserServerMethods is the interface a server writer
// implements for MacaroonBlesser.
//
@@ -316,8 +239,6 @@
MacaroonBlesserServerStubMethods
// Describe the MacaroonBlesser interfaces.
Describe__() []__ipc.InterfaceDesc
- // Signature will be replaced with Describe__.
- Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error)
}
// MacaroonBlesserServer returns a server stub for MacaroonBlesser.
@@ -376,48 +297,3 @@
},
},
}
-
-func (s implMacaroonBlesserServerStub) Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) {
- // TODO(toddw): Replace with new Describe__ implementation.
- result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
- result.Methods["Bless"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "macaroon", Type: 3},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "blessing", Type: 74},
- {Name: "err", Type: 75},
- },
- }
-
- result.TypeDefs = []__vdlutil.Any{
- __wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x41, Name: "", Tags: []string(nil)}, __wiretype.StructType{
- []__wiretype.FieldType{
- __wiretype.FieldType{Type: 0x42, Name: "ValidatorVOM"},
- },
- "v.io/core/veyron2/security.Caveat", []string(nil)},
- __wiretype.SliceType{Elem: 0x43, Name: "", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x3, Name: "v.io/core/veyron2/security.Hash", Tags: []string(nil)}, __wiretype.StructType{
- []__wiretype.FieldType{
- __wiretype.FieldType{Type: 0x42, Name: "Purpose"},
- __wiretype.FieldType{Type: 0x45, Name: "Hash"},
- __wiretype.FieldType{Type: 0x42, Name: "R"},
- __wiretype.FieldType{Type: 0x42, Name: "S"},
- },
- "v.io/core/veyron2/security.Signature", []string(nil)},
- __wiretype.StructType{
- []__wiretype.FieldType{
- __wiretype.FieldType{Type: 0x3, Name: "Extension"},
- __wiretype.FieldType{Type: 0x42, Name: "PublicKey"},
- __wiretype.FieldType{Type: 0x44, Name: "Caveats"},
- __wiretype.FieldType{Type: 0x46, Name: "Signature"},
- },
- "v.io/core/veyron2/security.Certificate", []string(nil)},
- __wiretype.SliceType{Elem: 0x47, Name: "", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x48, Name: "", Tags: []string(nil)}, __wiretype.StructType{
- []__wiretype.FieldType{
- __wiretype.FieldType{Type: 0x49, Name: "CertificateChains"},
- },
- "v.io/core/veyron2/security.WireBlessings", []string(nil)},
- __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
-
- return result, nil
-}
diff --git a/services/mgmt/device/config.vdl.go b/services/mgmt/device/config.vdl.go
index 4e35ccc..1a14ccb 100644
--- a/services/mgmt/device/config.vdl.go
+++ b/services/mgmt/device/config.vdl.go
@@ -8,15 +8,8 @@
__veyron2 "v.io/core/veyron2"
__context "v.io/core/veyron2/context"
__ipc "v.io/core/veyron2/ipc"
- __vdlutil "v.io/core/veyron2/vdl/vdlutil"
- __wiretype "v.io/core/veyron2/wiretype"
)
-// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where __wiretype is unused in VDL pacakges where only
-// bootstrap types are used on interfaces.
-const _ = __wiretype.TypeIDInvalid
-
// ConfigClientMethods is the client interface
// containing Config methods.
//
@@ -66,17 +59,6 @@
return
}
-func (c implConfigClientStub) Signature(ctx *__context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
- var call __ipc.Call
- if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&o0, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
// ConfigServerMethods is the interface a server writer
// implements for Config.
//
@@ -97,8 +79,6 @@
ConfigServerStubMethods
// Describe the Config interfaces.
Describe__() []__ipc.InterfaceDesc
- // Signature will be replaced with Describe__.
- Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error)
}
// ConfigServer returns a server stub for Config.
@@ -157,22 +137,3 @@
},
},
}
-
-func (s implConfigServerStub) Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) {
- // TODO(toddw): Replace with new Describe__ implementation.
- result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
- result.Methods["Set"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "key", Type: 3},
- {Name: "value", Type: 3},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 65},
- },
- }
-
- result.TypeDefs = []__vdlutil.Any{
- __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
-
- return result, nil
-}
diff --git a/services/mgmt/device/impl/dispatcher.go b/services/mgmt/device/impl/dispatcher.go
index 3b72c69..30cf651 100644
--- a/services/mgmt/device/impl/dispatcher.go
+++ b/services/mgmt/device/impl/dispatcher.go
@@ -237,19 +237,16 @@
if !instanceStateIs(appInstanceDir, started) {
return nil, nil, verror.Make(ErrInvalidSuffix, nil)
}
- var sigStub signatureStub
- if kind == "pprof" {
- sigStub = pprof.PProfServer(nil)
- } else {
- sigStub = stats.StatsServer(nil)
+ var desc []ipc.InterfaceDesc
+ switch kind {
+ case "pprof":
+ desc = pprof.PProfServer(nil).Describe__()
+ case "stats":
+ desc = stats.StatsServer(nil).Describe__()
}
suffix := naming.Join("__debug", naming.Join(components[4:]...))
remote := naming.JoinAddressName(info.AppCycleMgrName, suffix)
- invoker := &proxyInvoker{
- remote: remote,
- access: access.Debug,
- sigStub: sigStub,
- }
+ invoker := newProxyInvoker(remote, access.Debug, desc)
return invoker, auth, nil
}
}
diff --git a/services/mgmt/device/impl/proxy_invoker.go b/services/mgmt/device/impl/proxy_invoker.go
index 506d57f..9f82f88 100644
--- a/services/mgmt/device/impl/proxy_invoker.go
+++ b/services/mgmt/device/impl/proxy_invoker.go
@@ -17,19 +17,25 @@
//
// remote is the name of the remote object.
// access is the access tag require to access the object.
-// sigStub is used to get the signature of the remote object.
+// desc is used to determine the number of results for a given method.
+func newProxyInvoker(remote string, access access.Tag, desc []ipc.InterfaceDesc) *proxyInvoker {
+ methodNumResults := make(map[string]int)
+ for _, iface := range desc {
+ for _, method := range iface.Methods {
+ methodNumResults[method.Name] = len(method.OutArgs)
+ }
+ }
+ return &proxyInvoker{remote, access, methodNumResults}
+}
+
type proxyInvoker struct {
- remote string
- access access.Tag
- sigStub signatureStub
+ remote string
+ access access.Tag
+ methodNumResults map[string]int
}
var _ ipc.Invoker = (*proxyInvoker)(nil)
-type signatureStub interface {
- Signature(ipc.ServerContext) (ipc.ServiceSignature, error)
-}
-
func (p *proxyInvoker) Prepare(method string, numArgs int) (argptrs, tags []interface{}, err error) {
argptrs = make([]interface{}, numArgs)
for i, _ := range argptrs {
@@ -218,21 +224,15 @@
// numResults returns the number of result values for the given method.
func (p *proxyInvoker) numResults(method string) (int, error) {
- // TODO(toddw): Replace this mechanism when the new signature mechanism is
- // complete.
switch method {
case ipc.GlobMethod:
return 1, nil
case ipc.ReservedSignature, ipc.ReservedMethodSignature:
return 2, nil
}
- sig, err := p.sigStub.Signature(nil)
- if err != nil {
- return 0, err
- }
- m, ok := sig.Methods[method]
+ num, ok := p.methodNumResults[method]
if !ok {
return 0, fmt.Errorf("unknown method %q", method)
}
- return len(m.OutArgs), nil
+ return num, nil
}
diff --git a/services/mgmt/device/impl/proxy_invoker_test.go b/services/mgmt/device/impl/proxy_invoker_test.go
index 2da3bdc..2009a8c 100644
--- a/services/mgmt/device/impl/proxy_invoker_test.go
+++ b/services/mgmt/device/impl/proxy_invoker_test.go
@@ -53,7 +53,7 @@
disp := &proxyDispatcher{
runtime,
naming.JoinAddressName(eps1[0].String(), "__debug/stats"),
- stats.StatsServer(nil),
+ stats.StatsServer(nil).Describe__(),
}
if err := server2.ServeDispatcher("", disp); err != nil {
t.Fatalf("server2.Serve: %v", err)
@@ -87,15 +87,10 @@
type proxyDispatcher struct {
runtime veyron2.Runtime
remote string
- sigStub signatureStub
+ desc []ipc.InterfaceDesc
}
func (d *proxyDispatcher) Lookup(suffix string) (interface{}, security.Authorizer, error) {
vlog.Infof("LOOKUP(%s): remote .... %s", suffix, d.remote)
- invoker := &proxyInvoker{
- remote: naming.Join(d.remote, suffix),
- access: access.Debug,
- sigStub: d.sigStub,
- }
- return invoker, nil, nil
+ return newProxyInvoker(naming.Join(d.remote, suffix), access.Debug, d.desc), nil, nil
}
diff --git a/services/mgmt/device/impl/util_test.go b/services/mgmt/device/impl/util_test.go
index dd072de..4d8be6d 100644
--- a/services/mgmt/device/impl/util_test.go
+++ b/services/mgmt/device/impl/util_test.go
@@ -45,8 +45,8 @@
// resolveExpectNotFound verifies that the given name is not in the mounttable.
func resolveExpectNotFound(t *testing.T, name string) {
- if results, err := veyron2.GetNamespace(globalCtx).Resolve(globalCtx, name); err == nil {
- t.Fatalf(testutil.FormatLogLine(2, "Resolve(%v) succeeded with results %v when it was expected to fail", name, results))
+ if me, err := veyron2.GetNamespace(globalCtx).Resolve(globalCtx, name); err == nil {
+ t.Fatalf(testutil.FormatLogLine(2, "Resolve(%v) succeeded with results %v when it was expected to fail", name, me.Names()))
} else if expectErr := naming.ErrNoSuchName.ID; !verror2.Is(err, expectErr) {
t.Fatalf(testutil.FormatLogLine(2, "Resolve(%v) failed with error %v, expected error ID %v", name, err, expectErr))
}
@@ -54,13 +54,13 @@
// resolve looks up the given name in the mounttable.
func resolve(t *testing.T, name string, replicas int) []string {
- results, err := veyron2.GetNamespace(globalCtx).Resolve(globalCtx, name)
+ me, err := veyron2.GetNamespace(globalCtx).Resolve(globalCtx, name)
if err != nil {
t.Fatalf("Resolve(%v) failed: %v", name, err)
}
filteredResults := []string{}
- for _, r := range results {
+ for _, r := range me.Names() {
if strings.Index(r, "@tcp") != -1 {
filteredResults = append(filteredResults, r)
}
diff --git a/services/mgmt/repository/repository.vdl.go b/services/mgmt/repository/repository.vdl.go
index 36401ea..b320b6c 100644
--- a/services/mgmt/repository/repository.vdl.go
+++ b/services/mgmt/repository/repository.vdl.go
@@ -19,14 +19,8 @@
__context "v.io/core/veyron2/context"
__ipc "v.io/core/veyron2/ipc"
__vdlutil "v.io/core/veyron2/vdl/vdlutil"
- __wiretype "v.io/core/veyron2/wiretype"
)
-// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where __wiretype is unused in VDL pacakges where only
-// bootstrap types are used on interfaces.
-const _ = __wiretype.TypeIDInvalid
-
// ApplicationClientMethods is the client interface
// containing Application methods.
//
@@ -112,17 +106,6 @@
return
}
-func (c implApplicationClientStub) Signature(ctx *__context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
- var call __ipc.Call
- if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&o0, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
// ApplicationServerMethods is the interface a server writer
// implements for Application.
//
@@ -166,8 +149,6 @@
ApplicationServerStubMethods
// Describe the Application interfaces.
Describe__() []__ipc.InterfaceDesc
- // Signature will be replaced with Describe__.
- Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error)
}
// ApplicationServer returns a server stub for Application.
@@ -248,97 +229,6 @@
},
}
-func (s implApplicationServerStub) Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) {
- // TODO(toddw): Replace with new Describe__ implementation.
- result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
- result.Methods["Put"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "Profiles", Type: 61},
- {Name: "Envelope", Type: 66},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 67},
- },
- }
- result.Methods["Remove"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "Profile", Type: 3},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 67},
- },
- }
-
- result.TypeDefs = []__vdlutil.Any{
- __wiretype.MapType{Key: 0x3, Elem: 0x3, Name: "", Tags: []string(nil)}, __wiretype.StructType{
- []__wiretype.FieldType{
- __wiretype.FieldType{Type: 0x3, Name: "Title"},
- __wiretype.FieldType{Type: 0x3d, Name: "Args"},
- __wiretype.FieldType{Type: 0x3, Name: "Binary"},
- __wiretype.FieldType{Type: 0x3d, Name: "Env"},
- __wiretype.FieldType{Type: 0x41, Name: "Packages"},
- },
- "v.io/core/veyron2/services/mgmt/application.Envelope", []string(nil)},
- __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
- var ss __ipc.ServiceSignature
- var firstAdded int
- ss, _ = s.ApplicationServerStub.Signature(ctx)
- firstAdded = len(result.TypeDefs)
- for k, v := range ss.Methods {
- for i, _ := range v.InArgs {
- if v.InArgs[i].Type >= __wiretype.TypeIDFirst {
- v.InArgs[i].Type += __wiretype.TypeID(firstAdded)
- }
- }
- for i, _ := range v.OutArgs {
- if v.OutArgs[i].Type >= __wiretype.TypeIDFirst {
- v.OutArgs[i].Type += __wiretype.TypeID(firstAdded)
- }
- }
- if v.InStream >= __wiretype.TypeIDFirst {
- v.InStream += __wiretype.TypeID(firstAdded)
- }
- if v.OutStream >= __wiretype.TypeIDFirst {
- v.OutStream += __wiretype.TypeID(firstAdded)
- }
- result.Methods[k] = v
- }
- //TODO(bprosnitz) combine type definitions from embeded interfaces in a way that doesn't cause duplication.
- for _, d := range ss.TypeDefs {
- switch wt := d.(type) {
- case __wiretype.SliceType:
- if wt.Elem >= __wiretype.TypeIDFirst {
- wt.Elem += __wiretype.TypeID(firstAdded)
- }
- d = wt
- case __wiretype.ArrayType:
- if wt.Elem >= __wiretype.TypeIDFirst {
- wt.Elem += __wiretype.TypeID(firstAdded)
- }
- d = wt
- case __wiretype.MapType:
- if wt.Key >= __wiretype.TypeIDFirst {
- wt.Key += __wiretype.TypeID(firstAdded)
- }
- if wt.Elem >= __wiretype.TypeIDFirst {
- wt.Elem += __wiretype.TypeID(firstAdded)
- }
- d = wt
- case __wiretype.StructType:
- for i, fld := range wt.Fields {
- if fld.Type >= __wiretype.TypeIDFirst {
- wt.Fields[i].Type += __wiretype.TypeID(firstAdded)
- }
- }
- d = wt
- // NOTE: other types are missing, but we are upgrading anyways.
- }
- result.TypeDefs = append(result.TypeDefs, d)
- }
-
- return result, nil
-}
-
// ProfileClientMethods is the client interface
// containing Profile methods.
//
@@ -425,17 +315,6 @@
return
}
-func (c implProfileClientStub) Signature(ctx *__context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
- var call __ipc.Call
- if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&o0, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
// ProfileServerMethods is the interface a server writer
// implements for Profile.
//
@@ -469,8 +348,6 @@
ProfileServerStubMethods
// Describe the Profile interfaces.
Describe__() []__ipc.InterfaceDesc
- // Signature will be replaced with Describe__.
- Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error)
}
// ProfileServer returns a server stub for Profile.
@@ -559,106 +436,3 @@
},
},
}
-
-func (s implProfileServerStub) Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) {
- // TODO(toddw): Replace with new Describe__ implementation.
- result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
- result.Methods["Put"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "Specification", Type: 70},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 71},
- },
- }
- result.Methods["Remove"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{},
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 71},
- },
- }
- result.Methods["Specification"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{},
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 70},
- {Name: "", Type: 71},
- },
- }
-
- result.TypeDefs = []__vdlutil.Any{
- __wiretype.NamedPrimitiveType{Type: 0x3, Name: "v.io/core/veyron2/services/mgmt/build.Architecture", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x3, Name: "v.io/core/veyron2/services/mgmt/build.OperatingSystem", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x3, Name: "v.io/core/veyron2/services/mgmt/build.Format", Tags: []string(nil)}, __wiretype.StructType{
- []__wiretype.FieldType{
- __wiretype.FieldType{Type: 0x3, Name: "Name"},
- __wiretype.FieldType{Type: 0x3, Name: "MajorVersion"},
- __wiretype.FieldType{Type: 0x3, Name: "MinorVersion"},
- },
- "v.io/core/veyron/services/mgmt/profile.Library", []string(nil)},
- __wiretype.MapType{Key: 0x44, Elem: 0x2, Name: "", Tags: []string(nil)}, __wiretype.StructType{
- []__wiretype.FieldType{
- __wiretype.FieldType{Type: 0x3, Name: "Label"},
- __wiretype.FieldType{Type: 0x3, Name: "Description"},
- __wiretype.FieldType{Type: 0x41, Name: "Arch"},
- __wiretype.FieldType{Type: 0x42, Name: "OS"},
- __wiretype.FieldType{Type: 0x43, Name: "Format"},
- __wiretype.FieldType{Type: 0x45, Name: "Libraries"},
- },
- "v.io/core/veyron/services/mgmt/profile.Specification", []string(nil)},
- __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
- var ss __ipc.ServiceSignature
- var firstAdded int
- ss, _ = s.ProfileServerStub.Signature(ctx)
- firstAdded = len(result.TypeDefs)
- for k, v := range ss.Methods {
- for i, _ := range v.InArgs {
- if v.InArgs[i].Type >= __wiretype.TypeIDFirst {
- v.InArgs[i].Type += __wiretype.TypeID(firstAdded)
- }
- }
- for i, _ := range v.OutArgs {
- if v.OutArgs[i].Type >= __wiretype.TypeIDFirst {
- v.OutArgs[i].Type += __wiretype.TypeID(firstAdded)
- }
- }
- if v.InStream >= __wiretype.TypeIDFirst {
- v.InStream += __wiretype.TypeID(firstAdded)
- }
- if v.OutStream >= __wiretype.TypeIDFirst {
- v.OutStream += __wiretype.TypeID(firstAdded)
- }
- result.Methods[k] = v
- }
- //TODO(bprosnitz) combine type definitions from embeded interfaces in a way that doesn't cause duplication.
- for _, d := range ss.TypeDefs {
- switch wt := d.(type) {
- case __wiretype.SliceType:
- if wt.Elem >= __wiretype.TypeIDFirst {
- wt.Elem += __wiretype.TypeID(firstAdded)
- }
- d = wt
- case __wiretype.ArrayType:
- if wt.Elem >= __wiretype.TypeIDFirst {
- wt.Elem += __wiretype.TypeID(firstAdded)
- }
- d = wt
- case __wiretype.MapType:
- if wt.Key >= __wiretype.TypeIDFirst {
- wt.Key += __wiretype.TypeID(firstAdded)
- }
- if wt.Elem >= __wiretype.TypeIDFirst {
- wt.Elem += __wiretype.TypeID(firstAdded)
- }
- d = wt
- case __wiretype.StructType:
- for i, fld := range wt.Fields {
- if fld.Type >= __wiretype.TypeIDFirst {
- wt.Fields[i].Type += __wiretype.TypeID(firstAdded)
- }
- }
- d = wt
- // NOTE: other types are missing, but we are upgrading anyways.
- }
- result.TypeDefs = append(result.TypeDefs, d)
- }
-
- return result, nil
-}
diff --git a/services/mounttable/lib/collection_test_interface.vdl.go b/services/mounttable/lib/collection_test_interface.vdl.go
index 621160f..612f212 100644
--- a/services/mounttable/lib/collection_test_interface.vdl.go
+++ b/services/mounttable/lib/collection_test_interface.vdl.go
@@ -8,15 +8,8 @@
__veyron2 "v.io/core/veyron2"
__context "v.io/core/veyron2/context"
__ipc "v.io/core/veyron2/ipc"
- __vdlutil "v.io/core/veyron2/vdl/vdlutil"
- __wiretype "v.io/core/veyron2/wiretype"
)
-// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where __wiretype is unused in VDL pacakges where only
-// bootstrap types are used on interfaces.
-const _ = __wiretype.TypeIDInvalid
-
// CollectionClientMethods is the client interface
// containing Collection methods.
type CollectionClientMethods interface {
@@ -81,17 +74,6 @@
return
}
-func (c implCollectionClientStub) Signature(ctx *__context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
- var call __ipc.Call
- if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&o0, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
// CollectionServerMethods is the interface a server writer
// implements for Collection.
type CollectionServerMethods interface {
@@ -116,8 +98,6 @@
CollectionServerStubMethods
// Describe the Collection interfaces.
Describe__() []__ipc.InterfaceDesc
- // Signature will be replaced with Describe__.
- Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error)
}
// CollectionServer returns a server stub for Collection.
@@ -187,29 +167,3 @@
},
},
}
-
-func (s implCollectionServerStub) Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) {
- // TODO(toddw): Replace with new Describe__ implementation.
- result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
- result.Methods["Export"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "Val", Type: 3},
- {Name: "Overwrite", Type: 2},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 65},
- },
- }
- result.Methods["Lookup"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{},
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 67},
- {Name: "", Type: 65},
- },
- }
-
- result.TypeDefs = []__vdlutil.Any{
- __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x42, Name: "", Tags: []string(nil)}}
-
- return result, nil
-}
diff --git a/services/mounttable/lib/neighborhood_test.go b/services/mounttable/lib/neighborhood_test.go
index 7b48e53..6f197d6 100644
--- a/services/mounttable/lib/neighborhood_test.go
+++ b/services/mounttable/lib/neighborhood_test.go
@@ -83,13 +83,13 @@
client := veyron2.GetClient(rootCtx)
name := naming.JoinAddressName(estr, serverName+"/"+expectedSuffix)
- call, cerr := client.StartCall(rootCtx, name, "ResolveStepX", nil, options.NoResolve{})
+ call, cerr := client.StartCall(rootCtx, name, "ResolveStep", nil, options.NoResolve{})
if cerr != nil {
- boom(t, "ResolveStepX.StartCall: %s", cerr)
+ boom(t, "ResolveStep.StartCall: %s", cerr)
}
var entry naming.VDLMountEntry
if cerr = call.Finish(&entry, &err); cerr != nil {
- boom(t, "ResolveStepX: %s", cerr)
+ boom(t, "ResolveStep: %s", cerr)
}
// Resolution returned something. Make sure its correct.
diff --git a/services/security/discharger.vdl.go b/services/security/discharger.vdl.go
index c98b9b6..46805eb 100644
--- a/services/security/discharger.vdl.go
+++ b/services/security/discharger.vdl.go
@@ -11,14 +11,8 @@
__context "v.io/core/veyron2/context"
__ipc "v.io/core/veyron2/ipc"
__vdlutil "v.io/core/veyron2/vdl/vdlutil"
- __wiretype "v.io/core/veyron2/wiretype"
)
-// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where __wiretype is unused in VDL pacakges where only
-// bootstrap types are used on interfaces.
-const _ = __wiretype.TypeIDInvalid
-
// DischargerClientMethods is the client interface
// containing Discharger methods.
//
@@ -75,17 +69,6 @@
return
}
-func (c implDischargerClientStub) Signature(ctx *__context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
- var call __ipc.Call
- if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&o0, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
// DischargerServerMethods is the interface a server writer
// implements for Discharger.
//
@@ -113,8 +96,6 @@
DischargerServerStubMethods
// Describe the Discharger interfaces.
Describe__() []__ipc.InterfaceDesc
- // Signature will be replaced with Describe__.
- Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error)
}
// DischargerServer returns a server stub for Discharger.
@@ -174,30 +155,3 @@
},
},
}
-
-func (s implDischargerServerStub) Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) {
- // TODO(toddw): Replace with new Describe__ implementation.
- result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
- result.Methods["Discharge"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "Caveat", Type: 65},
- {Name: "Impetus", Type: 69},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "Discharge", Type: 65},
- {Name: "err", Type: 70},
- },
- }
-
- result.TypeDefs = []__vdlutil.Any{
- __wiretype.NamedPrimitiveType{Type: 0x1, Name: "anydata", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x3, Name: "v.io/core/veyron2/security.BlessingPattern", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x42, Name: "", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x41, Name: "", Tags: []string(nil)}, __wiretype.StructType{
- []__wiretype.FieldType{
- __wiretype.FieldType{Type: 0x43, Name: "Server"},
- __wiretype.FieldType{Type: 0x3, Name: "Method"},
- __wiretype.FieldType{Type: 0x44, Name: "Arguments"},
- },
- "v.io/core/veyron2/security.DischargeImpetus", []string(nil)},
- __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}}
-
- return result, nil
-}
diff --git a/tools/mgmt/device/devicemanager_mock_test.go b/tools/mgmt/device/devicemanager_mock_test.go
index 15b0733..859613b 100644
--- a/tools/mgmt/device/devicemanager_mock_test.go
+++ b/tools/mgmt/device/devicemanager_mock_test.go
@@ -77,6 +77,7 @@
type InstallStimulus struct {
fun string
appName string
+ config device.Config
}
type InstallResponse struct {
@@ -85,7 +86,7 @@
}
func (mni *mockDeviceInvoker) Install(call ipc.ServerContext, appName string, config device.Config) (string, error) {
- ir := mni.tape.Record(InstallStimulus{"Install", appName})
+ ir := mni.tape.Record(InstallStimulus{"Install", appName, config})
r := ir.(InstallResponse)
return r.appId, r.err
}
diff --git a/tools/mgmt/device/impl.go b/tools/mgmt/device/impl.go
index 9a6aaf9..b62fb96 100644
--- a/tools/mgmt/device/impl.go
+++ b/tools/mgmt/device/impl.go
@@ -1,6 +1,7 @@
package main
import (
+ "encoding/json"
"fmt"
"v.io/core/veyron2"
@@ -16,19 +17,29 @@
Name: "install",
Short: "Install the given application.",
Long: "Install the given application.",
- ArgsName: "<device> <application>",
+ ArgsName: "<device> <application> [<config override>]",
ArgsLong: `
<device> is the veyron object name of the device manager's app service.
-<application> is the veyron object name of the application.`,
+
+<application> is the veyron object name of the application.
+
+<config override> is an optional JSON-encoded device.Config object, of the form:
+ '{"flag1":"value1","flag2":"value2"}'.`,
}
func runInstall(cmd *cmdline.Command, args []string) error {
- if expected, got := 2, len(args); expected != got {
- return cmd.UsageErrorf("install: incorrect number of arguments, expected %d, got %d", expected, got)
+ if expectedMin, expectedMax, got := 2, 3, len(args); expectedMin > got || expectedMax < got {
+ return cmd.UsageErrorf("install: incorrect number of arguments, expected between %d and %d, got %d", expectedMin, expectedMax, got)
}
deviceName, appName := args[0], args[1]
- // TODO(caprita): Add support for config override.
- appID, err := device.ApplicationClient(deviceName).Install(gctx, appName, nil)
+ var cfg device.Config
+ if len(args) > 2 {
+ jsonConfig := args[2]
+ if err := json.Unmarshal([]byte(jsonConfig), &cfg); err != nil {
+ return fmt.Errorf("Unmarshal(%v) failed: %v", jsonConfig, err)
+ }
+ }
+ appID, err := device.ApplicationClient(deviceName).Install(gctx, appName, cfg)
if err != nil {
return fmt.Errorf("Install failed: %v", err)
}
diff --git a/tools/mgmt/device/impl_test.go b/tools/mgmt/device/impl_test.go
index 8425bec..a72c411 100644
--- a/tools/mgmt/device/impl_test.go
+++ b/tools/mgmt/device/impl_test.go
@@ -2,6 +2,7 @@
import (
"bytes"
+ "encoding/json"
"fmt"
"reflect"
"strings"
@@ -173,47 +174,81 @@
var stdout, stderr bytes.Buffer
cmd.Init(nil, &stdout, &stderr)
deviceName := naming.JoinAddressName(endpoint.String(), "")
-
- if err := cmd.Execute([]string{"install", "blech"}); err == nil {
- t.Fatalf("wrongly failed to receive a non-nil error.")
- }
- if got, expected := len(tape.Play()), 0; got != expected {
- t.Errorf("invalid call sequence. Got %v, want %v", got, expected)
- }
- tape.Rewind()
- stdout.Reset()
-
- if err := cmd.Execute([]string{"install", "blech1", "blech2", "blech3"}); err == nil {
- t.Fatalf("wrongly failed to receive a non-nil error.")
- }
- if got, expected := len(tape.Play()), 0; got != expected {
- t.Errorf("invalid call sequence. Got %v, want %v", got, expected)
- }
- tape.Rewind()
- stdout.Reset()
-
appId := "myBestAppID"
- tape.SetResponses([]interface{}{InstallResponse{
- appId: appId,
- err: nil,
- }})
- if err := cmd.Execute([]string{"install", deviceName, "myBestApp"}); err != nil {
- t.Fatalf("%v", err)
+ cfg := device.Config{"someflag": "somevalue"}
+ for i, c := range []struct {
+ args []string
+ config device.Config
+ shouldErr bool
+ tapeResponse interface{}
+ expectedTape interface{}
+ }{
+ {
+ []string{"install", "blech"},
+ nil,
+ true,
+ nil,
+ nil,
+ },
+ {
+ []string{"install", "blech1", "blech2", "blech3", "blech4"},
+ nil,
+ true,
+ nil,
+ nil,
+ },
+ {
+ []string{"install", deviceName, "myBestApp", "not-valid-json"},
+ nil,
+ true,
+ nil,
+ nil,
+ },
+ {
+ []string{"install", deviceName, "myBestApp"},
+ nil,
+ false,
+ InstallResponse{appId, nil},
+ InstallStimulus{"Install", "myBestApp", nil},
+ },
+ {
+ []string{"install", deviceName, "myBestApp"},
+ cfg,
+ false,
+ InstallResponse{appId, nil},
+ InstallStimulus{"Install", "myBestApp", cfg},
+ },
+ } {
+ tape.SetResponses([]interface{}{c.tapeResponse})
+ if c.config != nil {
+ jsonConfig, err := json.Marshal(c.config)
+ if err != nil {
+ t.Fatalf("test case %d: Marshal(%v) failed: %v", i, c.config, err)
+ }
+ c.args = append(c.args, string(jsonConfig))
+ }
+ err := cmd.Execute(c.args)
+ if c.shouldErr {
+ if err == nil {
+ t.Fatalf("test case %d: wrongly failed to receive a non-nil error.", i)
+ }
+ if got, expected := len(tape.Play()), 0; got != expected {
+ t.Errorf("test case %d: invalid call sequence. Got %v, want %v", got, expected)
+ }
+ } else {
+ if err != nil {
+ t.Fatalf("test case %d: %v", i, err)
+ }
+ if expected, got := fmt.Sprintf("Successfully installed: %q", naming.Join(deviceName, appId)), strings.TrimSpace(stdout.String()); got != expected {
+ t.Fatalf("test case %d: Unexpected output from Install. Got %q, expected %q", i, got, expected)
+ }
+ if got, expected := tape.Play(), []interface{}{c.expectedTape}; !reflect.DeepEqual(expected, got) {
+ t.Errorf("test case %d: invalid call sequence. Got %v, want %v", i, got, expected)
+ }
+ }
+ tape.Rewind()
+ stdout.Reset()
}
-
- eb := new(bytes.Buffer)
- fmt.Fprintf(eb, "Successfully installed: %q", naming.Join(deviceName, appId))
- if expected, got := eb.String(), strings.TrimSpace(stdout.String()); got != expected {
- t.Fatalf("Unexpected output from Install. Got %q, expected %q", got, expected)
- }
- expected := []interface{}{
- InstallStimulus{"Install", "myBestApp"},
- }
- if got := tape.Play(); !reflect.DeepEqual(expected, got) {
- t.Errorf("unexpected result. Got %v want %v", got, expected)
- }
- tape.Rewind()
- stdout.Reset()
}
func TestClaimCommand(t *testing.T) {
diff --git a/tools/namespace/impl.go b/tools/namespace/impl.go
index b2df4db..cae7c40 100644
--- a/tools/namespace/impl.go
+++ b/tools/namespace/impl.go
@@ -145,12 +145,12 @@
ns := veyron2.GetNamespace(ctx)
- servers, err := ns.Resolve(ctx, name)
+ me, err := ns.Resolve(ctx, name)
if err != nil {
vlog.Infof("ns.Resolve(%q) failed: %v", name, err)
return err
}
- for _, s := range servers {
+ for _, s := range me.Names() {
fmt.Fprintln(cmd.Stdout(), s)
}
return nil
@@ -176,9 +176,9 @@
ns := veyron2.GetNamespace(ctx)
- e, err := ns.ResolveToMountTableX(ctx, name)
+ e, err := ns.ResolveToMountTable(ctx, name)
if err != nil {
- vlog.Infof("ns.ResolveToMountTableX(%q) failed: %v", name, err)
+ vlog.Infof("ns.ResolveToMountTable(%q) failed: %v", name, err)
return err
}
for _, s := range e.Servers {
diff --git a/tools/naming/simulator/shell_functions.go b/tools/naming/simulator/shell_functions.go
index 396fe6d..552635b 100644
--- a/tools/naming/simulator/shell_functions.go
+++ b/tools/naming/simulator/shell_functions.go
@@ -87,18 +87,19 @@
return nil
}
-type resolver func(ctx *context.T, name string, opts ...naming.ResolveOpt) (names []string, err error)
+type resolver func(ctx *context.T, name string, opts ...naming.ResolveOpt) (me *naming.MountEntry, err error)
func resolve(fn resolver, stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
if err := checkArgs(args[1:], 1, "<name>"); err != nil {
return err
}
name := args[1]
- servers, err := fn(ctx, name)
+ me, err := fn(ctx, name)
if err != nil {
fmt.Fprintf(stdout, "RN=0\n")
return err
}
+ servers := me.Names()
fmt.Fprintf(stdout, "RN=%d\n", len(servers))
for i, s := range servers {
fmt.Fprintf(stdout, "R%d=%s\n", i, s)
diff --git a/tools/vrpc/test_base/test_base.vdl.go b/tools/vrpc/test_base/test_base.vdl.go
index 4cdfd98..af0e095 100644
--- a/tools/vrpc/test_base/test_base.vdl.go
+++ b/tools/vrpc/test_base/test_base.vdl.go
@@ -10,15 +10,8 @@
__context "v.io/core/veyron2/context"
__ipc "v.io/core/veyron2/ipc"
__vdl "v.io/core/veyron2/vdl"
- __vdlutil "v.io/core/veyron2/vdl/vdlutil"
- __wiretype "v.io/core/veyron2/wiretype"
)
-// TODO(toddw): Remove this line once the new signature support is done.
-// It corrects a bug where __wiretype is unused in VDL pacakges where only
-// bootstrap types are used on interfaces.
-const _ = __wiretype.TypeIDInvalid
-
type Struct struct {
X int32
Y int32
@@ -276,17 +269,6 @@
return
}
-func (c implTypeTesterClientStub) Signature(ctx *__context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) {
- var call __ipc.Call
- if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil {
- return
- }
- if ierr := call.Finish(&o0, &err); ierr != nil {
- err = ierr
- }
- return
-}
-
// TypeTesterZStreamClientStream is the client stream for TypeTester.ZStream.
type TypeTesterZStreamClientStream interface {
// RecvStream returns the receiver side of the TypeTester.ZStream client stream.
@@ -419,8 +401,6 @@
TypeTesterServerStubMethods
// Describe the TypeTester interfaces.
Describe__() []__ipc.InterfaceDesc
- // Signature will be replaced with Describe__.
- Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error)
}
// TypeTesterServer returns a server stub for TypeTester.
@@ -705,176 +685,6 @@
},
}
-func (s implTypeTesterServerStub) Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) {
- // TODO(toddw): Replace with new Describe__ implementation.
- result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)}
- result.Methods["EchoBool"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "I1", Type: 2},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "O1", Type: 2},
- {Name: "err", Type: 65},
- },
- }
- result.Methods["EchoByte"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "I1", Type: 66},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "O1", Type: 66},
- {Name: "err", Type: 65},
- },
- }
- result.Methods["EchoFloat32"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "I1", Type: 25},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "O1", Type: 25},
- {Name: "err", Type: 65},
- },
- }
- result.Methods["EchoFloat64"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "I1", Type: 26},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "O1", Type: 26},
- {Name: "err", Type: 65},
- },
- }
- result.Methods["EchoInt32"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "I1", Type: 36},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "O1", Type: 36},
- {Name: "err", Type: 65},
- },
- }
- result.Methods["EchoInt64"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "I1", Type: 37},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "O1", Type: 37},
- {Name: "err", Type: 65},
- },
- }
- result.Methods["EchoString"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "I1", Type: 3},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "O1", Type: 3},
- {Name: "err", Type: 65},
- },
- }
- result.Methods["EchoUint32"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "I1", Type: 52},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "O1", Type: 52},
- {Name: "err", Type: 65},
- },
- }
- result.Methods["EchoUint64"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "I1", Type: 53},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "O1", Type: 53},
- {Name: "err", Type: 65},
- },
- }
- result.Methods["XEchoArray"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "I1", Type: 67},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "O1", Type: 67},
- {Name: "err", Type: 65},
- },
- }
- result.Methods["XEchoMap"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "I1", Type: 68},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "O1", Type: 68},
- {Name: "err", Type: 65},
- },
- }
- result.Methods["XEchoSet"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "I1", Type: 69},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "O1", Type: 69},
- {Name: "err", Type: 65},
- },
- }
- result.Methods["XEchoSlice"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "I1", Type: 70},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "O1", Type: 70},
- {Name: "err", Type: 65},
- },
- }
- result.Methods["XEchoStruct"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "I1", Type: 71},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "O1", Type: 71},
- {Name: "err", Type: 65},
- },
- }
- result.Methods["YMultiArg"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "I1", Type: 36},
- {Name: "I2", Type: 36},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "O1", Type: 36},
- {Name: "O2", Type: 36},
- {Name: "err", Type: 65},
- },
- }
- result.Methods["YNoArgs"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{},
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 65},
- },
- }
- result.Methods["ZStream"] = __ipc.MethodSignature{
- InArgs: []__ipc.MethodArgument{
- {Name: "NumStreamItems", Type: 36},
- {Name: "StreamItem", Type: 2},
- },
- OutArgs: []__ipc.MethodArgument{
- {Name: "", Type: 65},
- },
-
- OutStream: 2,
- }
-
- result.TypeDefs = []__vdlutil.Any{
- __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}, __wiretype.NamedPrimitiveType{Type: 0x32, Name: "byte", Tags: []string(nil)}, __wiretype.ArrayType{Elem: 0x24, Len: 0x2, Name: "", Tags: []string(nil)}, __wiretype.MapType{Key: 0x24, Elem: 0x3, Name: "", Tags: []string(nil)}, __wiretype.MapType{Key: 0x24, Elem: 0x2, Name: "", Tags: []string(nil)}, __wiretype.SliceType{Elem: 0x24, Name: "", Tags: []string(nil)}, __wiretype.StructType{
- []__wiretype.FieldType{
- __wiretype.FieldType{Type: 0x24, Name: "X"},
- __wiretype.FieldType{Type: 0x24, Name: "Y"},
- },
- "v.io/core/veyron/tools/vrpc/test_base.Struct", []string(nil)},
- }
-
- return result, nil
-}
-
// TypeTesterZStreamServerStream is the server stream for TypeTester.ZStream.
type TypeTesterZStreamServerStream interface {
// SendStream returns the send side of the TypeTester.ZStream server stream.
diff --git a/tools/vrpc/vrpc_test.go b/tools/vrpc/vrpc_test.go
index f74b40d..3b71012 100644
--- a/tools/vrpc/vrpc_test.go
+++ b/tools/vrpc/vrpc_test.go
@@ -179,11 +179,6 @@
ZStream(NumStreamItems int32, StreamItem bool) stream<_, bool> error
}
-// The empty interface contains methods not attached to any interface.
-type <empty> interface {
- Signature() ("v.io/core/veyron2/ipc".ServiceSignature | error)
-}
-
// Reserved methods implemented by the IPC framework. Each method name is prefixed with a double underscore "__".
type __Reserved interface {
// Glob returns all entries matching the pattern.
@@ -228,25 +223,6 @@
X int32
Y int32
}
-
-type "v.io/core/veyron2/ipc".MethodArgument struct {
- Name string
- Type "v.io/core/veyron2/wiretype".TypeID
-}
-
-type "v.io/core/veyron2/ipc".MethodSignature struct {
- InArgs []"v.io/core/veyron2/ipc".MethodArgument
- OutArgs []"v.io/core/veyron2/ipc".MethodArgument
- InStream "v.io/core/veyron2/wiretype".TypeID
- OutStream "v.io/core/veyron2/wiretype".TypeID
-}
-
-type "v.io/core/veyron2/ipc".ServiceSignature struct {
- TypeDefs []any
- Methods map[string]"v.io/core/veyron2/ipc".MethodSignature
-}
-
-type "v.io/core/veyron2/wiretype".TypeID uint64
`
if got, want := stdout.String(), wantSig; got != want {
t.Errorf("got stdout %q, want %q", got, want)