Documentation ¶
Index ¶
- func AssertContains(t testing.TB, conn *mysql.Conn, query, expected string)
- func AssertContainsError(t *testing.T, conn *mysql.Conn, query, expected string)
- func AssertIsEmpty(t *testing.T, conn *mysql.Conn, query string)
- func AssertMatches(t testing.TB, conn *mysql.Conn, query, expected string)
- func AssertMatchesAny(t testing.TB, conn *mysql.Conn, query string, expected ...string)
- func AssertMatchesCompareMySQL(t *testing.T, vtConn, mysqlConn *mysql.Conn, query, expected string)
- func AssertMatchesContains(t testing.TB, conn *mysql.Conn, query string, substrings ...string)
- func AssertMatchesNoOrder(t *testing.T, conn *mysql.Conn, query, expected string)
- func AssertMatchesNotContains(t testing.TB, conn *mysql.Conn, query string, substrings ...string)
- func AssertMatchesWithTimeout(t *testing.T, conn *mysql.Conn, query, expected string, r time.Duration, ...)
- func AssertResultIsEmpty(t *testing.T, conn *mysql.Conn, pre string)
- func AssertSingleRowIsReturned(t *testing.T, conn *mysql.Conn, predicate string, expectedKs string)
- func BinaryIsAtLeastAtVersion(majorVersion int, binary string) bool
- func CreateMysqldAndMycnf(tabletUID uint32, mysqlSocket string, mysqlPort int) (*mysqlctl.Mysqld, *mysqlctl.Mycnf, error)
- func Exec(t testing.TB, conn *mysql.Conn, query string) *sqltypes.Result
- func ExecAllowError(t testing.TB, conn *mysql.Conn, query string) (*sqltypes.Result, error)
- func ExecCompareMySQL(t *testing.T, vtConn, mysqlConn *mysql.Conn, query string) *sqltypes.Result
- func ExecWithRowCount(t testing.TB, conn *mysql.Conn, query string, rowCount int) (*sqltypes.Result, error)
- func GetInitDBSQL(initDBSQL string, updatedPasswords string, oldAlterTableMode string) (string, error)
- func GetMySQLConn(tablet *cluster.Vttablet, db string) (*mysql.Conn, error)
- func NewMySQL(cluster *cluster.LocalProcessCluster, dbName string, schemaSQL ...string) (mysql.ConnParams, func(), error)
- func NewMySQLWithMysqld(port int, hostname, dbName string, schemaSQL ...string) (mysql.ConnParams, *mysqlctl.Mysqld, func(), error)
- func RunSQL(t *testing.T, sql string, tablet *cluster.Vttablet, db string) (*sqltypes.Result, error)
- func RunSQLs(t *testing.T, sqls []string, tablet *cluster.Vttablet, db string) error
- func SkipIfBinaryIsBelowVersion(t *testing.T, majorVersion int, binary string)
- func TimeoutAction(t *testing.T, timeout time.Duration, errMsg string, action func() bool)
- func WaitForAuthoritative(t *testing.T, ks, tbl string, readVSchema func() (*interface{}, error)) error
- func WaitForColumn(t testing.TB, vtgateProcess cluster.VtgateProcess, ks, tbl, col string) error
- func WaitForKsError(t *testing.T, vtgateProcess cluster.VtgateProcess, ks string) string
- func WaitForTableDeletions(t *testing.T, vtgateProcess cluster.VtgateProcess, ks, tbl string)
- func WaitForVschemaCondition(t *testing.T, vtgateProcess cluster.VtgateProcess, ks string, ...)
- type MySQLCompare
- func (mcmp *MySQLCompare) AssertContainsError(query, expected string)
- func (mcmp *MySQLCompare) AssertFoundRowsValue(query, workload string, count int)
- func (mcmp *MySQLCompare) AssertIsEmpty(query string)
- func (mcmp *MySQLCompare) AssertMatches(query, expected string)
- func (mcmp *MySQLCompare) AssertMatchesAny(query string, expected ...string)
- func (mcmp *MySQLCompare) AssertMatchesAnyNoCompare(query string, expected ...string)
- func (mcmp *MySQLCompare) AssertMatchesNoCompare(query, mExp string, vExp string)
- func (mcmp *MySQLCompare) AssertMatchesNoOrder(query, expected string)
- func (mcmp *MySQLCompare) AssertMatchesNoOrderInclColumnNames(query, expected string)
- func (mcmp *MySQLCompare) Close()
- func (mcmp *MySQLCompare) Exec(query string) *sqltypes.Result
- func (mcmp *MySQLCompare) ExecAllowAndCompareError(query string) (*sqltypes.Result, error)
- func (mcmp *MySQLCompare) ExecAllowError(query string) (*sqltypes.Result, error)
- func (mcmp *MySQLCompare) ExecAndIgnore(query string) (*sqltypes.Result, error)
- func (mcmp *MySQLCompare) ExecNoCompare(query string) (*sqltypes.Result, *sqltypes.Result)
- func (mcmp *MySQLCompare) ExecWithColumnCompare(query string) *sqltypes.Result
- func (mcmp *MySQLCompare) Run(query string, f func(mcmp *MySQLCompare))
- func (mcmp *MySQLCompare) SkipIfBinaryIsBelowVersion(majorVersion int, binary string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertContains ¶ added in v0.16.0
AssertContains ensures the given query result contains the expected results.
func AssertContainsError ¶
AssertContainsError ensures that the given query returns a certain error.
func AssertIsEmpty ¶
AssertIsEmpty ensures that the given query returns 0 row.
func AssertMatches ¶
AssertMatches ensures the given query produces the expected results.
func AssertMatchesAny ¶ added in v0.15.0
AssertMatchesAny ensures the given query produces any one of the expected results.
func AssertMatchesCompareMySQL ¶
AssertMatchesCompareMySQL executes the given query on both Vitess and MySQL and make sure they have the same result set. The result set of Vitess is then matched with the given expectation.
func AssertMatchesContains ¶ added in v0.16.0
AssertMatchesContains ensures the given query produces the given substring.
func AssertMatchesNoOrder ¶
AssertMatchesNoOrder executes the given query and makes sure it matches the given `expected` string. The order applied to the results or expectation is ignored. They are both re-sorted.
func AssertMatchesNotContains ¶ added in v0.16.0
AssertMatchesNotContains ensures the given query's output doesn't have the given substring.
func AssertMatchesWithTimeout ¶
func AssertMatchesWithTimeout(t *testing.T, conn *mysql.Conn, query, expected string, r time.Duration, d time.Duration, failureMsg string)
AssertMatchesWithTimeout asserts that the given query produces the expected result. The query will be executed every 'r' duration until it matches the expected result. If after 'd' duration we still did not find the expected result, the test will be marked as failed.
func BinaryIsAtLeastAtVersion ¶ added in v0.19.0
BinaryIsAtLeastAtVersion returns true if this binary is at or above the required version
func CreateMysqldAndMycnf ¶ added in v0.16.0
func CreateMysqldAndMycnf(tabletUID uint32, mysqlSocket string, mysqlPort int) (*mysqlctl.Mysqld, *mysqlctl.Mycnf, error)
CreateMysqldAndMycnf returns a Mysqld and a Mycnf object to use for working with a MySQL installation that hasn't been set up yet.
func Exec ¶
Exec executes the given query using the given connection. The results are returned. The test fails if the query produces an error.
func ExecAllowError ¶
ExecAllowError executes the given query without failing the test if it produces an error. The error is returned to the client, along with the result set.
func ExecCompareMySQL ¶
ExecCompareMySQL executes the given query against both Vitess and MySQL and compares the two result set. If there is a mismatch, the difference will be printed and the test will fail. If the query produces an error in either Vitess or MySQL, the test will be marked as failed. The result set of Vitess is returned to the caller.
func ExecWithRowCount ¶ added in v0.18.0
func ExecWithRowCount(t testing.TB, conn *mysql.Conn, query string, rowCount int) (*sqltypes.Result, error)
ExecWithRowCount is similar to ExecAllowError with max row count provided.
func GetInitDBSQL ¶ added in v0.16.3
func GetMySQLConn ¶ added in v0.18.0
GetMySQLConn gets a MySQL connection for the given tablet
func NewMySQL ¶
func NewMySQL(cluster *cluster.LocalProcessCluster, dbName string, schemaSQL ...string) (mysql.ConnParams, func(), error)
NewMySQL creates a new MySQL server using the local mysqld binary. The name of the database will be set to `dbName`. SQL queries that need to be executed on the new MySQL instance can be passed through the `schemaSQL` argument. The mysql.ConnParams to connect to the new database is returned, along with a function to teardown the database.
func NewMySQLWithMysqld ¶ added in v0.17.0
func RunSQL ¶ added in v0.18.0
func RunSQL(t *testing.T, sql string, tablet *cluster.Vttablet, db string) (*sqltypes.Result, error)
RunSQL is used to run a SQL statement on the given tablet
func SkipIfBinaryIsBelowVersion ¶
SkipIfBinaryIsBelowVersion skips the given test if the binary's major version is below majorVersion.
func TimeoutAction ¶ added in v0.15.4
TimeoutAction performs the action within the given timeout limit. If the timeout is reached, the test is failed with errMsg. If action returns false, the timeout loop continues, if it returns true, the function succeeds.
func WaitForAuthoritative ¶
func WaitForAuthoritative(t *testing.T, ks, tbl string, readVSchema func() (*interface{}, error)) error
WaitForAuthoritative waits for a table to become authoritative
func WaitForColumn ¶ added in v0.16.0
WaitForColumn waits for a table's column to be present
func WaitForKsError ¶ added in v0.19.0
WaitForKsError waits for the ks error field to be populated and returns it.
func WaitForTableDeletions ¶ added in v0.19.0
func WaitForTableDeletions(t *testing.T, vtgateProcess cluster.VtgateProcess, ks, tbl string)
WaitForTableDeletions waits for a table to be deleted
Types ¶
type MySQLCompare ¶
type MySQLCompare struct {
MySQLConn, VtConn *mysql.Conn
// contains filtered or unexported fields
}
func NewMySQLCompare ¶
func NewMySQLCompare(t *testing.T, vtParams, mysqlParams mysql.ConnParams) (MySQLCompare, error)
func (*MySQLCompare) AssertContainsError ¶
func (mcmp *MySQLCompare) AssertContainsError(query, expected string)
AssertContainsError executes the query on both Vitess and MySQL. Both clients need to return an error. The error of Vitess must be matching the given expectation.
func (*MySQLCompare) AssertFoundRowsValue ¶
func (mcmp *MySQLCompare) AssertFoundRowsValue(query, workload string, count int)
AssertFoundRowsValue executes the given query against both Vitess and MySQL. The results of that query must match between Vitess and MySQL, otherwise the test will be marked as failed. Once the query is executed, the test checks the value of `found_rows`, which must match the given `count` argument.
func (*MySQLCompare) AssertIsEmpty ¶
func (mcmp *MySQLCompare) AssertIsEmpty(query string)
AssertIsEmpty executes the given query against both Vitess and MySQL and ensures their results match and are empty.
func (*MySQLCompare) AssertMatches ¶
func (mcmp *MySQLCompare) AssertMatches(query, expected string)
AssertMatches executes the given query on both Vitess and MySQL and make sure they have the same result set. The result set of Vitess is then matched with the given expectation.
func (*MySQLCompare) AssertMatchesAny ¶ added in v0.15.0
func (mcmp *MySQLCompare) AssertMatchesAny(query string, expected ...string)
AssertMatchesAny ensures the given query produces any one of the expected results.
func (*MySQLCompare) AssertMatchesAnyNoCompare ¶ added in v0.14.4
func (mcmp *MySQLCompare) AssertMatchesAnyNoCompare(query string, expected ...string)
AssertMatchesAnyNoCompare ensures the given query produces any one of the expected results. This method does not compare the mysql and vitess results together
func (*MySQLCompare) AssertMatchesNoCompare ¶
func (mcmp *MySQLCompare) AssertMatchesNoCompare(query, mExp string, vExp string)
AssertMatchesNoCompare compares the record of mysql and vitess separately and not with each other.
func (*MySQLCompare) AssertMatchesNoOrder ¶
func (mcmp *MySQLCompare) AssertMatchesNoOrder(query, expected string)
AssertMatchesNoOrder executes the given query against both Vitess and MySQL. The test will be marked as failed if there is a mismatch between the two result sets.
func (*MySQLCompare) AssertMatchesNoOrderInclColumnNames ¶
func (mcmp *MySQLCompare) AssertMatchesNoOrderInclColumnNames(query, expected string)
AssertMatchesNoOrderInclColumnNames executes the given query against both Vitess and MySQL. The test will be marked as failed if there is a mismatch between the two result sets. This method also checks that the column names are the same and in the same order
func (*MySQLCompare) Close ¶
func (mcmp *MySQLCompare) Close()
func (*MySQLCompare) Exec ¶
func (mcmp *MySQLCompare) Exec(query string) *sqltypes.Result
Exec executes the given query against both Vitess and MySQL and compares the two result set. If there is a mismatch, the difference will be printed and the test will fail. If the query produces an error in either Vitess or MySQL, the test will be marked as failed. The result set of Vitess is returned to the caller.
func (*MySQLCompare) ExecAllowAndCompareError ¶
func (mcmp *MySQLCompare) ExecAllowAndCompareError(query string) (*sqltypes.Result, error)
ExecAllowAndCompareError executes the query against both Vitess and MySQL. The test will pass if:
- MySQL and Vitess both agree that there is an error
- MySQL and Vitess did not find an error, but their results are matching
The result set and error produced by Vitess are returned to the caller. If the Vitess and MySQL error are both nil, but the results do not match, the mismatched results are instead returned as an error, as well as the Vitess result set
func (*MySQLCompare) ExecAllowError ¶ added in v0.18.0
func (mcmp *MySQLCompare) ExecAllowError(query string) (*sqltypes.Result, error)
ExecAllowError executes the query against both Vitess and MySQL. If there is no error, it compares the result Return any Vitess execution error without comparing the results.
func (*MySQLCompare) ExecAndIgnore ¶
func (mcmp *MySQLCompare) ExecAndIgnore(query string) (*sqltypes.Result, error)
ExecAndIgnore executes the query against both Vitess and MySQL. Errors and results difference are ignored.
func (*MySQLCompare) ExecNoCompare ¶ added in v0.18.0
ExecNoCompare executes the query on vitess and mysql but does not compare the result with each other.
func (*MySQLCompare) ExecWithColumnCompare ¶
func (mcmp *MySQLCompare) ExecWithColumnCompare(query string) *sqltypes.Result
ExecWithColumnCompare executes the given query against both Vitess and MySQL and compares the two result set. If there is a mismatch, the difference will be printed and the test will fail. If the query produces an error in either Vitess or MySQL, the test will be marked as failed. The result set of Vitess is returned to the caller.
func (*MySQLCompare) Run ¶ added in v0.18.0
func (mcmp *MySQLCompare) Run(query string, f func(mcmp *MySQLCompare))
func (*MySQLCompare) SkipIfBinaryIsBelowVersion ¶ added in v0.18.3
func (mcmp *MySQLCompare) SkipIfBinaryIsBelowVersion(majorVersion int, binary string)
SkipIfBinaryIsBelowVersion should be used instead of using utils.SkipIfBinaryIsBelowVersion(t, This is because we might be inside a Run block that has a different `t` variable