Skip to content

Commit

Permalink
v15 compat fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
  • Loading branch information
timvaillancourt committed Oct 13, 2023
1 parent d47c899 commit 685d5cb
Showing 1 changed file with 1 addition and 187 deletions.
188 changes: 1 addition & 187 deletions go/vt/vtctl/reparentutil/planned_reparenter_flaky_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3802,192 +3802,6 @@ func AssertReparentEventsEqual(t *testing.T, expected *events.Reparent, actual *
AssertReparentEventsEqualWithMessage(t, expected, actual, "")
}

// TestPlannedReparenter_verifyAllTabletsReachable tests the functionality of verifyAllTabletsReachable.
func TestPlannedReparenter_verifyAllTabletsReachable(t *testing.T) {
tests := []struct {
name string
tmc tmclient.TabletManagerClient
tabletMap map[string]*topo.TabletInfo
remoteOpTime time.Duration
wantErr string
}{
{
name: "Success",
tmc: &testutil.TabletManagerClient{
PrimaryStatusResults: map[string]struct {
Status *replicationdatapb.PrimaryStatus
Error error
}{
"zone1-0000000200": {
Status: &replicationdatapb.PrimaryStatus{},
},
"zone1-0000000201": {
Status: &replicationdatapb.PrimaryStatus{},
},
"zone1-0000000100": {
Status: &replicationdatapb.PrimaryStatus{},
},
},
},
tabletMap: map[string]*topo.TabletInfo{
"zone1-0000000100": {
Tablet: &topodatapb.Tablet{
Alias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 100,
},
Type: topodatapb.TabletType_PRIMARY,
},
},
"zone1-0000000200": {
Tablet: &topodatapb.Tablet{
Alias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 200,
},
Type: topodatapb.TabletType_REPLICA,
},
},
"zone1-0000000201": {
Tablet: &topodatapb.Tablet{
Alias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 201,
},
Type: topodatapb.TabletType_REPLICA,
},
},
},
}, {
name: "Failure",
tmc: &testutil.TabletManagerClient{
PrimaryStatusResults: map[string]struct {
Status *replicationdatapb.PrimaryStatus
Error error
}{
"zone1-0000000200": {
Error: fmt.Errorf("primary status failed"),
},
"zone1-0000000201": {
Status: &replicationdatapb.PrimaryStatus{},
},
"zone1-0000000100": {
Status: &replicationdatapb.PrimaryStatus{},
},
},
},
tabletMap: map[string]*topo.TabletInfo{
"zone1-0000000100": {
Tablet: &topodatapb.Tablet{
Alias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 100,
},
Type: topodatapb.TabletType_PRIMARY,
},
},
"zone1-0000000200": {
Tablet: &topodatapb.Tablet{
Alias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 200,
},
Type: topodatapb.TabletType_REPLICA,
},
},
"zone1-0000000201": {
Tablet: &topodatapb.Tablet{
Alias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 201,
},
Type: topodatapb.TabletType_REPLICA,
},
},
},
wantErr: "primary status failed",
}, {
name: "Timeout",
tmc: &testutil.TabletManagerClient{
PrimaryStatusDelays: map[string]time.Duration{
"zone1-0000000100": 20 * time.Second,
},
PrimaryStatusResults: map[string]struct {
Status *replicationdatapb.PrimaryStatus
Error error
}{
"zone1-0000000200": {
Status: &replicationdatapb.PrimaryStatus{},
},
"zone1-0000000201": {
Status: &replicationdatapb.PrimaryStatus{},
},
"zone1-0000000100": {
Status: &replicationdatapb.PrimaryStatus{},
},
},
},
remoteOpTime: 100 * time.Millisecond,
tabletMap: map[string]*topo.TabletInfo{
"zone1-0000000100": {
Tablet: &topodatapb.Tablet{
Alias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 100,
},
Type: topodatapb.TabletType_PRIMARY,
},
},
"zone1-0000000200": {
Tablet: &topodatapb.Tablet{
Alias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 200,
},
Type: topodatapb.TabletType_REPLICA,
},
},
"zone1-0000000201": {
Tablet: &topodatapb.Tablet{
Alias: &topodatapb.TabletAlias{
Cell: "zone1",
Uid: 201,
},
Type: topodatapb.TabletType_REPLICA,
},
},
},
wantErr: "context deadline exceeded",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ts := memorytopo.NewServer(ctx, "zone1")
defer ts.Close()

pr := &PlannedReparenter{
ts: ts,
tmc: tt.tmc,
}
if tt.remoteOpTime != 0 {
oldTime := topo.RemoteOperationTimeout
topo.RemoteOperationTimeout = tt.remoteOpTime
defer func() {
topo.RemoteOperationTimeout = oldTime
}()
}
err := pr.verifyAllTabletsReachable(context.Background(), tt.tabletMap)
if tt.wantErr == "" {
require.NoError(t, err)
return
}
require.ErrorContains(t, err, tt.wantErr)
})
}
}

func TestPlannedReparenterStats(t *testing.T) {
prsCounter.ResetAll()
reparentShardOpTimings.Reset()
Expand Down Expand Up @@ -4058,7 +3872,7 @@ func TestPlannedReparenterStats(t *testing.T) {
}
keyspace := "testkeyspace"
shard := "-"
ts := memorytopo.NewServer(context.Background(), "zone1")
ts := memorytopo.NewServer("zone1")

ctx := context.Background()
logger := logutil.NewMemoryLogger()
Expand Down

0 comments on commit 685d5cb

Please sign in to comment.