-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Towards a VReplication/OnlineDDL testing suite #8181
Towards a VReplication/OnlineDDL testing suite #8181
Conversation
…th tables on cut-over to names inaccessible to the app, paving the way for a reliable test suite Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…ast 5 seconds Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…e.g. via an internal EVENT), we need to cut-over using two-step, to hard-hide the original table Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Ready for reviewSuite is now working: https://github.com/vitessio/vitess/pull/8181/checks?check_run_id=2672882181 Main file is https://github.com/vitessio/vitess/pull/8181/files#diff-5b2f7e26e6a031b4098461528dca98e5ff630e70e1986f35efaab59f3fa5bd76, the endtoend test that runs the suite. All tests files are under The rest of the tests are temporarily in The objective is:
|
@@ -106,6 +106,12 @@ func CheckCancelAllMigrations(t *testing.T, vtParams *mysql.ConnParams, expectCo | |||
assert.Equal(t, expectCount, int(r.RowsAffected)) | |||
} | |||
|
|||
// ReadMigrations reads migration entries | |||
func ReadMigrations(t *testing.T, vtParams *mysql.ConnParams, like string) *sqltypes.Result { | |||
showQuery := fmt.Sprintf("show vitess_migrations like '%s'", like) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I talk you into using sqlparser.TrackedBuffer
for this? I don't think anybody is gonna do SQL injection in our integration test suite buuuut it's a good consistency habit to pick up :p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm looking at Vitess code and I don't see sqlparser.TrackedBuffer
widely used for encapsulating values; I see construction using sqlparser.NewStrLiteral
, like in:
vitess/go/vt/vtgate/planbuilder/show.go
Lines 217 to 226 in bb15f60
sql := "SELECT * FROM _vt.schema_migrations" | |
if show.Filter != nil { | |
if show.Filter.Filter != nil { | |
sql += fmt.Sprintf(" where %s", sqlparser.String(show.Filter.Filter)) | |
} else if show.Filter.Like != "" { | |
lit := sqlparser.String(sqlparser.NewStrLiteral(show.Filter.Like)) | |
sql += fmt.Sprintf(" where migration_uuid LIKE %s OR migration_context LIKE %s OR migration_status LIKE %s", lit, lit, lit) | |
} | |
} |
Any thoughts on how to use TrackedBuffer
to avoid SQL injection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewritten to use sqlparser.ParseAndBind()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the one! Sorry I didn't make it explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good good, thank you!
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Request for review 🙏 I have more to come on this topic but don't want to overwhelm with a giant PR |
@@ -0,0 +1,376 @@ | |||
/* | |||
Copyright 2019 The Vitess Authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2021?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some nits, otherwise lgtm
|
||
exitcode, err := func() (int, error) { | ||
clusterInstance = cluster.NewCluster(cell, hostname) | ||
schemaChangeDirectory = path.Join("/tmp", fmt.Sprintf("schema_change_dir_%d", clusterInstance.GetAndReserveTabletUID())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ClusterInstance
has a TmpDirectory
parameter (based off of VTDATAROOT). Maybe using that here might be more consistent with the other tests. I have found that helps while debugging: if you comment out the teardown temporarily all transient files are then in the same root dir.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I inherited this schemaChangeDirectory
variable, and am unsure how Vitess even uses it. Having said that, there's a problem with using suggested TmpDirectory
:
TmpDirectory
is only set inStartTopo()
StartTopo()
requires thatVtctldExtraArgs
are setVtctldExtraArgs
rely onschemaChangeDirectory
so if we introduce schemaChangeDirectory = cluster.TmpDirectory
there's a dependency loop.
I have no strong opinions (and really no opinions at all) on how this should be resolved. Even after reviewing the code I don't understand how SchemaChangeDirName
is being used: it's used by LocalController
-- I don't really understand what LocalController is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm gonna merge this PR with the nit still outstanding, and resolve TmpDirectory
in a future PR 🙏
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Setting up a VReplication testing suite.
Initial commit: support for ddl_strategy '-vreplication-test-suite', which renames both tables on cut-over to names inaccessible to the app
e.g. if table name is
mytable
, then we end up withmytable_before
andmytable_after
. The app (and the scripts executed by the test suite) knows nothing about those tables and therefore cannot make changes to those tabes. This means both tables are frozen in time at the moment of cut-over, and this means they can be compared without interference. And that's how the suite validates that the migration is correct: by comparing table data.Related Issue(s)
Checklist
Deployment Notes