diff --git a/go/vt/vtctl/reparentutil/emergency_reparenter_test.go b/go/vt/vtctl/reparentutil/emergency_reparenter_test.go index 887dbd22671..9f97fdb6c29 100644 --- a/go/vt/vtctl/reparentutil/emergency_reparenter_test.go +++ b/go/vt/vtctl/reparentutil/emergency_reparenter_test.go @@ -1816,70 +1816,10 @@ func TestEmergencyReparenter_reparentShardLocked(t *testing.T) { emergencyReparentOps: EmergencyReparentOptions{ ExpectedPrimaryAlias: &topodatapb.TabletAlias{ Cell: "zone1", - Uid: 102, - }, - }, - tmc: &testutil.TabletManagerClient{ - PopulateReparentJournalResults: map[string]error{ - "zone1-0000000102": nil, - }, - PromoteReplicaResults: map[string]struct { - Result string - Error error - }{ - "zone1-0000000102": { - Result: "ok", - Error: nil, - }, - }, - SetReplicationSourceResults: map[string]error{ - "zone1-0000000100": nil, - "zone1-0000000101": nil, - }, - StopReplicationAndGetStatusResults: map[string]struct { - StopStatus *replicationdatapb.StopReplicationStatus - Error error - }{ - "zone1-0000000100": { - StopStatus: &replicationdatapb.StopReplicationStatus{ - Before: &replicationdatapb.Status{IoState: int32(replication.ReplicationStateRunning), SqlState: int32(replication.ReplicationStateRunning)}, - After: &replicationdatapb.Status{ - SourceUuid: "3E11FA47-71CA-11E1-9E33-C80AA9429562", - RelayLogPosition: "MySQL56/3E11FA47-71CA-11E1-9E33-C80AA9429562:1-21", - }, - }, - }, - "zone1-0000000101": { - StopStatus: &replicationdatapb.StopReplicationStatus{ - Before: &replicationdatapb.Status{IoState: int32(replication.ReplicationStateRunning), SqlState: int32(replication.ReplicationStateRunning)}, - After: &replicationdatapb.Status{ - SourceUuid: "3E11FA47-71CA-11E1-9E33-C80AA9429562", - RelayLogPosition: "MySQL56/3E11FA47-71CA-11E1-9E33-C80AA9429562:1-21", - }, - }, - }, - "zone1-0000000102": { - StopStatus: &replicationdatapb.StopReplicationStatus{ - Before: &replicationdatapb.Status{IoState: int32(replication.ReplicationStateRunning), SqlState: int32(replication.ReplicationStateRunning)}, - After: &replicationdatapb.Status{ - SourceUuid: "3E11FA47-71CA-11E1-9E33-C80AA9429562", - RelayLogPosition: "MySQL56/3E11FA47-71CA-11E1-9E33-C80AA9429562:1-26", - }, - }, - }, - }, - WaitForPositionResults: map[string]map[string]error{ - "zone1-0000000100": { - "MySQL56/3E11FA47-71CA-11E1-9E33-C80AA9429562:1-21": nil, - }, - "zone1-0000000101": { - "MySQL56/3E11FA47-71CA-11E1-9E33-C80AA9429562:1-21": nil, - }, - "zone1-0000000102": { - "MySQL56/3E11FA47-71CA-11E1-9E33-C80AA9429562:1-26": nil, - }, + Uid: 101, }, }, + tmc: &testutil.TabletManagerClient{}, shards: []*vtctldatapb.Shard{ { Keyspace: "testkeyspace", @@ -1912,22 +1852,12 @@ func TestEmergencyReparenter_reparentShardLocked(t *testing.T) { Keyspace: "testkeyspace", Shard: "-", }, - { - Alias: &topodatapb.TabletAlias{ - Cell: "zone1", - Uid: 102, - }, - Type: topodatapb.TabletType_REPLICA, - Keyspace: "testkeyspace", - Shard: "-", - Hostname: "proposed primary", - }, }, keyspace: "testkeyspace", shard: "-", cells: []string{"zone1"}, shouldErr: true, - errShouldContain: "primary zone1-0000000100 is not equal to expected alias zone1-0000000102", + errShouldContain: "primary zone1-0000000100 is not equal to expected alias zone1-0000000101", }, } diff --git a/go/vt/vtctl/reparentutil/planned_reparenter_flaky_test.go b/go/vt/vtctl/reparentutil/planned_reparenter_flaky_test.go index d1bbe417528..7edcd65b6d6 100644 --- a/go/vt/vtctl/reparentutil/planned_reparenter_flaky_test.go +++ b/go/vt/vtctl/reparentutil/planned_reparenter_flaky_test.go @@ -2518,8 +2518,9 @@ func TestPlannedReparenter_reparentShardLocked(t *testing.T) { shard string opts PlannedReparentOptions - shouldErr bool - expectedEvent *events.Reparent + shouldErr bool + errShouldContain string + expectedEvent *events.Reparent }{ { name: "success: current primary cannot be determined", // "Case (1)" @@ -3299,23 +3300,7 @@ func TestPlannedReparenter_reparentShardLocked(t *testing.T) { }, { name: "expected primary mismatch", - tmc: &testutil.TabletManagerClient{ - GetGlobalStatusVarsResults: map[string]struct { - Statuses map[string]string - Error error - }{ - "zone1-0000000200": { - Statuses: map[string]string{ - InnodbBufferPoolsDataVar: "123", - }, - }, - "zone1-0000000100": { - Statuses: map[string]string{ - InnodbBufferPoolsDataVar: "123", - }, - }, - }, - }, + tmc: &testutil.TabletManagerClient{}, shards: []*vtctldatapb.Shard{ { Keyspace: "testkeyspace", @@ -3360,9 +3345,9 @@ func TestPlannedReparenter_reparentShardLocked(t *testing.T) { Uid: 200, }, }, - - shouldErr: true, - expectedEvent: nil, + shouldErr: true, + errShouldContain: "primary zone1-0000000100 is not equal to expected alias zone1-0000000200", + expectedEvent: nil, }, } @@ -3410,7 +3395,9 @@ func TestPlannedReparenter_reparentShardLocked(t *testing.T) { err := pr.reparentShardLocked(ctx, tt.ev, tt.keyspace, tt.shard, tt.opts) if tt.shouldErr { assert.Error(t, err) - + if tt.errShouldContain != "" { + assert.Contains(t, err.Error(), tt.errShouldContain) + } return }