Skip to content

Commit

Permalink
Fix Upgrade downgrade reparent tests in release-17.0 (#14507)
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 authored Nov 13, 2023
1 parent 0f6c24b commit 6803635
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions go/test/endtoend/reparent/plannedreparent/reparent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,16 @@ func TestReparentReplicaOffline(t *testing.T) {
// Perform a graceful reparent operation.
out, err := utils.PrsWithTimeout(t, clusterInstance, tablets[1], false, "", "31s")
require.Error(t, err)
assert.True(t, utils.SetReplicationSourceFailed(tablets[3], out))

utils.CheckPrimaryTablet(t, clusterInstance, tablets[1])
// Assert that PRS failed
if clusterInstance.VtctlMajorVersion <= 17 {
assert.True(t, utils.SetReplicationSourceFailed(tablets[3], out))
utils.CheckPrimaryTablet(t, clusterInstance, tablets[1])
} else {
assert.Contains(t, out, "rpc error: code = DeadlineExceeded desc")
utils.CheckPrimaryTablet(t, clusterInstance, tablets[0])
}

}

func TestReparentAvoid(t *testing.T) {
Expand Down Expand Up @@ -155,7 +162,11 @@ func TestReparentAvoid(t *testing.T) {
utils.StopTablet(t, tablets[0], true)
out, err := utils.PrsAvoid(t, clusterInstance, tablets[1])
require.Error(t, err)
assert.Contains(t, out, "cannot find a tablet to reparent to in the same cell as the current primary")
if clusterInstance.VtctlMajorVersion <= 17 {
assert.Contains(t, out, "cannot find a tablet to reparent to in the same cell as the current primary")
} else {
assert.Contains(t, out, "rpc error: code = DeadlineExceeded desc = latest balancer error")
}
utils.ValidateTopology(t, clusterInstance, false)
utils.CheckPrimaryTablet(t, clusterInstance, tablets[1])
}
Expand Down Expand Up @@ -275,17 +286,24 @@ func TestReparentWithDownReplica(t *testing.T) {
// Perform a graceful reparent operation. It will fail as one tablet is down.
out, err := utils.Prs(t, clusterInstance, tablets[1])
require.Error(t, err)
assert.True(t, utils.SetReplicationSourceFailed(tablets[2], out))

// insert data into the new primary, check the connected replica work
insertVal := utils.ConfirmReplication(t, tablets[1], []*cluster.Vttablet{tablets[0], tablets[3]})
var insertVal int
// Assert that PRS failed
if clusterInstance.VtctlMajorVersion <= 17 {
assert.True(t, utils.SetReplicationSourceFailed(tablets[2], out))
// insert data into the new primary, check the connected replica work
insertVal = utils.ConfirmReplication(t, tablets[1], []*cluster.Vttablet{tablets[0], tablets[3]})
} else {
assert.Contains(t, out, fmt.Sprintf("TabletManager.PrimaryStatus on %s error", tablets[2].Alias))
// insert data into the old primary, check the connected replica works. The primary tablet shouldn't have changed.
insertVal = utils.ConfirmReplication(t, tablets[0], []*cluster.Vttablet{tablets[1], tablets[3]})
}

// restart mysql on the old replica, should still be connecting to the old primary
tablets[2].MysqlctlProcess.InitMysql = false
err = tablets[2].MysqlctlProcess.Start()
require.NoError(t, err)

// Use the same PlannedReparentShard command to fix up the tablet.
// Use the same PlannedReparentShard command to promote the new primary.
_, err = utils.Prs(t, clusterInstance, tablets[1])
require.NoError(t, err)

Expand Down

0 comments on commit 6803635

Please sign in to comment.