Skip to content

Commit

Permalink
fix migrator test
Browse files Browse the repository at this point in the history
  • Loading branch information
meiji163 committed Nov 19, 2024
1 parent 9b5e2bc commit 6689aeb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
8 changes: 7 additions & 1 deletion go/logic/coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
"testing"
"time"

"path/filepath"
"runtime"

"github.com/github/gh-ost/go/base"
"github.com/github/gh-ost/go/binlog"
"github.com/github/gh-ost/go/mysql"
Expand Down Expand Up @@ -95,7 +98,6 @@ func (suite *CoordinatorTestSuite) TestApplyDML() {
migrationContext.AllowedRunningOnMaster = true
migrationContext.ReplicaServerId = 99999
migrationContext.HeartbeatIntervalMilliseconds = 100
migrationContext.ServeSocketFile = "/tmp/gh-ost.sock"
migrationContext.ThrottleHTTPIntervalMillis = 100
migrationContext.DMLBatchSize = 10

Expand All @@ -116,6 +118,10 @@ func (suite *CoordinatorTestSuite) TestApplyDML() {
migrationContext.SkipPortValidation = true
migrationContext.NumWorkers = 4

//nolint:dogsled
_, filename, _, _ := runtime.Caller(0)
migrationContext.ServeSocketFile = filepath.Join(filepath.Dir(filename), "../../tmp/gh-ost.sock")

applier := NewApplier(migrationContext)
err = applier.InitDBConnections(migrationContext.NumWorkers)
suite.Require().NoError(err)
Expand Down
16 changes: 12 additions & 4 deletions go/logic/migrator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,10 @@ func (suite *MigratorTestSuite) TeardownSuite() {
func (suite *MigratorTestSuite) SetupTest() {
ctx := context.Background()

_, err := suite.db.ExecContext(ctx, "CREATE DATABASE test")
_, err := suite.db.ExecContext(ctx, "SET @@GLOBAL.binlog_transaction_dependency_tracking = WRITESET")
suite.Require().NoError(err)

_, err = suite.db.ExecContext(ctx, "CREATE DATABASE test")
suite.Require().NoError(err)
}

Expand All @@ -322,6 +325,9 @@ func (suite *MigratorTestSuite) TestFoo() {
_, err := suite.db.ExecContext(ctx, "CREATE TABLE test.testing (id INT PRIMARY KEY, name VARCHAR(64))")
suite.Require().NoError(err)

_, err = suite.db.ExecContext(ctx, "INSERT INTO test.testing(id, name) VALUES (1, 'mona')")
suite.Require().NoError(err)

connectionConfig, err := GetConnectionConfig(ctx, suite.mysqlContainer)
suite.Require().NoError(err)

Expand All @@ -330,18 +336,20 @@ func (suite *MigratorTestSuite) TestFoo() {
migrationContext.ApplierConnectionConfig = connectionConfig
migrationContext.InspectorConnectionConfig = connectionConfig
migrationContext.DatabaseName = "test"
migrationContext.SkipPortValidation = true
migrationContext.OriginalTableName = "testing"
migrationContext.SetConnectionConfig("innodb")
migrationContext.AlterStatementOptions = "ADD COLUMN foobar varchar(255), ENGINE=InnoDB"
migrationContext.AlterStatementOptions = "ADD COLUMN foobar varchar(255)"
migrationContext.ReplicaServerId = 99999
migrationContext.HeartbeatIntervalMilliseconds = 100
migrationContext.ThrottleHTTPIntervalMillis = 100
migrationContext.ThrottleHTTPTimeoutMillis = 1000
migrationContext.DMLBatchSize = 10
migrationContext.NumWorkers = 4
migrationContext.SkipPortValidation = true

//nolint:dogsled
_, filename, _, _ := runtime.Caller(0)
migrationContext.ServeSocketFile = filepath.Join(filepath.Dir(filename), "../../tmp/gh-ost.sock")
_ = os.Remove(filename)

migrator := NewMigrator(migrationContext, "0.0.0")

Expand Down

0 comments on commit 6689aeb

Please sign in to comment.