Skip to content

Commit

Permalink
Attempted fixes for flaky tests: TestPlayerDDL and TestTabletVStreame…
Browse files Browse the repository at this point in the history
…rClientVStreamRows

Signed-off-by: Rohit Nayak <[email protected]>
  • Loading branch information
rohit-nayak-ps committed Apr 13, 2020
1 parent 056d8c2 commit c6307b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 8 additions & 2 deletions go/vt/vttablet/tabletmanager/vreplication/vplayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"testing"
"time"

"vitess.io/vitess/go/vt/log"

"golang.org/x/net/context"

"vitess.io/vitess/go/sqltypes"
Expand Down Expand Up @@ -1113,17 +1115,21 @@ func TestPlayerDDL(t *testing.T) {
OnDdl: binlogdatapb.OnDDLAction_STOP,
}
cancel, id := startVReplication(t, bls, "")
pos0 := masterPosition(t) //For debugging only
execStatements(t, []string{"alter table t1 add column val varchar(128)"})
pos1 := masterPosition(t)
execStatements(t, []string{"alter table t1 drop column val"})
pos2 := masterPosition(t)
// The stop position must be the GTID of the first DDL
expectDBClientQueries(t, []string{
"begin",
fmt.Sprintf("/update _vt.vreplication set pos='%s'", pos1),
"/update _vt.vreplication set state='Stopped'",
"commit",
})
pos2b := masterPosition(t)
execStatements(t, []string{"alter table t1 drop column val"})
pos2 := masterPosition(t)
log.Errorf("Expected log:: TestPlayerDDL Positions are: before first alter %v, after first alter %v, before second alter %v, after second alter %v",
pos0, pos1, pos2b, pos2) //For debugging only: to check what are the positions when test works and if/when it fails
// Restart vreplication
if _, err := playerEngine.Exec(fmt.Sprintf(`update _vt.vreplication set state = 'Running', message='' where id=%d`, id)); err != nil {
t.Fatal(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,14 @@ func TestTabletVStreamerClientVStreamRows(t *testing.T) {

defer vsClient.Close(ctx)

// This asserts that events are flowing through the VStream when using mysql client
go vsClient.VStreamRows(ctx, "select * from t1", nil, send)

execStatements(t, []string{
fmt.Sprintf("insert into t1 values(1, '%s', '%s')", want, want),
})

// This asserts that events are flowing through VStreamRows when using mysql client
// This needs to happen after the insert above to avoid race where select precedes the insert
go vsClient.VStreamRows(ctx, "select * from t1", nil, send)

select {
case <-eventsChan:
// Success got expected
Expand Down

0 comments on commit c6307b3

Please sign in to comment.