Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for flaky tests: races in TestPlayerDDL and TestTabletVStreamerrClientVStreamRows #6061

Merged
merged 1 commit into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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