Skip to content

Commit 6689aeb

Browse files
committed
fix migrator test
1 parent 9b5e2bc commit 6689aeb

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

go/logic/coordinator_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import (
88
"testing"
99
"time"
1010

11+
"path/filepath"
12+
"runtime"
13+
1114
"github.com/github/gh-ost/go/base"
1215
"github.com/github/gh-ost/go/binlog"
1316
"github.com/github/gh-ost/go/mysql"
@@ -95,7 +98,6 @@ func (suite *CoordinatorTestSuite) TestApplyDML() {
9598
migrationContext.AllowedRunningOnMaster = true
9699
migrationContext.ReplicaServerId = 99999
97100
migrationContext.HeartbeatIntervalMilliseconds = 100
98-
migrationContext.ServeSocketFile = "/tmp/gh-ost.sock"
99101
migrationContext.ThrottleHTTPIntervalMillis = 100
100102
migrationContext.DMLBatchSize = 10
101103

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

121+
//nolint:dogsled
122+
_, filename, _, _ := runtime.Caller(0)
123+
migrationContext.ServeSocketFile = filepath.Join(filepath.Dir(filename), "../../tmp/gh-ost.sock")
124+
119125
applier := NewApplier(migrationContext)
120126
err = applier.InitDBConnections(migrationContext.NumWorkers)
121127
suite.Require().NoError(err)

go/logic/migrator_test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,10 @@ func (suite *MigratorTestSuite) TeardownSuite() {
305305
func (suite *MigratorTestSuite) SetupTest() {
306306
ctx := context.Background()
307307

308-
_, err := suite.db.ExecContext(ctx, "CREATE DATABASE test")
308+
_, err := suite.db.ExecContext(ctx, "SET @@GLOBAL.binlog_transaction_dependency_tracking = WRITESET")
309+
suite.Require().NoError(err)
310+
311+
_, err = suite.db.ExecContext(ctx, "CREATE DATABASE test")
309312
suite.Require().NoError(err)
310313
}
311314

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

328+
_, err = suite.db.ExecContext(ctx, "INSERT INTO test.testing(id, name) VALUES (1, 'mona')")
329+
suite.Require().NoError(err)
330+
325331
connectionConfig, err := GetConnectionConfig(ctx, suite.mysqlContainer)
326332
suite.Require().NoError(err)
327333

@@ -330,18 +336,20 @@ func (suite *MigratorTestSuite) TestFoo() {
330336
migrationContext.ApplierConnectionConfig = connectionConfig
331337
migrationContext.InspectorConnectionConfig = connectionConfig
332338
migrationContext.DatabaseName = "test"
333-
migrationContext.SkipPortValidation = true
334339
migrationContext.OriginalTableName = "testing"
335340
migrationContext.SetConnectionConfig("innodb")
336-
migrationContext.AlterStatementOptions = "ADD COLUMN foobar varchar(255), ENGINE=InnoDB"
341+
migrationContext.AlterStatementOptions = "ADD COLUMN foobar varchar(255)"
337342
migrationContext.ReplicaServerId = 99999
338343
migrationContext.HeartbeatIntervalMilliseconds = 100
339344
migrationContext.ThrottleHTTPIntervalMillis = 100
340-
migrationContext.ThrottleHTTPTimeoutMillis = 1000
345+
migrationContext.DMLBatchSize = 10
346+
migrationContext.NumWorkers = 4
347+
migrationContext.SkipPortValidation = true
341348

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

346354
migrator := NewMigrator(migrationContext, "0.0.0")
347355

0 commit comments

Comments
 (0)