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

VCopier Flaky Test: modify how we validate expected queries #6033

Merged
merged 2 commits into from
Apr 8, 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
4 changes: 3 additions & 1 deletion go/vt/vttablet/tabletmanager/vreplication/framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,11 @@ func expectNontxQueries(t *testing.T, queries []string) {
retry:
select {
case got = <-globalDBQueries:
if got == "begin" || got == "commit" || got == "rollback" || strings.Contains(got, "_vt.vreplication") {

if got == "begin" || got == "commit" || got == "rollback" || strings.Contains(got, "update _vt.vreplication set pos") {
goto retry
}

var match bool
if query[0] == '/' {
result, err := regexp.MatchString(query[1:], got)
Expand Down
19 changes: 6 additions & 13 deletions go/vt/vttablet/tabletmanager/vreplication/vcopier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,10 @@ func TestPlayerCopyBigTable(t *testing.T) {

expectNontxQueries(t, []string{
// Create the list of tables to copy and transition to Copying state.
"/insert into _vt.vreplication",
"/insert into _vt.copy_state",
// The first fast-forward has no starting point. So, it just saves the current position.
"/update _vt.vreplication set state='Copying'",
"insert into dst(id,val) values (1,'aaa')",
`/update _vt.copy_state set lastpk='fields:<name:\\"id\\" type:INT32 > rows:<lengths:1 values:\\"1\\" > ' where vrepl_id=.*`,
// The next catchup executes the new row insert, but will be a no-op.
Expand All @@ -208,8 +210,6 @@ func TestPlayerCopyBigTable(t *testing.T) {
"/delete from _vt.copy_state.*dst",
// Copy is done. Go into running state.
// All tables copied. Final catch up followed by Running state.
})
expectDBClientQueries(t, []string{
"/update _vt.vreplication set state='Running'",
})
expectData(t, "dst", [][]string{
Expand Down Expand Up @@ -304,7 +304,9 @@ func TestPlayerCopyWildcardRule(t *testing.T) {

expectNontxQueries(t, []string{
// Create the list of tables to copy and transition to Copying state.
"/insert into _vt.vreplication",
"/insert into _vt.copy_state",
"/update _vt.vreplication set state='Copying'",
// The first fast-forward has no starting point. So, it just saves the current position.
"insert into src(id,val) values (1,'aaa')",
`/update _vt.copy_state set lastpk='fields:<name:\\"id\\" type:INT32 > rows:<lengths:1 values:\\"1\\" > ' where vrepl_id=.*`,
Expand All @@ -319,9 +321,6 @@ func TestPlayerCopyWildcardRule(t *testing.T) {
`/update _vt.copy_state set lastpk='fields:<name:\\"id\\" type:INT32 > rows:<lengths:1 values:\\"3\\" > ' where vrepl_id=.*`,
"/delete from _vt.copy_state.*src",
// Copy is done. Go into running state.
// All tables copied. Final catch up followed by Running state.
})
expectDBClientQueries(t, []string{
"/update _vt.vreplication set state='Running'",
})
expectData(t, "src", [][]string{
Expand Down Expand Up @@ -468,10 +467,6 @@ func TestPlayerCopyTableContinuation(t *testing.T) {
"insert into not_copied(id,val) values (1,'bbb')",
`/update _vt.copy_state set lastpk='fields:<name:\\\"id\\\" type:INT32 > rows:<lengths:1 values:\\\"1\\\" > ' where vrepl_id=.*`,
"/delete from _vt.copy_state.*not_copied",
})
// Explicitly eat the Running state query. You can't make expectNontxQueries
// wait for it because it ignores _vt.vreplication events.
expectDBClientQueries(t, []string{
"/update _vt.vreplication set state='Running'",
})
expectData(t, "dst1", [][]string{
Expand Down Expand Up @@ -558,15 +553,13 @@ func TestPlayerCopyWildcardTableContinuation(t *testing.T) {

expectNontxQueries(t, []string{
// Catchup
"/insert into _vt.vreplication",
"/update _vt.vreplication set state = 'Copying'",
"insert into dst(id,val) select 4, 'new' from dual where (4) <= (2)",
// Copy
"insert into dst(id,val) values (3,'uncopied'), (4,'new')",
`/update _vt.copy_state set lastpk.*`,
"/delete from _vt.copy_state.*dst",
})
// Explicitly eat the Running state query. You can't make expectNontxQueries
// wait for it because it ignores _vt.vreplication events.
expectDBClientQueries(t, []string{
"/update _vt.vreplication set state='Running'",
})
expectData(t, "dst", [][]string{
Expand Down