Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/cmd/vtctldclient/command/framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (ft *FakeTablet) StartActionLoop(t *testing.T, ts *topo.Server) {
ft.Tablet = ft.TM.Tablet()

// Register the gRPC server, and starts listening.
grpctmserver.RegisterForTest(ft.RPCServer, ft.TM)
grpctmserver.RegisterForTest(ft.RPCServer, ft.TM, nil)
go ft.RPCServer.Serve(ft.Listener)

// And wait for it to serve, so we don't start using it before it's
Expand Down
18 changes: 8 additions & 10 deletions go/test/endtoend/cluster/cluster_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,19 @@ import (
"testing"
"time"

"github.com/buger/jsonparser"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"

"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/vt/grpcclient"
"vitess.io/vitess/go/vt/log"
replicationdatapb "vitess.io/vitess/go/vt/proto/replicationdata"
tabletmanagerdatapb "vitess.io/vitess/go/vt/proto/tabletmanagerdata"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
"vitess.io/vitess/go/vt/vtgate/grpcvtgateconn"

"github.com/buger/jsonparser"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/vt/vtgate/vtgateconn"

topodatapb "vitess.io/vitess/go/vt/proto/topodata"
tmc "vitess.io/vitess/go/vt/vttablet/grpctmclient"
)

Expand Down Expand Up @@ -104,10 +102,10 @@ func GetPrimaryPosition(t *testing.T, vttablet Vttablet, hostname string) (strin
}

// FullStatus gets the full status from the given tablet.
func FullStatus(t *testing.T, vttablet *Vttablet, hostname string) *replicationdatapb.FullStatus {
func FullStatus(t *testing.T, vttablet *Vttablet, hostname string, req *tabletmanagerdatapb.FullStatusRequest) *replicationdatapb.FullStatus {
ctx := t.Context()
vtablet := getTablet(vttablet.GrpcPort, hostname)
status, err := tmClient.FullStatus(ctx, vtablet)
status, err := tmClient.FullStatus(ctx, vtablet, req)
require.NoError(t, err)
return status
}
Expand Down
51 changes: 51 additions & 0 deletions go/test/endtoend/reparent/plannedreparent/reparent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ import (
"vitess.io/vitess/go/test/endtoend/reparent/utils"
"vitess.io/vitess/go/vt/log"
replicationdatapb "vitess.io/vitess/go/vt/proto/replicationdata"
tabletmanagerdatapb "vitess.io/vitess/go/vt/proto/tabletmanagerdata"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
"vitess.io/vitess/go/vt/topo"
"vitess.io/vitess/go/vt/vtctl/reparentutil/policy"
"vitess.io/vitess/go/vt/vttablet/grpctmclient"
)

func TestPrimaryToSpareStateChangeImpossible(t *testing.T) {
Expand Down Expand Up @@ -567,6 +571,53 @@ func TestFullStatus(t *testing.T) {
assert.True(t, replicaStatus.LogBinEnabled)
assert.Regexp(t, `[58]\.[074].*`, replicaStatus.Version)
assert.NotEmpty(t, replicaStatus.VersionComment)

vttabletVersion, err := cluster.GetMajorVersion("vttablet")
require.NoError(t, err)

// Support for proxying FullStatus RPCs was added in v24
if vttabletVersion >= 24 {
primary, err := clusterInstance.VtctldClientProcess.GetTablet(primaryTablet.Alias)
assert.NoError(t, err)
replica, err := clusterInstance.VtctldClientProcess.GetTablet(replicaTablet.Alias)
assert.NoError(t, err)

c := grpctmclient.NewClient()

// test a proxied request success from primary -> replica
proxiedResp, err := c.FullStatus(t.Context(), primary, &tabletmanagerdatapb.FullStatusRequest{
ProxyTarget: replica,
})
assert.NoError(t, err)
assert.NotNil(t, proxiedResp)
assert.Equal(t, topodatapb.TabletType_REPLICA, proxiedResp.TabletType)
assert.True(t, proxiedResp.ReadOnly)
assert.NotEqual(t, primaryStatus.ServerId, proxiedResp.ServerId)
assert.NotEqual(t, primaryStatus.ServerUuid, proxiedResp.ServerUuid)

// test a proxied request failure to primary -> replica #1
proxiedResp, err = c.FullStatus(t.Context(), primary, &tabletmanagerdatapb.FullStatusRequest{
ProxyTarget: primary,
})
assert.ErrorContains(t, err, "cannot use proxying tablet as a proxy target")
assert.Nil(t, proxiedResp)

// test a proxied request failure to primary -> replica #2
proxiedResp, err = c.FullStatus(t.Context(), primary, &tabletmanagerdatapb.FullStatusRequest{
ProxiedBy: primary.Alias,
ProxyTarget: replica,
})
assert.ErrorContains(t, err, "cannot proxy a request that is already proxied")
assert.Nil(t, proxiedResp)

// test a proxied request failure to primary -> replica #3
proxiedResp, err = c.FullStatus(t.Context(), primary, &tabletmanagerdatapb.FullStatusRequest{
ProxyTarget: replica,
ProxyTimeoutMs: uint64(topo.RemoteOperationTimeout.Milliseconds()) + 100,
})
assert.ErrorContains(t, err, "cannot set a proxy timeout ms greater than")
assert.Nil(t, proxiedResp)
}
}

func getFullStatus(t *testing.T, clusterInstance *cluster.LocalProcessCluster, tablet *cluster.Vttablet) *replicationdatapb.FullStatus {
Expand Down
5 changes: 3 additions & 2 deletions go/test/endtoend/tabletmanager/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/test/endtoend/cluster"
replicationdatapb "vitess.io/vitess/go/vt/proto/replicationdata"
"vitess.io/vitess/go/vt/proto/tabletmanagerdata"
tabletpb "vitess.io/vitess/go/vt/proto/topodata"
"vitess.io/vitess/go/vt/utils"
tmc "vitess.io/vitess/go/vt/vttablet/grpctmclient"
Expand Down Expand Up @@ -197,9 +198,9 @@ func tmcStartReplicationUntilAfter(ctx context.Context, tabletGrpcPort int, posi
return tmClient.StartReplicationUntilAfter(ctx, vtablet, positon, waittime)
}

func tmcFullStatus(ctx context.Context, tabletGrpcPort int) (*replicationdatapb.FullStatus, error) {
func tmcFullStatus(ctx context.Context, tabletGrpcPort int, req *tabletmanagerdata.FullStatusRequest) (*replicationdatapb.FullStatus, error) {
vtablet := getTablet(tabletGrpcPort)
return tmClient.FullStatus(ctx, vtablet)
return tmClient.FullStatus(ctx, vtablet, req)
}

func tmcStopReplicationAndGetStatus(ctx context.Context, tabletGrpcPort int, mode replicationdatapb.StopReplicationMode) (*replicationdatapb.StopReplicationStatus, error) {
Expand Down
4 changes: 2 additions & 2 deletions go/test/endtoend/tabletmanager/tablet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestGRPCErrorCode_UNAVAILABLE(t *testing.T) {
// because this will try and fail to connect to mysql
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
_, err = tmcFullStatus(ctx, tablet.GrpcPort)
_, err = tmcFullStatus(ctx, tablet.GrpcPort, nil)
assert.Equal(t, vtrpcpb.Code_UNAVAILABLE, vterrors.Code(err))
}

Expand Down Expand Up @@ -182,7 +182,7 @@ func TestStopReplicationAndGetStatus(t *testing.T) {
require.EventuallyWithT(t, func(c *assert.CollectT) {
ctx, cancel := context.WithTimeout(t.Context(), time.Second*10)
defer cancel()
resp, err := tmcFullStatus(ctx, tablet.GrpcPort)
resp, err := tmcFullStatus(ctx, tablet.GrpcPort, nil)
require.NoError(c, err)
require.True(c, resp.SemiSyncReplicaEnabled)
require.True(c, resp.SemiSyncReplicaStatus)
Expand Down
2 changes: 1 addition & 1 deletion go/test/endtoend/vtorc/general/vtorc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ func TestVTOrcRepairs(t *testing.T) {

// Wait for VTOrc to detect the mismatch and promote the tablet.
require.Eventuallyf(t, func() bool {
fs := cluster.FullStatus(t, replica, clusterInfo.ClusterInstance.Hostname)
fs := cluster.FullStatus(t, replica, clusterInfo.ClusterInstance.Hostname, nil)
return fs.TabletType == topodatapb.TabletType_PRIMARY
}, 10*time.Second, 1*time.Second, "Primary tablet's display type didn't match the topo record")
// Also check that the replica gets promoted and can accept writes.
Expand Down
2 changes: 1 addition & 1 deletion go/test/fuzzing/vttablet_fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ func FuzzGRPCTMServer(data []byte) int {
}
s := grpc.NewServer()
fakeTM := tmrpctest.NewFakeRPCTM(t)
grpctmserver.RegisterForTest(s, fakeTM)
grpctmserver.RegisterForTest(s, fakeTM, nil)
go s.Serve(listener)
defer s.Stop()

Expand Down
Loading
Loading