From 6689aeb3cefb4c5fb1d54459e50949486b103e70 Mon Sep 17 00:00:00 2001 From: meiji163 Date: Tue, 19 Nov 2024 11:13:30 -0800 Subject: [PATCH] fix migrator test --- go/logic/coordinator_test.go | 8 +++++++- go/logic/migrator_test.go | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/go/logic/coordinator_test.go b/go/logic/coordinator_test.go index e6c36353e..d832a7b1e 100644 --- a/go/logic/coordinator_test.go +++ b/go/logic/coordinator_test.go @@ -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" @@ -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 @@ -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) diff --git a/go/logic/migrator_test.go b/go/logic/migrator_test.go index 3431ae587..fe6a335a6 100644 --- a/go/logic/migrator_test.go +++ b/go/logic/migrator_test.go @@ -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) } @@ -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) @@ -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")