From 8536013788cdd90af83111cbbc03852a0e36af28 Mon Sep 17 00:00:00 2001 From: Andrew Mason Date: Mon, 31 May 2021 21:40:31 -0400 Subject: [PATCH] misc cleanup Signed-off-by: Andrew Mason --- .../internal/command/routing_rules.go | 18 ++-- .../internal/command/serving_graph.go | 9 +- go/vt/vtctl/grpcvtctldserver/server_test.go | 82 +++++++++---------- 3 files changed, 56 insertions(+), 53 deletions(-) diff --git a/go/cmd/vtctldclient/internal/command/routing_rules.go b/go/cmd/vtctldclient/internal/command/routing_rules.go index 645bb39611a..e43aa49c915 100644 --- a/go/cmd/vtctldclient/internal/command/routing_rules.go +++ b/go/cmd/vtctldclient/internal/command/routing_rules.go @@ -34,17 +34,19 @@ import ( var ( // ApplyRoutingRules makes an ApplyRoutingRules gRPC call to a vtctld. ApplyRoutingRules = &cobra.Command{ - Use: "ApplyRoutingRules {--rules RULES | --rules-file RULES_FILE} [--cells=c1,c2,...] [--skip-rebuild] [--dry-run]", - Short: "Applies the VSchema routing rules.", - Args: cobra.NoArgs, - RunE: commandApplyRoutingRules, + Use: "ApplyRoutingRules {--rules RULES | --rules-file RULES_FILE} [--cells=c1,c2,...] [--skip-rebuild] [--dry-run]", + Short: "Applies the VSchema routing rules.", + DisableFlagsInUseLine: true, + Args: cobra.NoArgs, + RunE: commandApplyRoutingRules, } // GetRoutingRules makes a GetRoutingRules gRPC call to a vtctld. GetRoutingRules = &cobra.Command{ - Use: "GetRoutingRules", - Short: "Displays the VSchema routing rules.", - Args: cobra.NoArgs, - RunE: commandGetRoutingRules, + Use: "GetRoutingRules", + Short: "Displays the VSchema routing rules.", + DisableFlagsInUseLine: true, + Args: cobra.NoArgs, + RunE: commandGetRoutingRules, } ) diff --git a/go/cmd/vtctldclient/internal/command/serving_graph.go b/go/cmd/vtctldclient/internal/command/serving_graph.go index 93743c91b55..2c7065088cd 100644 --- a/go/cmd/vtctldclient/internal/command/serving_graph.go +++ b/go/cmd/vtctldclient/internal/command/serving_graph.go @@ -53,10 +53,11 @@ var ( } // RebuildVSchemaGraph makes a RebuildVSchemaGraph gRPC call to a vtctld. RebuildVSchemaGraph = &cobra.Command{ - Use: "RebuildVSchemaGraph [--cells=c1,c2,...]", - Short: "Rebuilds the cell-specific SrvVSchema from the global VSchema objects in the provided cells (or all cells if none provided).", - Args: cobra.NoArgs, - RunE: commandRebuildVSchemaGraph, + Use: "RebuildVSchemaGraph [--cells=c1,c2,...]", + Short: "Rebuilds the cell-specific SrvVSchema from the global VSchema objects in the provided cells (or all cells if none provided).", + DisableFlagsInUseLine: true, + Args: cobra.NoArgs, + RunE: commandRebuildVSchemaGraph, } ) diff --git a/go/vt/vtctl/grpcvtctldserver/server_test.go b/go/vt/vtctl/grpcvtctldserver/server_test.go index 07aa65c0c5f..7eeaf3008dd 100644 --- a/go/vt/vtctl/grpcvtctldserver/server_test.go +++ b/go/vt/vtctl/grpcvtctldserver/server_test.go @@ -2859,47 +2859,6 @@ func TestGetRoutingRules(t *testing.T) { } } -func TestGetTablet(t *testing.T) { - t.Parallel() - - ctx := context.Background() - ts := memorytopo.NewServer("cell1") - vtctld := testutil.NewVtctldServerWithTabletManagerClient(t, ts, nil, func(ts *topo.Server) vtctlservicepb.VtctldServer { - return NewVtctldServer(ts) - }) - - tablet := &topodatapb.Tablet{ - Alias: &topodatapb.TabletAlias{ - Cell: "cell1", - Uid: 100, - }, - Hostname: "localhost", - Keyspace: "testkeyspace", - Shard: "-", - Type: topodatapb.TabletType_REPLICA, - } - - testutil.AddTablet(ctx, t, ts, tablet, nil) - - resp, err := vtctld.GetTablet(ctx, &vtctldatapb.GetTabletRequest{ - TabletAlias: &topodatapb.TabletAlias{ - Cell: "cell1", - Uid: 100, - }, - }) - assert.NoError(t, err) - utils.MustMatch(t, resp.Tablet, tablet) - - // not found - _, err = vtctld.GetTablet(ctx, &vtctldatapb.GetTabletRequest{ - TabletAlias: &topodatapb.TabletAlias{ - Cell: "cell1", - Uid: 101, - }, - }) - assert.Error(t, err) -} - func TestGetSchema(t *testing.T) { ctx := context.Background() ts := memorytopo.NewServer("zone1") @@ -3631,6 +3590,47 @@ func TestGetSrvVSchemas(t *testing.T) { } } +func TestGetTablet(t *testing.T) { + t.Parallel() + + ctx := context.Background() + ts := memorytopo.NewServer("cell1") + vtctld := testutil.NewVtctldServerWithTabletManagerClient(t, ts, nil, func(ts *topo.Server) vtctlservicepb.VtctldServer { + return NewVtctldServer(ts) + }) + + tablet := &topodatapb.Tablet{ + Alias: &topodatapb.TabletAlias{ + Cell: "cell1", + Uid: 100, + }, + Hostname: "localhost", + Keyspace: "testkeyspace", + Shard: "-", + Type: topodatapb.TabletType_REPLICA, + } + + testutil.AddTablet(ctx, t, ts, tablet, nil) + + resp, err := vtctld.GetTablet(ctx, &vtctldatapb.GetTabletRequest{ + TabletAlias: &topodatapb.TabletAlias{ + Cell: "cell1", + Uid: 100, + }, + }) + assert.NoError(t, err) + utils.MustMatch(t, resp.Tablet, tablet) + + // not found + _, err = vtctld.GetTablet(ctx, &vtctldatapb.GetTabletRequest{ + TabletAlias: &topodatapb.TabletAlias{ + Cell: "cell1", + Uid: 101, + }, + }) + assert.Error(t, err) +} + func TestGetTablets(t *testing.T) { t.Parallel()