utils

package
v0.15.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertContainsError

func AssertContainsError(t *testing.T, conn *mysql.Conn, query, expected string)

AssertContainsError ensures that the given query returns a certain error.

func AssertIsEmpty

func AssertIsEmpty(t *testing.T, conn *mysql.Conn, query string)

AssertIsEmpty ensures that the given query returns 0 row.

func AssertMatches

func AssertMatches(t testing.TB, conn *mysql.Conn, query, expected string)

AssertMatches ensures the given query produces the expected results.

func AssertMatchesAny added in v0.15.0

func AssertMatchesAny(t testing.TB, conn *mysql.Conn, query string, expected ...string)

AssertMatchesAny ensures the given query produces any one of the expected results.

func AssertMatchesCompareMySQL

func AssertMatchesCompareMySQL(t *testing.T, vtConn, mysqlConn *mysql.Conn, query, expected string)

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 AssertMatchesNoOrder

func AssertMatchesNoOrder(t *testing.T, conn *mysql.Conn, query, expected string)

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 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 AssertResultIsEmpty

func AssertResultIsEmpty(t *testing.T, conn *mysql.Conn, pre string)

func AssertSingleRowIsReturned

func AssertSingleRowIsReturned(t *testing.T, conn *mysql.Conn, predicate string, expectedKs string)

func Exec

func Exec(t testing.TB, conn *mysql.Conn, query string) *sqltypes.Result

Exec executes the given query using the given connection. The results are returned. The test fails if the query produces an error.

func ExecAllowError

func ExecAllowError(t *testing.T, conn *mysql.Conn, query string) (*sqltypes.Result, error)

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

func ExecCompareMySQL(t *testing.T, vtConn, mysqlConn *mysql.Conn, query string) *sqltypes.Result

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 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 NewMySQLWithDetails added in v0.15.0

func NewMySQLWithDetails(port int, hostname, dbName string, schemaSQL ...string) (mysql.ConnParams, func(), error)

func SkipIfBinaryIsBelowVersion

func SkipIfBinaryIsBelowVersion(t *testing.T, majorVersion int, binary string)

SkipIfBinaryIsBelowVersion skips the given test if the binary's major version is below majorVersion.

func WaitForAuthoritative

func WaitForAuthoritative(t *testing.T, vtgateProcess cluster.VtgateProcess, ks, tbl string) error

WaitForAuthoritative waits for a table to become authoritative

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.

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) 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL