Skip to content

Commit

Permalink
misc cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Mason <[email protected]>
  • Loading branch information
ajm188 committed Jun 1, 2021
1 parent 88b1ad4 commit 8536013
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 53 deletions.
18 changes: 10 additions & 8 deletions go/cmd/vtctldclient/internal/command/routing_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
)

Expand Down
9 changes: 5 additions & 4 deletions go/cmd/vtctldclient/internal/command/serving_graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
)

Expand Down
82 changes: 41 additions & 41 deletions go/vt/vtctl/grpcvtctldserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 8536013

Please sign in to comment.