mysql_test

package
v0.9.71 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2020 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TestTableName                                 = "test_table"
	TestTableWithoutTs                            = "test_table_without_ts"
	DummyTableName                                = "dummy_table"
	TxnRouteTableName                             = "drc_routes"
	TestScanColumnTableIdPrimary                  = "test_scan_column_id_primary"
	TestScanColumnTableCompositePrimary           = "test_scan_column_multiple_primary"
	TestScanColumnTableCompositePrimaryInt        = "test_scan_column_composite_pk_int"
	TestScanColumnTableCompositePrimaryOutOfOrder = "test_scan_column_multiple_pk_unordered"
	TestScanColumnTableUniqueIndexEmailString     = "test_scan_column_unique_index_email_string"
	TestScanColumnTableUniqueIndexTime            = "test_scan_column_unique_index_time"
	TestScanColumnTableCompositeUniqueKey         = "test_scan_column_multi_uk"
	TestScanColumnTableNoKey                      = "test_scan_column_no_key"
)
View Source
const TestDBPrefix = "__test_drc__"

Variables

View Source
var MaxConn = 2048

Functions

func CountTestTable

func CountTestTable(db *sql.DB, testDBName string, testTableName string) (int, error)

func DeleteTestTable

func DeleteTestTable(db *sql.DB, testDBName string, testTableName string, id int) error

func InsertIntoTestTable

func InsertIntoTestTable(db *sql.DB, testDBName string, testTableName string, args map[string]interface{}) error

func InsertIntoTestTableWithTxnRoute

func InsertIntoTestTableWithTxnRoute(db *sql.DB, testDBName string, testTableName string, args map[string]interface{}, region string) error

func IsDeadSignal

func IsDeadSignal(schema string, table string) bool

func IsTestDB

func IsTestDB(schemaName string) bool

func MustCreateSourceDBConn

func MustCreateSourceDBConn() *sql.DB

func MustCreateTargetDBConn

func MustCreateTargetDBConn() *sql.DB

func MustSetupSourceDB

func MustSetupSourceDB(dbName string) *sql.DB

MustSetupSourceDB setup a test db, so that we can use different db in different test cases

func MustSetupTargetDB

func MustSetupTargetDB(dbName string) *sql.DB

func QueryTestTable

func QueryTestTable(db *sql.DB, testDBName string, testTableName string, id int) (string, error)

func SeedCompositePrimaryKeyInt added in v0.9.27

func SeedCompositePrimaryKeyInt(db *sql.DB, dbName string)

func SendDeadSignal

func SendDeadSignal(db *sql.DB, pipeline string) error

func SetMySQLGlobalVars

func SetMySQLGlobalVars(db *sql.DB)

func SourceDBConfig

func SourceDBConfig() *config.DBConfig

func TableChecksum added in v0.9.27

func TableChecksum(db *sql.DB, dbName string, tableName string) string

func TargetDBConfig

func TargetDBConfig() *config.DBConfig

func TestChecksum

func TestChecksum(t *testing.T, tableNames []string, sourceDB *sql.DB, sourceDBName string, targetDB *sql.DB, targetDBName string)

func TestDBName

func TestDBName(name string) string

func UpdateTestTable

func UpdateTestTable(db *sql.DB, testDBName string, testTableName string, id int, newName string) error

func UpdateTestTableWithMultiRows

func UpdateTestTableWithMultiRows(db *sql.DB, testDBName string, testTableName string, whereClause string) error

Types

type Column

type Column struct {
	// contains filtered or unexported fields
}

type Generator

type Generator struct {
	GeneratorConfig

	SourceDB     *sql.DB
	SourceSchema string

	TargetDB     *sql.DB
	TargetSchema string
	// contains filtered or unexported fields
}

func (*Generator) ParallelUpdate

func (g *Generator) ParallelUpdate(ctx context.Context) *sync.WaitGroup

func (*Generator) SeedRows

func (g *Generator) SeedRows()

func (*Generator) SetupTestTables

func (g *Generator) SetupTestTables(createTarget bool) []string

func (*Generator) TestChecksum

func (g *Generator) TestChecksum() error

type GeneratorConfig

type GeneratorConfig struct {
	NrTables          int     `json:"nrTables" yaml:"nrTables"`
	NrSeedRows        int     `json:"nrSeedRows" yaml:"nrSeedRows"`
	DeleteRatio       float32 `json:"deleteRatio" yaml:"deleteRatio"`
	InsertRatio       float32 `json:"insertRatio" yaml:"insertRatio"`
	Concurrency       int     `json:"concurrency" yaml:"concurrency"`
	TransactionLength int     `json:"transactionLength" yaml:"transactionLength"`
}

type MysqlTableDataGenerator

type MysqlTableDataGenerator struct {
	*sync.Mutex
	// contains filtered or unexported fields
}

func NewMysqlTableDataGenerator

func NewMysqlTableDataGenerator(db *sql.DB, schema string, table string) MysqlTableDataGenerator

func (*MysqlTableDataGenerator) InitData

func (g *MysqlTableDataGenerator) InitData(num int, r *rand.Rand) (stmt string, args []interface{})

func (*MysqlTableDataGenerator) RandomStmt

func (g *MysqlTableDataGenerator) RandomStmt(deleteRatio float32, insertRatio float32, r *rand.Rand) (string, []interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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