From f2218cbfa4375a465d8184ac2e92dd94ae4f1d26 Mon Sep 17 00:00:00 2001 From: glorv Date: Tue, 11 May 2021 19:27:35 +0800 Subject: [PATCH] fix test --- dm/config/task_test.go | 4 ++-- dumpling/dumpling.go | 2 +- pkg/utils/common_test.go | 1 - syncer/db_test.go | 5 +---- tests/all_mode/data/db1.increment.sql | 2 +- tests/dmctl_basic/conf/get_task.yaml | 1 + tests/full_mode/run.sh | 2 +- tests/import_v10x/conf/task.yaml | 1 + tests/safe_mode/run.sh | 2 +- 9 files changed, 9 insertions(+), 11 deletions(-) diff --git a/dm/config/task_test.go b/dm/config/task_test.go index 462c9ceb8e..305b84484a 100644 --- a/dm/config/task_test.go +++ b/dm/config/task_test.go @@ -289,7 +289,7 @@ mysql-instances: err := taskConfig.Decode(errorTaskConfig1) // field server-id is not a member of TaskConfig c.Check(err, NotNil) - c.Assert(err, ErrorMatches, "*line 18: field server-id not found in type config.MySQLInstance.*") + c.Assert(err, ErrorMatches, "*line 17: field server-id not found in type config.MySQLInstance.*") err = taskConfig.Decode(errorTaskConfig2) // field name duplicate @@ -640,7 +640,7 @@ func (t *testConfig) TestGenAndFromSubTaskConfigs(c *C) { BinLogPos: 456, BinLogGTID: "1-1-12,4-4-4", }, - From: source1DBCfg, + From: source1DBCfg, To: DBConfig{ Host: "127.0.0.1", Port: 4000, diff --git a/dumpling/dumpling.go b/dumpling/dumpling.go index 9c9de1ae3d..975945f1eb 100644 --- a/dumpling/dumpling.go +++ b/dumpling/dumpling.go @@ -61,7 +61,7 @@ func (m *Dumpling) Init(ctx context.Context) error { m.dumpConfig, err = m.constructArgs() m.detectSQLMode(ctx) m.dumpConfig.SessionParams["time_zone"] = "+00:00" - m.logger.Info("create dumpling", zap.Stringer("config", m.dumpConfig)) + m.logger.Info("create dumpling", zap.Stringer("config", m.dumpConfig)) return err } diff --git a/pkg/utils/common_test.go b/pkg/utils/common_test.go index 9e48766760..c199c74df0 100644 --- a/pkg/utils/common_test.go +++ b/pkg/utils/common_test.go @@ -267,7 +267,6 @@ func (s *testCommonSuite) TestParseTimeZone(c *C) { "+12:59": 12*time.Hour + 59*time.Minute, "Asia/Shanghai": 8 * time.Hour, "UTC": time.Duration(0), - "CST": -1 * 6 * time.Hour, } for k, v := range cases { dur, err := ParseTimeZone(k) diff --git a/syncer/db_test.go b/syncer/db_test.go index 9aad570b05..93af69963a 100644 --- a/syncer/db_test.go +++ b/syncer/db_test.go @@ -255,9 +255,6 @@ func (s *testDBSuite) TestTimezone(c *C) { err = txn.Commit() c.Assert(err, IsNil) - location, err := utils.ParseTimeZone(testCase.timezone) - c.Assert(err, IsNil) - idx := 0 for { if idx >= len(testCase.sqls) { @@ -280,7 +277,7 @@ func (s *testDBSuite) TestTimezone(c *C) { c.Assert(ts.Valid, IsTrue) raw := ev.Rows[0][1].(string) - data, err := time.ParseInLocation("2006-01-02 15:04:05", raw, location) + data, err := time.ParseInLocation("2006-01-02 15:04:05", raw, time.UTC) c.Assert(err, IsNil) c.Assert(data.Unix(), DeepEquals, ts.Int64) idx++ diff --git a/tests/all_mode/data/db1.increment.sql b/tests/all_mode/data/db1.increment.sql index f602f85878..4509ea3a3a 100644 --- a/tests/all_mode/data/db1.increment.sql +++ b/tests/all_mode/data/db1.increment.sql @@ -45,4 +45,4 @@ insert into t1 (id, name, info, lat, big1, big2) values (12, 'gentest', '{"id":1 -- test with different session time_zone SET @@session.time_zone = '+07:00'; -insert into t1 (id, name, info) values (13, 'tztest', '{"id": 122}'); +insert into t1 (id, name, info) values (13, 'tztest', '{"id": 132}'); diff --git a/tests/dmctl_basic/conf/get_task.yaml b/tests/dmctl_basic/conf/get_task.yaml index d03f85fb6d..eff8d4d84d 100644 --- a/tests/dmctl_basic/conf/get_task.yaml +++ b/tests/dmctl_basic/conf/get_task.yaml @@ -16,6 +16,7 @@ target-database: max-allowed-packet: null session: tidb_txn_mode: optimistic + time_zone: "+00:00" security: null mysql-instances: - source-id: mysql-replica-01 diff --git a/tests/full_mode/run.sh b/tests/full_mode/run.sh index 273f42af93..e0c5b4fa7d 100755 --- a/tests/full_mode/run.sh +++ b/tests/full_mode/run.sh @@ -42,7 +42,7 @@ function fail_acquire_global_lock() { "\"result\": true" 1 cp $cur/conf/dm-task.yaml $WORK_DIR/dm-task.yaml - sed -i '/timezone/i\ignore-checking-items: ["dump_privilege"]' $WORK_DIR/dm-task.yaml + sed -i '/heartbeat-report-interval/i\ignore-checking-items: ["dump_privilege"]' $WORK_DIR/dm-task.yaml run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ "start-task $WORK_DIR/dm-task.yaml --remove-meta" diff --git a/tests/import_v10x/conf/task.yaml b/tests/import_v10x/conf/task.yaml index 0f8f6ac42b..41ece6babd 100644 --- a/tests/import_v10x/conf/task.yaml +++ b/tests/import_v10x/conf/task.yaml @@ -18,6 +18,7 @@ target-database: tidb_disable_txn_auto_retry: "off" tidb_retry_limit: "10" tidb_skip_utf8_check: "1" + time_zone: "+00:00" security: null mysql-instances: - source-id: mysql-replica-01 diff --git a/tests/safe_mode/run.sh b/tests/safe_mode/run.sh index 780b061682..48750e5b05 100755 --- a/tests/safe_mode/run.sh +++ b/tests/safe_mode/run.sh @@ -27,7 +27,7 @@ function consistency_none() { dmctl_operate_source create $WORK_DIR/source2.yaml $SOURCE_ID2 cp $cur/conf/dm-task.yaml $WORK_DIR/dm-task.yaml - sed -i "/timezone/i\clean-dump-file: false" $WORK_DIR/dm-task.yaml + sed -i "/enable-heartbeat/i\clean-dump-file: false" $WORK_DIR/dm-task.yaml sed -i "s/extra-args: \"\"/extra-args: \"--consistency none\"/g" $WORK_DIR/dm-task.yaml dmctl_start_task "$WORK_DIR/dm-task.yaml" "--remove-meta" check_sync_diff $WORK_DIR $cur/conf/diff_config.toml