Skip to content

Commit dff6b6e

Browse files
authored
Merge branch 'slack-vitess-r14.0.5' into v14_vtgate_balancer_v2
2 parents f2905ca + 8ce8799 commit dff6b6e

File tree

17 files changed

+2571
-1361
lines changed

17 files changed

+2571
-1361
lines changed

go/cmd/vtctldclient/command/tablets.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ Note: hook names may not contain slash (/) characters.
7373
Args: cobra.MinimumNArgs(2),
7474
RunE: commandExecuteHook,
7575
}
76+
// GetFullStatus makes a FullStatus gRPC call to a vttablet.
77+
GetFullStatus = &cobra.Command{
78+
Use: "GetFullStatus <alias>",
79+
Short: "Outputs a JSON structure that contains full status of MySQL including the replication information, semi-sync information, GTID information among others.",
80+
DisableFlagsInUseLine: true,
81+
Args: cobra.ExactArgs(1),
82+
RunE: commandGetFullStatus,
83+
}
7684
// GetPermissions makes a GetPermissions gRPC call to a vtctld.
7785
GetPermissions = &cobra.Command{
7886
Use: "GetPermissions <tablet_alias>",
@@ -299,6 +307,30 @@ func commandExecuteHook(cmd *cobra.Command, args []string) error {
299307
return nil
300308
}
301309

310+
func commandGetFullStatus(cmd *cobra.Command, args []string) error {
311+
aliasStr := cmd.Flags().Arg(0)
312+
alias, err := topoproto.ParseTabletAlias(aliasStr)
313+
if err != nil {
314+
return err
315+
}
316+
317+
cli.FinishedParsing(cmd)
318+
319+
resp, err := client.GetFullStatus(commandCtx, &vtctldatapb.GetFullStatusRequest{TabletAlias: alias})
320+
if err != nil {
321+
return err
322+
}
323+
324+
data, err := cli.MarshalJSON(resp.Status)
325+
if err != nil {
326+
return err
327+
}
328+
329+
fmt.Printf("%s\n", data)
330+
331+
return nil
332+
}
333+
302334
func commandGetPermissions(cmd *cobra.Command, args []string) error {
303335
alias, err := topoproto.ParseTabletAlias(cmd.Flags().Arg(0))
304336
if err != nil {
@@ -596,6 +628,7 @@ func init() {
596628
Root.AddCommand(DeleteTablets)
597629

598630
Root.AddCommand(ExecuteHook)
631+
Root.AddCommand(GetFullStatus)
599632
Root.AddCommand(GetPermissions)
600633
Root.AddCommand(GetTablet)
601634

go/test/endtoend/cluster/cluster_process.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ type LocalProcessCluster struct {
9292
VtctlMajorVersion int
9393

9494
// standalone executable
95-
VtctlclientProcess VtctlClientProcess
96-
VtctlProcess VtctlProcess
95+
VtctlclientProcess VtctlClientProcess
96+
VtctldClientProcess VtctldClientProcess
97+
VtctlProcess VtctlProcess
9798

9899
// background executable processes
99100
TopoProcess TopoProcess

go/test/endtoend/reparent/newfeaturetest/reparent_test.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ import (
2323
"testing"
2424
"time"
2525

26+
"github.com/stretchr/testify/assert"
27+
"github.com/stretchr/testify/require"
28+
"google.golang.org/protobuf/encoding/protojson"
29+
2630
"vitess.io/vitess/go/mysql"
2731
"vitess.io/vitess/go/test/endtoend/cluster"
2832
"vitess.io/vitess/go/test/endtoend/reparent/utils"
29-
30-
"github.com/stretchr/testify/assert"
31-
"github.com/stretchr/testify/require"
33+
replicationdatapb "vitess.io/vitess/go/vt/proto/replicationdata"
3234
)
3335

3436
// ERS TESTS
@@ -134,7 +136,10 @@ func TestFullStatus(t *testing.T) {
134136
utils.ConfirmReplication(t, tablets[0], []*cluster.Vttablet{tablets[1], tablets[2], tablets[3]})
135137

136138
// Check that full status gives the correct result for a primary tablet
137-
primaryStatus, err := utils.TmcFullStatus(context.Background(), tablets[0])
139+
primaryStatusString, err := clusterInstance.VtctldClientProcess.ExecuteCommandWithOutput("GetFullStatus", tablets[0].Alias)
140+
require.NoError(t, err)
141+
primaryStatus := &replicationdatapb.FullStatus{}
142+
err = protojson.Unmarshal([]byte(primaryStatusString), primaryStatus)
138143
require.NoError(t, err)
139144
assert.NotEmpty(t, primaryStatus.ServerUuid)
140145
assert.NotEmpty(t, primaryStatus.ServerId)
@@ -159,7 +164,10 @@ func TestFullStatus(t *testing.T) {
159164
assert.NotEmpty(t, primaryStatus.VersionComment)
160165

161166
// Check that full status gives the correct result for a replica tablet
162-
replicaStatus, err := utils.TmcFullStatus(context.Background(), tablets[1])
167+
replicaStatusString, err := clusterInstance.VtctldClientProcess.ExecuteCommandWithOutput("GetFullStatus", tablets[1].Alias)
168+
require.NoError(t, err)
169+
replicaStatus := &replicationdatapb.FullStatus{}
170+
err = protojson.Unmarshal([]byte(replicaStatusString), replicaStatus)
163171
require.NoError(t, err)
164172
assert.NotEmpty(t, replicaStatus.ServerUuid)
165173
assert.NotEmpty(t, replicaStatus.ServerId)

go/test/endtoend/reparent/utils/utils.go

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ import (
3636
"vitess.io/vitess/go/sqltypes"
3737
"vitess.io/vitess/go/test/endtoend/cluster"
3838
"vitess.io/vitess/go/vt/log"
39-
tmc "vitess.io/vitess/go/vt/vttablet/grpctmclient"
40-
4139
replicationdatapb "vitess.io/vitess/go/vt/proto/replicationdata"
4240
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
4341
)
@@ -163,8 +161,8 @@ func setupCluster(ctx context.Context, t *testing.T, shardName string, cells []s
163161
}
164162
}
165163
if clusterInstance.VtctlMajorVersion >= 14 {
166-
vtctldClientProcess := cluster.VtctldClientProcessInstance("localhost", clusterInstance.VtctldProcess.GrpcPort, clusterInstance.TmpDirectory)
167-
out, err := vtctldClientProcess.ExecuteCommandWithOutput("SetKeyspaceDurabilityPolicy", KeyspaceName, fmt.Sprintf("--durability-policy=%s", durability))
164+
clusterInstance.VtctldClientProcess = *cluster.VtctldClientProcessInstance("localhost", clusterInstance.VtctldProcess.GrpcPort, clusterInstance.TmpDirectory)
165+
out, err := clusterInstance.VtctldClientProcess.ExecuteCommandWithOutput("SetKeyspaceDurabilityPolicy", KeyspaceName, fmt.Sprintf("--durability-policy=%s", durability))
168166
require.NoError(t, err, out)
169167
}
170168

@@ -327,7 +325,7 @@ func setupShardLegacy(ctx context.Context, t *testing.T, clusterInstance *cluste
327325

328326
//endregion
329327

330-
//region database queries
328+
// region database queries
331329
func getMysqlConnParam(tablet *cluster.Vttablet) mysql.ConnParams {
332330
connParams := mysql.ConnParams{
333331
Uname: username,
@@ -788,18 +786,3 @@ func ReplicationThreadsStatus(t *testing.T, status *replicationdatapb.Status, vt
788786
}
789787
return ioThread, sqlThread
790788
}
791-
792-
// TmcFullStatus retuns the result of the TabletManagerClient RPC FullStatus
793-
func TmcFullStatus(ctx context.Context, tablet *cluster.Vttablet) (*replicationdatapb.FullStatus, error) {
794-
// create tablet manager client
795-
tmClient := tmc.NewClient()
796-
797-
vttablet := getTablet(tablet.GrpcPort)
798-
return tmClient.FullStatus(ctx, vttablet)
799-
}
800-
801-
func getTablet(tabletGrpcPort int) *topodatapb.Tablet {
802-
portMap := make(map[string]int32)
803-
portMap["grpc"] = int32(tabletGrpcPort)
804-
return &topodatapb.Tablet{Hostname: Hostname, PortMap: portMap}
805-
}

0 commit comments

Comments
 (0)