Skip to content

Commit

Permalink
test: Add e2e tests for replication (#15671)
Browse files Browse the repository at this point in the history
Signed-off-by: Noble Mittal <[email protected]>
Signed-off-by: Manan Gupta <[email protected]>
Co-authored-by: Manan Gupta <[email protected]>
  • Loading branch information
beingnoble03 and GuptaManan100 authored Apr 8, 2024
1 parent 05e069c commit 84dfb30
Show file tree
Hide file tree
Showing 2 changed files with 355 additions and 9 deletions.
16 changes: 8 additions & 8 deletions go/test/endtoend/utils/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewMySQL(cluster *cluster.LocalProcessCluster, dbName string, schemaSQL ...
}
sqls = append(sqls, split...)
}
mysqlParam, _, closer, error := NewMySQLWithMysqld(cluster.GetAndReservePort(), cluster.Hostname, dbName, sqls...)
mysqlParam, _, _, closer, error := NewMySQLWithMysqld(cluster.GetAndReservePort(), cluster.Hostname, dbName, sqls...)
return mysqlParam, closer, error
}

Expand All @@ -75,24 +75,24 @@ func CreateMysqldAndMycnf(tabletUID uint32, mysqlSocket string, mysqlPort int) (
return mysqlctl.NewMysqld(&cfg), mycnf, nil
}

func NewMySQLWithMysqld(port int, hostname, dbName string, schemaSQL ...string) (mysql.ConnParams, *mysqlctl.Mysqld, func(), error) {
func NewMySQLWithMysqld(port int, hostname, dbName string, schemaSQL ...string) (mysql.ConnParams, *mysqlctl.Mysqld, *mysqlctl.Mycnf, func(), error) {
mysqlDir, err := createMySQLDir()
if err != nil {
return mysql.ConnParams{}, nil, nil, err
return mysql.ConnParams{}, nil, nil, nil, err
}
initMySQLFile, err := createInitSQLFile(mysqlDir, dbName)
if err != nil {
return mysql.ConnParams{}, nil, nil, err
return mysql.ConnParams{}, nil, nil, nil, err
}

mysqlPort := port
mysqld, mycnf, err := CreateMysqldAndMycnf(0, "", mysqlPort)
if err != nil {
return mysql.ConnParams{}, nil, nil, err
return mysql.ConnParams{}, nil, nil, nil, err
}
err = initMysqld(mysqld, mycnf, initMySQLFile)
if err != nil {
return mysql.ConnParams{}, nil, nil, err
return mysql.ConnParams{}, nil, nil, nil, err
}

params := mysql.ConnParams{
Expand All @@ -104,10 +104,10 @@ func NewMySQLWithMysqld(port int, hostname, dbName string, schemaSQL ...string)
for _, sql := range schemaSQL {
err = prepareMySQLWithSchema(params, sql)
if err != nil {
return mysql.ConnParams{}, nil, nil, err
return mysql.ConnParams{}, nil, nil, nil, err
}
}
return params, mysqld, func() {
return params, mysqld, mycnf, func() {
ctx := context.Background()
_ = mysqld.Teardown(ctx, mycnf, true, mysqlShutdownTimeout)
}, nil
Expand Down
Loading

0 comments on commit 84dfb30

Please sign in to comment.