Skip to content

Commit

Permalink
Merge pull request vitessio#8642 from eeSeeGee/young.20210818.longer_…
Browse files Browse the repository at this point in the history
…reparent_wait

Fixes for reparent endtoend test flakiness
  • Loading branch information
deepthi authored Aug 20, 2021
2 parents 441d4bd + 2a53305 commit 56a2288
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 7 additions & 3 deletions go/test/endtoend/reparent/reparent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestReparentNoChoiceDownPrimary(t *testing.T) {
require.NotEqual(t, newPrimary.Alias, tab1.Alias)

// Check new primary has latest transaction.
err = checkInsertedValues(ctx, t, newPrimary, 2)
err = checkInsertedValues(ctx, t, newPrimary, insertVal)
require.NoError(t, err)

// bring back the old primary as a replica, check that it catches up
Expand Down Expand Up @@ -152,7 +152,7 @@ func TestReparentIgnoreReplicas(t *testing.T) {

newPrimary := getNewPrimary(t)
// Check new primary has latest transaction.
err = checkInsertedValues(ctx, t, newPrimary, 2)
err = checkInsertedValues(ctx, t, newPrimary, insertVal)
require.Nil(t, err)

// bring back the old primary as a replica, check that it catches up
Expand Down Expand Up @@ -343,10 +343,14 @@ func TestReparentWithDownReplica(t *testing.T) {

ctx := context.Background()

confirmReplication(t, tab1, []*cluster.Vttablet{tab2, tab3, tab4})

// Stop replica mysql Process
err := tab3.MysqlctlProcess.Stop()
require.NoError(t, err)

confirmReplication(t, tab1, []*cluster.Vttablet{tab2, tab4})

// Perform a graceful reparent operation. It will fail as one tablet is down.
out, err := prs(t, tab2)
require.Error(t, err)
Expand All @@ -365,7 +369,7 @@ func TestReparentWithDownReplica(t *testing.T) {
require.NoError(t, err)

// wait until it gets the data
err = checkInsertedValues(ctx, t, tab3, 2)
err = checkInsertedValues(ctx, t, tab3, insertVal)
require.NoError(t, err)
}

Expand Down
8 changes: 5 additions & 3 deletions go/test/endtoend/reparent/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ var (
dbName = "vt_" + keyspaceName
username = "vt_dba"
hostname = "localhost"
insertVal = 1
insertSQL = "insert into vt_insert_test(id, msg) values (%d, 'test %d')"
sqlSchema = `
create table vt_insert_test (
Expand Down Expand Up @@ -310,7 +311,8 @@ func validateTopology(t *testing.T, pingTablets bool) {

func confirmReplication(t *testing.T, primary *cluster.Vttablet, replicas []*cluster.Vttablet) {
ctx := context.Background()
n := 2 // random value ...
insertVal++
n := insertVal // unique value ...
// insert data into the new primary, check the connected replica work
insertSQL := fmt.Sprintf(insertSQL, n, n)
runSQL(ctx, t, insertSQL, primary)
Expand Down Expand Up @@ -441,7 +443,7 @@ func isHealthyPrimaryTablet(t *testing.T, tablet *cluster.Vttablet) bool {

func checkInsertedValues(ctx context.Context, t *testing.T, tablet *cluster.Vttablet, index int) error {
// wait until it gets the data
timeout := time.Now().Add(5 * time.Second)
timeout := time.Now().Add(15 * time.Second)
i := 0
for time.Now().Before(timeout) {
selectSQL := fmt.Sprintf("select msg from vt_insert_test where id=%d", index)
Expand Down Expand Up @@ -490,7 +492,7 @@ func resurrectTablet(ctx context.Context, t *testing.T, tab *cluster.Vttablet) {
err = tab.VttabletProcess.Setup()
require.NoError(t, err)

err = checkInsertedValues(ctx, t, tab, 2)
err = checkInsertedValues(ctx, t, tab, insertVal)
require.NoError(t, err)
}

Expand Down

0 comments on commit 56a2288

Please sign in to comment.