TBR: vrpc will no longer show reserved interfaces by default, instead
there's a flag. This in response to:
https://github.com/veyron/release-issues/issues/1581
- also get rid of annoying error message in rpc/client.go
MultiPart: 1/2
Change-Id: I08d75bdc5a59384c6dc195ebb9ffc4d8f9ac3cc5
diff --git a/cmd/vrpc/doc.go b/cmd/vrpc/doc.go
index f281770..ff54449 100644
--- a/cmd/vrpc/doc.go
+++ b/cmd/vrpc/doc.go
@@ -79,6 +79,8 @@
-insecure=false
If true, skip server authentication. This means that the client will reveal
its blessings to servers that it may not recognize.
+ -show-reserved=false
+ if true, also show the signatures of reserved methods
Vrpc Call
diff --git a/cmd/vrpc/vrpc.go b/cmd/vrpc/vrpc.go
index bde1970..590e02d 100644
--- a/cmd/vrpc/vrpc.go
+++ b/cmd/vrpc/vrpc.go
@@ -16,6 +16,7 @@
"v.io/v23"
"v.io/v23/context"
+ "v.io/v23/naming"
"v.io/v23/options"
"v.io/v23/rpc"
"v.io/v23/rpc/reserved"
@@ -30,8 +31,9 @@
)
var (
- gctx *context.T
- flagInsecure bool
+ gctx *context.T
+ flagInsecure bool
+ flagShowReserved bool
)
func main() {
@@ -50,6 +52,8 @@
)
cmdSignature.Flags.BoolVar(&flagInsecure, insecureName, insecureVal, insecureDesc)
cmdIdentify.Flags.BoolVar(&flagInsecure, insecureName, insecureVal, insecureDesc)
+
+ cmdSignature.Flags.BoolVar(&flagShowReserved, "show-reserved", false, "if true, also show the signatures of reserved methods")
}
var cmdVRPC = &cmdline.Command{
@@ -166,6 +170,9 @@
return fmt.Errorf("Signature failed: %v", err)
}
for i, iface := range ifacesSig {
+ if !flagShowReserved && naming.IsReserved(iface.Name) {
+ continue
+ }
if i > 0 {
fmt.Fprintln(cmd.Stdout())
}
diff --git a/cmd/vrpc/vrpc_test.go b/cmd/vrpc/vrpc_test.go
index 5d380c2..190efc4 100644
--- a/cmd/vrpc/vrpc_test.go
+++ b/cmd/vrpc/vrpc_test.go
@@ -136,16 +136,29 @@
return name, shutdown
}
-func TestSignature(t *testing.T) {
+func testSignature(t *testing.T, showReserved bool, wantSig string) {
name, shutdown := initTest(t)
defer shutdown()
var stdout, stderr bytes.Buffer
cmdVRPC.Init(nil, &stdout, &stderr)
- if err := cmdVRPC.Execute([]string{"signature", name}); err != nil {
- t.Errorf("%v", err)
- return
+ args := []string{"signature", name}
+ // The cmdline package won't reparse the flags sent to Execute, so
+ // instead, set the flag variable directly from here.
+ flagShowReserved = showReserved
+ if err := cmdVRPC.Execute(args); err != nil {
+ t.Fatalf("%s: %v", args, err)
}
+
+ if got, want := stdout.String(), wantSig; got != want {
+ t.Errorf("%s: got stdout %s, want %s", args, got, want)
+ }
+ if got, want := stderr.String(), ""; got != want {
+ t.Errorf("%s: got stderr %s, want %s", args, got, want)
+ }
+}
+
+func TestSignatureWithReserved(t *testing.T) {
wantSig := `// TypeTester methods are listed in alphabetical order, to make it easier to
// test Signature output, which sorts methods alphabetically.
type "v.io/x/ref/cmd/vrpc/internal".TypeTester interface {
@@ -219,12 +232,44 @@
Y int32
}
`
- if got, want := stdout.String(), wantSig; got != want {
- t.Errorf("got stdout %q, want %q", got, want)
- }
- if got, want := stderr.String(), ""; got != want {
- t.Errorf("got stderr %q, want %q", got, want)
- }
+ testSignature(t, true, wantSig)
+}
+
+func TestSignatureNoReserved(t *testing.T) {
+ wantSig := `// TypeTester methods are listed in alphabetical order, to make it easier to
+// test Signature output, which sorts methods alphabetically.
+type "v.io/x/ref/cmd/vrpc/internal".TypeTester interface {
+ // Methods to test support for primitive types.
+ EchoBool(I1 bool) (O1 bool | error)
+ EchoByte(I1 byte) (O1 byte | error)
+ EchoFloat32(I1 float32) (O1 float32 | error)
+ EchoFloat64(I1 float64) (O1 float64 | error)
+ EchoInt32(I1 int32) (O1 int32 | error)
+ EchoInt64(I1 int64) (O1 int64 | error)
+ EchoString(I1 string) (O1 string | error)
+ EchoUint32(I1 uint32) (O1 uint32 | error)
+ EchoUint64(I1 uint64) (O1 uint64 | error)
+ // Methods to test support for composite types.
+ XEchoArray(I1 "v.io/x/ref/cmd/vrpc/internal".Array2Int) (O1 "v.io/x/ref/cmd/vrpc/internal".Array2Int | error)
+ XEchoMap(I1 map[int32]string) (O1 map[int32]string | error)
+ XEchoSet(I1 set[int32]) (O1 set[int32] | error)
+ XEchoSlice(I1 []int32) (O1 []int32 | error)
+ XEchoStruct(I1 "v.io/x/ref/cmd/vrpc/internal".Struct) (O1 "v.io/x/ref/cmd/vrpc/internal".Struct | error)
+ // Methods to test support for different number of arguments.
+ YMultiArg(I1 int32, I2 int32) (O1 int32, O2 int32 | error)
+ YNoArgs() error
+ // Methods to test support for streaming.
+ ZStream(NumStreamItems int32, StreamItem bool) stream<_, bool> error
+}
+
+type "v.io/x/ref/cmd/vrpc/internal".Array2Int [2]int32
+
+type "v.io/x/ref/cmd/vrpc/internal".Struct struct {
+ X int32
+ Y int32
+}
+`
+ testSignature(t, false, wantSig)
}
func TestMethodSignature(t *testing.T) {
diff --git a/profiles/internal/rpc/client.go b/profiles/internal/rpc/client.go
index 25ee7fb..728d527 100644
--- a/profiles/internal/rpc/client.go
+++ b/profiles/internal/rpc/client.go
@@ -431,7 +431,6 @@
var blessingPattern security.BlessingPattern
blessingPattern, name = security.SplitPatternName(name)
if resolved, err = c.ns.Resolve(ctx, name, getNamespaceOpts(opts)...); err != nil {
- vlog.Errorf("Resolve: %v", err)
// We always return NoServers as the error so that the caller knows
// that's ok to retry the operation since the name may be registered
// in the near future.