From 0a0d8f7716abd1761750e52615dce74502d20905 Mon Sep 17 00:00:00 2001 From: Chunzhu Li Date: Fri, 9 Dec 2022 16:23:08 +0800 Subject: [PATCH 1/4] add enable paging, parallelize test cases --- dumpling/export/block_allow_list_test.go | 4 ++ dumpling/export/config_test.go | 6 ++ dumpling/export/consistency_test.go | 12 ++++ dumpling/export/dump.go | 18 ++++++ dumpling/export/dump_test.go | 77 ++++++++++++++++++++++++ dumpling/export/ir_impl_test.go | 4 ++ dumpling/export/metadata_test.go | 18 ++++++ dumpling/export/prepare_test.go | 12 ++++ dumpling/export/sql_test.go | 46 ++++++++++++++ dumpling/export/sql_type_test.go | 2 + dumpling/export/status_test.go | 4 ++ dumpling/export/util_test.go | 4 ++ dumpling/export/writer_serial_test.go | 14 +++++ dumpling/export/writer_test.go | 20 +++++- 14 files changed, 240 insertions(+), 1 deletion(-) diff --git a/dumpling/export/block_allow_list_test.go b/dumpling/export/block_allow_list_test.go index 28faa4e95f261..2086f652bbbaa 100644 --- a/dumpling/export/block_allow_list_test.go +++ b/dumpling/export/block_allow_list_test.go @@ -14,6 +14,8 @@ import ( ) func TestFilterTables(t *testing.T) { + t.Parallel() + tctx := tcontext.Background().WithLogger(appLogger) dbTables := DatabaseTables{} expectedDBTables := DatabaseTables{} @@ -46,6 +48,8 @@ func TestFilterTables(t *testing.T) { } func TestFilterDatabaseWithNoTable(t *testing.T) { + t.Parallel() + dbTables := DatabaseTables{} expectedDBTables := DatabaseTables{} diff --git a/dumpling/export/config_test.go b/dumpling/export/config_test.go index 966a933881497..a456b0ef4a3d1 100644 --- a/dumpling/export/config_test.go +++ b/dumpling/export/config_test.go @@ -12,6 +12,8 @@ import ( ) func TestCreateExternalStorage(t *testing.T) { + t.Parallel() + mockConfig := defaultConfigForTest(t) loc, err := mockConfig.createExternalStorage(tcontext.Background()) require.NoError(t, err) @@ -19,6 +21,8 @@ func TestCreateExternalStorage(t *testing.T) { } func TestMatchMysqlBugVersion(t *testing.T) { + t.Parallel() + cases := []struct { serverInfo version.ServerInfo expected bool @@ -35,6 +39,8 @@ func TestMatchMysqlBugVersion(t *testing.T) { } func TestGetConfTables(t *testing.T) { + t.Parallel() + tablesList := []string{"db1t1", "db2.t1"} _, err := GetConfTables(tablesList) require.EqualError(t, err, fmt.Sprintf("--tables-list only accepts qualified table names, but `%s` lacks a dot", tablesList[0])) diff --git a/dumpling/export/consistency_test.go b/dumpling/export/consistency_test.go index 555338803d40d..f1bc12da163aa 100644 --- a/dumpling/export/consistency_test.go +++ b/dumpling/export/consistency_test.go @@ -18,6 +18,8 @@ import ( ) func TestConsistencyController(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -72,6 +74,8 @@ func TestConsistencyController(t *testing.T) { } func TestConsistencyLockControllerRetry(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -108,6 +112,8 @@ func TestConsistencyLockControllerRetry(t *testing.T) { } func TestConsistencyLockControllerEmpty(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -141,6 +147,8 @@ func TestConsistencyLockControllerEmpty(t *testing.T) { } func TestResolveAutoConsistency(t *testing.T) { + t.Parallel() + conf := defaultConfigForTest(t) cases := []struct { serverTp version.ServerType @@ -198,6 +206,8 @@ func TestResolveAutoConsistency(t *testing.T) { } func TestConsistencyControllerError(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -237,6 +247,8 @@ func TestConsistencyControllerError(t *testing.T) { } func TestConsistencyLockTiDBCheck(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { diff --git a/dumpling/export/dump.go b/dumpling/export/dump.go index 291b02b30bff9..4bffc5e760933 100644 --- a/dumpling/export/dump.go +++ b/dumpling/export/dump.go @@ -15,6 +15,7 @@ import ( "sync/atomic" "time" + "github.com/coreos/go-semver/semver" // import mysql driver "github.com/go-sql-driver/mysql" "github.com/pingcap/errors" @@ -42,6 +43,10 @@ var openDBFunc = openDB var errEmptyHandleVals = errors.New("empty handleVals for TiDB table") +// After TiDB v6.2.0 we always enable tidb_enable_paging by default. +// see https://docs.pingcap.com/zh/tidb/dev/system-variables#tidb_enable_paging-%E4%BB%8E-v540-%E7%89%88%E6%9C%AC%E5%BC%80%E5%A7%8B%E5%BC%95%E5%85%A5 +var enablePagingVersion = semver.New("6.2.0") + // Dumper is the dump progress structure type Dumper struct { tctx *tcontext.Context @@ -1508,6 +1513,19 @@ func updateServiceSafePoint(tctx *tcontext.Context, pdClient pd.Client, ttl int6 } } +// setDefaultSessionParams is a step to set default params for session params. +func setDefaultSessionParams(si version.ServerInfo, sessionParams map[string]interface{}) { + defaultSessionParams := map[string]interface{}{} + if si.ServerType == version.ServerTypeTiDB && si.HasTiKV && si.ServerVersion.Compare(*enablePagingVersion) >= 0 { + defaultSessionParams["tidb_enable_paging"] = "ON" + } + for k, v := range defaultSessionParams { + if _, ok := sessionParams[k]; !ok { + sessionParams[k] = v + } + } +} + // setSessionParam is an initialization step of Dumper. func setSessionParam(d *Dumper) error { conf, pool := d.conf, d.dbHandle diff --git a/dumpling/export/dump_test.go b/dumpling/export/dump_test.go index c9a40bba28d6f..d4f3cbdc97669 100644 --- a/dumpling/export/dump_test.go +++ b/dumpling/export/dump_test.go @@ -9,6 +9,7 @@ import ( "time" "github.com/DATA-DOG/go-sqlmock" + "github.com/coreos/go-semver/semver" "github.com/pingcap/errors" "github.com/pingcap/tidb/br/pkg/version" tcontext "github.com/pingcap/tidb/dumpling/context" @@ -19,6 +20,8 @@ import ( ) func TestDumpExit(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -66,6 +69,8 @@ func TestDumpExit(t *testing.T) { } func TestDumpTableMeta(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -106,6 +111,8 @@ func TestDumpTableMeta(t *testing.T) { } func TestGetListTableTypeByConf(t *testing.T) { + t.Parallel() + conf := defaultConfigForTest(t) cases := []struct { serverInfo version.ServerInfo @@ -132,6 +139,8 @@ func TestGetListTableTypeByConf(t *testing.T) { } func TestAdjustDatabaseCollation(t *testing.T) { + t.Parallel() + tctx, cancel := tcontext.Background().WithLogger(appLogger).WithCancel() defer cancel() parser1 := parser.New() @@ -161,6 +170,8 @@ func TestAdjustDatabaseCollation(t *testing.T) { } func TestAdjustTableCollation(t *testing.T) { + t.Parallel() + tctx, cancel := tcontext.Background().WithLogger(appLogger).WithCancel() defer cancel() @@ -224,3 +235,69 @@ func TestUnregisterMetrics(t *testing.T) { // should not panic require.Error(t, err) } + +func TestSetDefaultSessionParams(t *testing.T) { + t.Parallel() + + testCases := []struct { + si version.ServerInfo + sessionParams map[string]interface{} + expectedParams map[string]interface{} + }{ + { + si: version.ServerInfo{ + ServerType: version.ServerTypeTiDB, + HasTiKV: true, + ServerVersion: semver.New("6.1.0"), + }, + sessionParams: map[string]interface{}{ + "tidb_snapshot": "2020-01-01 00:00:00", + }, + expectedParams: map[string]interface{}{ + "tidb_snapshot": "2020-01-01 00:00:00", + }, + }, + { + si: version.ServerInfo{ + ServerType: version.ServerTypeTiDB, + HasTiKV: true, + ServerVersion: semver.New("6.2.0"), + }, + sessionParams: map[string]interface{}{ + "tidb_snapshot": "2020-01-01 00:00:00", + }, + expectedParams: map[string]interface{}{ + "tidb_enable_paging": "ON", + "tidb_snapshot": "2020-01-01 00:00:00", + }, + }, + { + si: version.ServerInfo{ + ServerType: version.ServerTypeTiDB, + HasTiKV: true, + ServerVersion: semver.New("6.2.0"), + }, + sessionParams: map[string]interface{}{ + "tidb_enable_paging": "OFF", + "tidb_snapshot": "2020-01-01 00:00:00", + }, + expectedParams: map[string]interface{}{ + "tidb_enable_paging": "OFF", + "tidb_snapshot": "2020-01-01 00:00:00", + }, + }, + { + si: version.ServerInfo{ + ServerType: version.ServerTypeMySQL, + ServerVersion: semver.New("8.0.32"), + }, + sessionParams: map[string]interface{}{}, + expectedParams: map[string]interface{}{}, + }, + } + + for _, testCase := range testCases { + setDefaultSessionParams(testCase.si, testCase.sessionParams) + require.Equal(t, testCase.expectedParams, testCase.sessionParams) + } +} diff --git a/dumpling/export/ir_impl_test.go b/dumpling/export/ir_impl_test.go index b614f0ae9912f..07a0a93f9ccf5 100644 --- a/dumpling/export/ir_impl_test.go +++ b/dumpling/export/ir_impl_test.go @@ -26,6 +26,8 @@ func (s *simpleRowReceiver) BindAddress(args []interface{}) { } func TestRowIter(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -65,6 +67,8 @@ func TestRowIter(t *testing.T) { } func TestChunkRowIter(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { diff --git a/dumpling/export/metadata_test.go b/dumpling/export/metadata_test.go index 90099bbf00acd..192735bb35215 100644 --- a/dumpling/export/metadata_test.go +++ b/dumpling/export/metadata_test.go @@ -23,6 +23,8 @@ const ( ) func TestMysqlMetaData(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -51,6 +53,8 @@ func TestMysqlMetaData(t *testing.T) { } func TestMetaDataAfterConn(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -90,6 +94,8 @@ func TestMetaDataAfterConn(t *testing.T) { } func TestMysqlWithFollowersMetaData(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -124,6 +130,8 @@ func TestMysqlWithFollowersMetaData(t *testing.T) { } func TestMysqlWithNullFollowersMetaData(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -151,6 +159,8 @@ func TestMysqlWithNullFollowersMetaData(t *testing.T) { } func TestMariaDBMetaData(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -176,6 +186,8 @@ func TestMariaDBMetaData(t *testing.T) { } func TestMariaDBWithFollowersMetaData(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -220,6 +232,8 @@ func TestMariaDBWithFollowersMetaData(t *testing.T) { } func TestEarlierMysqlMetaData(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -250,6 +264,8 @@ func TestEarlierMysqlMetaData(t *testing.T) { } func TestTiDBSnapshotMetaData(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -290,6 +306,8 @@ func TestTiDBSnapshotMetaData(t *testing.T) { } func TestNoPrivilege(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { diff --git a/dumpling/export/prepare_test.go b/dumpling/export/prepare_test.go index ebfb2ee7efe48..52bdc7e8488a2 100644 --- a/dumpling/export/prepare_test.go +++ b/dumpling/export/prepare_test.go @@ -14,6 +14,8 @@ import ( ) func TestPrepareDumpingDatabases(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -62,6 +64,8 @@ func TestPrepareDumpingDatabases(t *testing.T) { } func TestListAllTables(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -124,6 +128,8 @@ func TestListAllTables(t *testing.T) { } func TestListAllTablesByTableStatus(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -190,6 +196,8 @@ func TestListAllTablesByTableStatus(t *testing.T) { } func TestListAllTablesByShowFullTables(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -265,6 +273,8 @@ func TestListAllTablesByShowFullTables(t *testing.T) { } func TestConfigValidation(t *testing.T) { + t.Parallel() + conf := defaultConfigForTest(t) conf.Where = "id < 5" conf.SQL = "select * from t where id > 3" @@ -298,6 +308,8 @@ func TestConfigValidation(t *testing.T) { } func TestValidateResolveAutoConsistency(t *testing.T) { + t.Parallel() + conf1 := defaultConfigForTest(t) d := &Dumper{conf: conf1} conf := d.conf diff --git a/dumpling/export/sql_test.go b/dumpling/export/sql_test.go index 04615637be8f1..4732cd8807aa6 100644 --- a/dumpling/export/sql_test.go +++ b/dumpling/export/sql_test.go @@ -47,6 +47,8 @@ const ( ) func TestBuildSelectAllQuery(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -170,6 +172,8 @@ func TestBuildSelectAllQuery(t *testing.T) { } func TestBuildOrderByClause(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -248,6 +252,8 @@ func TestBuildOrderByClause(t *testing.T) { } func TestBuildSelectField(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -311,6 +317,8 @@ func TestBuildSelectField(t *testing.T) { } func TestParseSnapshotToTSO(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -339,6 +347,8 @@ func TestParseSnapshotToTSO(t *testing.T) { } func TestShowCreateView(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -366,6 +376,8 @@ func TestShowCreateView(t *testing.T) { } func TestShowCreateSequence(t *testing.T) { + t.Parallel() + conf := defaultConfigForTest(t) db, mock, err := sqlmock.New() require.NoError(t, err) @@ -406,6 +418,8 @@ func TestShowCreateSequence(t *testing.T) { } func TestShowCreatePolicy(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -428,6 +442,8 @@ func TestShowCreatePolicy(t *testing.T) { } func TestListPolicyNames(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -458,6 +474,8 @@ func TestListPolicyNames(t *testing.T) { } func TestGetSuitableRows(t *testing.T) { + t.Parallel() + testCases := []struct { avgRowLength uint64 expectedRows uint64 @@ -486,6 +504,8 @@ func TestGetSuitableRows(t *testing.T) { } func TestSelectTiDBRowID(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -523,6 +543,8 @@ func TestSelectTiDBRowID(t *testing.T) { } func TestBuildTableSampleQueries(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -842,6 +864,8 @@ func TestBuildTableSampleQueries(t *testing.T) { } func TestBuildPartitionClauses(t *testing.T) { + t.Parallel() + const ( dbName = "test" tbName = "t" @@ -900,6 +924,8 @@ func TestBuildPartitionClauses(t *testing.T) { } func TestBuildWhereCondition(t *testing.T) { + t.Parallel() + conf := DefaultConfig() testCases := []struct { confWhere string @@ -935,6 +961,8 @@ func TestBuildWhereCondition(t *testing.T) { } func TestBuildRegionQueriesWithoutPartition(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -1096,6 +1124,8 @@ func TestBuildRegionQueriesWithoutPartition(t *testing.T) { } func TestBuildRegionQueriesWithPartitions(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -1308,6 +1338,8 @@ func buildMockNewRows(mock sqlmock.Sqlmock, columns []string, driverValues [][]d } func readRegionCsvDriverValues(t *testing.T) [][]driver.Value { + t.Helper() + csvFilename := "region_results.csv" file, err := os.Open(csvFilename) require.NoError(t, err) @@ -1331,6 +1363,8 @@ func readRegionCsvDriverValues(t *testing.T) [][]driver.Value { } func TestBuildVersion3RegionQueries(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -1609,6 +1643,8 @@ func TestBuildVersion3RegionQueries(t *testing.T) { } func TestCheckTiDBWithTiKV(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -1656,6 +1692,8 @@ func TestCheckTiDBWithTiKV(t *testing.T) { } func TestPickupPossibleField(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -1801,6 +1839,8 @@ func TestPickupPossibleField(t *testing.T) { } func TestCheckIfSeqExists(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -1828,6 +1868,8 @@ func TestCheckIfSeqExists(t *testing.T) { } func TestGetCharsetAndDefaultCollation(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -1849,6 +1891,8 @@ func TestGetCharsetAndDefaultCollation(t *testing.T) { } func TestGetSpecifiedColumnValueAndClose(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -1879,6 +1923,8 @@ func TestGetSpecifiedColumnValueAndClose(t *testing.T) { } func TestGetSpecifiedColumnValuesAndClose(t *testing.T) { + t.Parallel() + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { diff --git a/dumpling/export/sql_type_test.go b/dumpling/export/sql_type_test.go index 1ed75a3247472..97ae6d058123f 100644 --- a/dumpling/export/sql_type_test.go +++ b/dumpling/export/sql_type_test.go @@ -10,6 +10,8 @@ import ( ) func TestEscape(t *testing.T) { + t.Parallel() + var bf bytes.Buffer str := []byte(`MWQeWw""'\rNmtGxzGp`) expectStrBackslash := `MWQeWw\"\"\'\\rNmtGxzGp` diff --git a/dumpling/export/status_test.go b/dumpling/export/status_test.go index 7c340b06dcf83..095dd11f99dd2 100644 --- a/dumpling/export/status_test.go +++ b/dumpling/export/status_test.go @@ -11,6 +11,8 @@ import ( ) func TestGetParameters(t *testing.T) { + t.Parallel() + conf := defaultConfigForTest(t) d := &Dumper{conf: conf, speedRecorder: NewSpeedRecorder()} d.metrics = newMetrics(conf.PromFactory, nil) @@ -34,6 +36,8 @@ func TestGetParameters(t *testing.T) { } func TestSpeedRecorder(t *testing.T) { + t.Parallel() + testCases := []struct { spentTime int64 finished float64 diff --git a/dumpling/export/util_test.go b/dumpling/export/util_test.go index 35de448432cd0..c32d7f71b9fd9 100644 --- a/dumpling/export/util_test.go +++ b/dumpling/export/util_test.go @@ -11,6 +11,8 @@ import ( ) func TestRepeatableRead(t *testing.T) { + t.Parallel() + data := [][]interface{}{ {version.ServerTypeUnknown, ConsistencyTypeNone, true}, {version.ServerTypeMySQL, ConsistencyTypeFlush, true}, @@ -31,6 +33,8 @@ func TestRepeatableRead(t *testing.T) { } func TestInfiniteChan(t *testing.T) { + t.Parallel() + in, out := infiniteChan[int]() go func() { for i := 0; i < 10000; i++ { diff --git a/dumpling/export/writer_serial_test.go b/dumpling/export/writer_serial_test.go index 2290ca86cdfa2..7052bb6a4b5ee 100644 --- a/dumpling/export/writer_serial_test.go +++ b/dumpling/export/writer_serial_test.go @@ -16,6 +16,8 @@ import ( ) func TestWriteMeta(t *testing.T) { + t.Parallel() + createTableStmt := "CREATE TABLE `t1` (\n" + " `a` int(11) DEFAULT NULL\n" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;\n" @@ -34,6 +36,8 @@ func TestWriteMeta(t *testing.T) { } func TestWriteInsert(t *testing.T) { + t.Parallel() + cfg := createMockConfig() data := [][]driver.Value{ @@ -69,6 +73,8 @@ func TestWriteInsert(t *testing.T) { } func TestWriteInsertReturnsError(t *testing.T) { + t.Parallel() + cfg := createMockConfig() data := [][]driver.Value{ @@ -107,6 +113,8 @@ func TestWriteInsertReturnsError(t *testing.T) { } func TestWriteInsertInCsv(t *testing.T) { + t.Parallel() + cfg := createMockConfig() data := [][]driver.Value{ @@ -194,6 +202,8 @@ func TestWriteInsertInCsv(t *testing.T) { } func TestWriteInsertInCsvReturnsError(t *testing.T) { + t.Parallel() + cfg := createMockConfig() data := [][]driver.Value{ @@ -227,6 +237,8 @@ func TestWriteInsertInCsvReturnsError(t *testing.T) { } func TestSQLDataTypes(t *testing.T) { + t.Parallel() + cfg := createMockConfig() data := [][]driver.Value{ @@ -258,6 +270,8 @@ func TestSQLDataTypes(t *testing.T) { } func TestWrite(t *testing.T) { + t.Parallel() + mocksw := &mockPoisonWriter{} src := []string{"test", "loooooooooooooooooooong", "poison"} exp := []string{"test", "loooooooooooooooooooong", "poison_error"} diff --git a/dumpling/export/writer_test.go b/dumpling/export/writer_test.go index b5f54f3debcb9..30ee6ae9f53ec 100644 --- a/dumpling/export/writer_test.go +++ b/dumpling/export/writer_test.go @@ -18,6 +18,8 @@ import ( ) func TestWriteDatabaseMeta(t *testing.T) { + t.Parallel() + dir := t.TempDir() config := defaultConfigForTest(t) config.OutputDirPath = dir @@ -31,12 +33,14 @@ func TestWriteDatabaseMeta(t *testing.T) { _, err = os.Stat(p) require.NoError(t, err) - bytes, err := ioutil.ReadFile(p) + bytes, err := os.ReadFile(p) require.NoError(t, err) require.Equal(t, "/*!40101 SET NAMES binary*/;\nCREATE DATABASE `test`;\n", string(bytes)) } func TestWritePolicyMeta(t *testing.T) { + t.Parallel() + dir := t.TempDir() config := defaultConfigForTest(t) config.OutputDirPath = dir @@ -56,6 +60,8 @@ func TestWritePolicyMeta(t *testing.T) { } func TestWriteTableMeta(t *testing.T) { + t.Parallel() + dir := t.TempDir() config := defaultConfigForTest(t) @@ -74,6 +80,8 @@ func TestWriteTableMeta(t *testing.T) { } func TestWriteViewMeta(t *testing.T) { + t.Parallel() + dir := t.TempDir() config := defaultConfigForTest(t) config.OutputDirPath = dir @@ -102,6 +110,8 @@ func TestWriteViewMeta(t *testing.T) { } func TestWriteTableData(t *testing.T) { + t.Parallel() + dir := t.TempDir() config := defaultConfigForTest(t) config.OutputDirPath = dir @@ -140,6 +150,8 @@ func TestWriteTableData(t *testing.T) { } func TestWriteTableDataWithFileSize(t *testing.T) { + t.Parallel() + dir := t.TempDir() config := defaultConfigForTest(t) config.OutputDirPath = dir @@ -189,6 +201,8 @@ func TestWriteTableDataWithFileSize(t *testing.T) { } func TestWriteTableDataWithFileSizeAndRows(t *testing.T) { + t.Parallel() + dir := t.TempDir() config := defaultConfigForTest(t) config.OutputDirPath = dir @@ -239,6 +253,8 @@ func TestWriteTableDataWithFileSizeAndRows(t *testing.T) { } func TestWriteTableDataWithStatementSize(t *testing.T) { + t.Parallel() + dir := t.TempDir() config := defaultConfigForTest(t) config.OutputDirPath = dir @@ -331,6 +347,8 @@ func TestWriteTableDataWithStatementSize(t *testing.T) { var mu sync.Mutex func createTestWriter(conf *Config, t *testing.T) *Writer { + t.Helper() + mu.Lock() extStore, err := conf.createExternalStorage(context.Background()) mu.Unlock() From 8657cb79c5acc03e8860537ac56a5c17131c92cd Mon Sep 17 00:00:00 2001 From: Chunzhu Li Date: Fri, 9 Dec 2022 16:30:58 +0800 Subject: [PATCH 2/4] remove ioutil --- dumpling/export/writer_test.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/dumpling/export/writer_test.go b/dumpling/export/writer_test.go index 30ee6ae9f53ec..ccc20936a8be4 100644 --- a/dumpling/export/writer_test.go +++ b/dumpling/export/writer_test.go @@ -5,7 +5,6 @@ package export import ( "context" "database/sql/driver" - "io/ioutil" "os" "path" "sync" @@ -54,7 +53,7 @@ func TestWritePolicyMeta(t *testing.T) { _, err = os.Stat(p) require.NoError(t, err) - bytes, err := ioutil.ReadFile(p) + bytes, err := os.ReadFile(p) require.NoError(t, err) require.Equal(t, "/*!40101 SET NAMES binary*/;\ncreate placement policy `y` followers=2;\n", string(bytes)) } @@ -74,7 +73,7 @@ func TestWriteTableMeta(t *testing.T) { p := path.Join(dir, "test.t-schema.sql") _, err = os.Stat(p) require.NoError(t, err) - bytes, err := ioutil.ReadFile(p) + bytes, err := os.ReadFile(p) require.NoError(t, err) require.Equal(t, "/*!40101 SET NAMES binary*/;\nCREATE TABLE t (a INT);\n", string(bytes)) } @@ -97,14 +96,14 @@ func TestWriteViewMeta(t *testing.T) { p := path.Join(dir, "test.v-schema.sql") _, err = os.Stat(p) require.NoError(t, err) - bytes, err := ioutil.ReadFile(p) + bytes, err := os.ReadFile(p) require.NoError(t, err) require.Equal(t, specCmt+createTableSQL, string(bytes)) p = path.Join(dir, "test.v-schema-view.sql") _, err = os.Stat(p) require.NoError(t, err) - bytes, err = ioutil.ReadFile(p) + bytes, err = os.ReadFile(p) require.NoError(t, err) require.Equal(t, specCmt+createViewSQL, string(bytes)) } @@ -136,7 +135,7 @@ func TestWriteTableData(t *testing.T) { p := path.Join(dir, "test.employee.000000000.sql") _, err = os.Stat(p) require.NoError(t, err) - bytes, err := ioutil.ReadFile(p) + bytes, err := os.ReadFile(p) require.NoError(t, err) expected := "/*!40101 SET NAMES binary*/;\n" + @@ -194,7 +193,7 @@ func TestWriteTableDataWithFileSize(t *testing.T) { p = path.Join(dir, p) _, err := os.Stat(p) require.NoError(t, err) - bytes, err := ioutil.ReadFile(p) + bytes, err := os.ReadFile(p) require.NoError(t, err) require.Equal(t, expected, string(bytes)) } @@ -246,7 +245,7 @@ func TestWriteTableDataWithFileSizeAndRows(t *testing.T) { p = path.Join(dir, p) _, err = os.Stat(p) require.NoError(t, err) - bytes, err := ioutil.ReadFile(p) + bytes, err := os.ReadFile(p) require.NoError(t, err) require.Equal(t, expected, string(bytes)) } @@ -297,7 +296,7 @@ func TestWriteTableDataWithStatementSize(t *testing.T) { p = path.Join(config.OutputDirPath, p) _, err = os.Stat(p) require.NoError(t, err) - bytes, err1 := ioutil.ReadFile(p) + bytes, err1 := os.ReadFile(p) require.NoError(t, err1) require.Equal(t, expected, string(bytes)) } @@ -313,7 +312,7 @@ func TestWriteTableDataWithStatementSize(t *testing.T) { require.NoError(t, err) err = os.RemoveAll(config.OutputDirPath) require.NoError(t, err) - config.OutputDirPath, err = ioutil.TempDir("", "dumpling") + config.OutputDirPath, err = os.MkdirTemp("", "dumpling") writer = createTestWriter(config, t) @@ -338,7 +337,7 @@ func TestWriteTableDataWithStatementSize(t *testing.T) { p = path.Join(config.OutputDirPath, p) _, err = os.Stat(p) require.NoError(t, err) - bytes, err := ioutil.ReadFile(p) + bytes, err := os.ReadFile(p) require.NoError(t, err) require.Equal(t, expected, string(bytes)) } From 63b3bee6c6d218b5b3eed35a48a1ef4c592d0df9 Mon Sep 17 00:00:00 2001 From: Chunzhu Li Date: Fri, 9 Dec 2022 17:03:32 +0800 Subject: [PATCH 3/4] fix bazel --- dumpling/export/BUILD.bazel | 1 + dumpling/export/block_allow_list_test.go | 2 +- dumpling/export/config_test.go | 2 +- dumpling/export/ir_impl_test.go | 2 +- dumpling/export/prepare_test.go | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dumpling/export/BUILD.bazel b/dumpling/export/BUILD.bazel index c9aebfb577c8a..18ea8a2e65814 100644 --- a/dumpling/export/BUILD.bazel +++ b/dumpling/export/BUILD.bazel @@ -102,6 +102,7 @@ go_test( "//util/filter", "//util/promutil", "//util/table-filter", + "@com_github_coreos_go_semver//semver", "@com_github_data_dog_go_sqlmock//:go-sqlmock", "@com_github_go_sql_driver_mysql//:mysql", "@com_github_pingcap_errors//:errors", diff --git a/dumpling/export/block_allow_list_test.go b/dumpling/export/block_allow_list_test.go index 2086f652bbbaa..607abd86f0cad 100644 --- a/dumpling/export/block_allow_list_test.go +++ b/dumpling/export/block_allow_list_test.go @@ -49,7 +49,7 @@ func TestFilterTables(t *testing.T) { func TestFilterDatabaseWithNoTable(t *testing.T) { t.Parallel() - + dbTables := DatabaseTables{} expectedDBTables := DatabaseTables{} diff --git a/dumpling/export/config_test.go b/dumpling/export/config_test.go index a456b0ef4a3d1..8f2e72bd09f65 100644 --- a/dumpling/export/config_test.go +++ b/dumpling/export/config_test.go @@ -40,7 +40,7 @@ func TestMatchMysqlBugVersion(t *testing.T) { func TestGetConfTables(t *testing.T) { t.Parallel() - + tablesList := []string{"db1t1", "db2.t1"} _, err := GetConfTables(tablesList) require.EqualError(t, err, fmt.Sprintf("--tables-list only accepts qualified table names, but `%s` lacks a dot", tablesList[0])) diff --git a/dumpling/export/ir_impl_test.go b/dumpling/export/ir_impl_test.go index 07a0a93f9ccf5..e82977ba9a98a 100644 --- a/dumpling/export/ir_impl_test.go +++ b/dumpling/export/ir_impl_test.go @@ -68,7 +68,7 @@ func TestRowIter(t *testing.T) { func TestChunkRowIter(t *testing.T) { t.Parallel() - + db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { diff --git a/dumpling/export/prepare_test.go b/dumpling/export/prepare_test.go index 52bdc7e8488a2..bbbcd21c398cc 100644 --- a/dumpling/export/prepare_test.go +++ b/dumpling/export/prepare_test.go @@ -309,7 +309,7 @@ func TestConfigValidation(t *testing.T) { func TestValidateResolveAutoConsistency(t *testing.T) { t.Parallel() - + conf1 := defaultConfigForTest(t) d := &Dumper{conf: conf1} conf := d.conf From 74803c2e7ec4cd897cd293429d11ec6530df7941 Mon Sep 17 00:00:00 2001 From: Chunzhu Li Date: Fri, 9 Dec 2022 20:14:06 +0800 Subject: [PATCH 4/4] fix --- dumpling/export/block_allow_list_test.go | 4 --- dumpling/export/config_test.go | 6 ---- dumpling/export/consistency_test.go | 12 ------- dumpling/export/dump_test.go | 12 ------- dumpling/export/ir_impl_test.go | 4 --- dumpling/export/metadata_test.go | 18 ---------- dumpling/export/prepare_test.go | 12 ------- dumpling/export/sql_test.go | 44 ------------------------ dumpling/export/sql_type_test.go | 2 -- dumpling/export/status_test.go | 4 --- dumpling/export/util_test.go | 4 --- dumpling/export/writer_serial_test.go | 14 -------- dumpling/export/writer_test.go | 16 --------- 13 files changed, 152 deletions(-) diff --git a/dumpling/export/block_allow_list_test.go b/dumpling/export/block_allow_list_test.go index 607abd86f0cad..28faa4e95f261 100644 --- a/dumpling/export/block_allow_list_test.go +++ b/dumpling/export/block_allow_list_test.go @@ -14,8 +14,6 @@ import ( ) func TestFilterTables(t *testing.T) { - t.Parallel() - tctx := tcontext.Background().WithLogger(appLogger) dbTables := DatabaseTables{} expectedDBTables := DatabaseTables{} @@ -48,8 +46,6 @@ func TestFilterTables(t *testing.T) { } func TestFilterDatabaseWithNoTable(t *testing.T) { - t.Parallel() - dbTables := DatabaseTables{} expectedDBTables := DatabaseTables{} diff --git a/dumpling/export/config_test.go b/dumpling/export/config_test.go index 8f2e72bd09f65..966a933881497 100644 --- a/dumpling/export/config_test.go +++ b/dumpling/export/config_test.go @@ -12,8 +12,6 @@ import ( ) func TestCreateExternalStorage(t *testing.T) { - t.Parallel() - mockConfig := defaultConfigForTest(t) loc, err := mockConfig.createExternalStorage(tcontext.Background()) require.NoError(t, err) @@ -21,8 +19,6 @@ func TestCreateExternalStorage(t *testing.T) { } func TestMatchMysqlBugVersion(t *testing.T) { - t.Parallel() - cases := []struct { serverInfo version.ServerInfo expected bool @@ -39,8 +35,6 @@ func TestMatchMysqlBugVersion(t *testing.T) { } func TestGetConfTables(t *testing.T) { - t.Parallel() - tablesList := []string{"db1t1", "db2.t1"} _, err := GetConfTables(tablesList) require.EqualError(t, err, fmt.Sprintf("--tables-list only accepts qualified table names, but `%s` lacks a dot", tablesList[0])) diff --git a/dumpling/export/consistency_test.go b/dumpling/export/consistency_test.go index f1bc12da163aa..555338803d40d 100644 --- a/dumpling/export/consistency_test.go +++ b/dumpling/export/consistency_test.go @@ -18,8 +18,6 @@ import ( ) func TestConsistencyController(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -74,8 +72,6 @@ func TestConsistencyController(t *testing.T) { } func TestConsistencyLockControllerRetry(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -112,8 +108,6 @@ func TestConsistencyLockControllerRetry(t *testing.T) { } func TestConsistencyLockControllerEmpty(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -147,8 +141,6 @@ func TestConsistencyLockControllerEmpty(t *testing.T) { } func TestResolveAutoConsistency(t *testing.T) { - t.Parallel() - conf := defaultConfigForTest(t) cases := []struct { serverTp version.ServerType @@ -206,8 +198,6 @@ func TestResolveAutoConsistency(t *testing.T) { } func TestConsistencyControllerError(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -247,8 +237,6 @@ func TestConsistencyControllerError(t *testing.T) { } func TestConsistencyLockTiDBCheck(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { diff --git a/dumpling/export/dump_test.go b/dumpling/export/dump_test.go index d4f3cbdc97669..7d621857f3a85 100644 --- a/dumpling/export/dump_test.go +++ b/dumpling/export/dump_test.go @@ -20,8 +20,6 @@ import ( ) func TestDumpExit(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -69,8 +67,6 @@ func TestDumpExit(t *testing.T) { } func TestDumpTableMeta(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -111,8 +107,6 @@ func TestDumpTableMeta(t *testing.T) { } func TestGetListTableTypeByConf(t *testing.T) { - t.Parallel() - conf := defaultConfigForTest(t) cases := []struct { serverInfo version.ServerInfo @@ -139,8 +133,6 @@ func TestGetListTableTypeByConf(t *testing.T) { } func TestAdjustDatabaseCollation(t *testing.T) { - t.Parallel() - tctx, cancel := tcontext.Background().WithLogger(appLogger).WithCancel() defer cancel() parser1 := parser.New() @@ -170,8 +162,6 @@ func TestAdjustDatabaseCollation(t *testing.T) { } func TestAdjustTableCollation(t *testing.T) { - t.Parallel() - tctx, cancel := tcontext.Background().WithLogger(appLogger).WithCancel() defer cancel() @@ -237,8 +227,6 @@ func TestUnregisterMetrics(t *testing.T) { } func TestSetDefaultSessionParams(t *testing.T) { - t.Parallel() - testCases := []struct { si version.ServerInfo sessionParams map[string]interface{} diff --git a/dumpling/export/ir_impl_test.go b/dumpling/export/ir_impl_test.go index e82977ba9a98a..b614f0ae9912f 100644 --- a/dumpling/export/ir_impl_test.go +++ b/dumpling/export/ir_impl_test.go @@ -26,8 +26,6 @@ func (s *simpleRowReceiver) BindAddress(args []interface{}) { } func TestRowIter(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -67,8 +65,6 @@ func TestRowIter(t *testing.T) { } func TestChunkRowIter(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { diff --git a/dumpling/export/metadata_test.go b/dumpling/export/metadata_test.go index 192735bb35215..90099bbf00acd 100644 --- a/dumpling/export/metadata_test.go +++ b/dumpling/export/metadata_test.go @@ -23,8 +23,6 @@ const ( ) func TestMysqlMetaData(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -53,8 +51,6 @@ func TestMysqlMetaData(t *testing.T) { } func TestMetaDataAfterConn(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -94,8 +90,6 @@ func TestMetaDataAfterConn(t *testing.T) { } func TestMysqlWithFollowersMetaData(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -130,8 +124,6 @@ func TestMysqlWithFollowersMetaData(t *testing.T) { } func TestMysqlWithNullFollowersMetaData(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -159,8 +151,6 @@ func TestMysqlWithNullFollowersMetaData(t *testing.T) { } func TestMariaDBMetaData(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -186,8 +176,6 @@ func TestMariaDBMetaData(t *testing.T) { } func TestMariaDBWithFollowersMetaData(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -232,8 +220,6 @@ func TestMariaDBWithFollowersMetaData(t *testing.T) { } func TestEarlierMysqlMetaData(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -264,8 +250,6 @@ func TestEarlierMysqlMetaData(t *testing.T) { } func TestTiDBSnapshotMetaData(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -306,8 +290,6 @@ func TestTiDBSnapshotMetaData(t *testing.T) { } func TestNoPrivilege(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { diff --git a/dumpling/export/prepare_test.go b/dumpling/export/prepare_test.go index bbbcd21c398cc..ebfb2ee7efe48 100644 --- a/dumpling/export/prepare_test.go +++ b/dumpling/export/prepare_test.go @@ -14,8 +14,6 @@ import ( ) func TestPrepareDumpingDatabases(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -64,8 +62,6 @@ func TestPrepareDumpingDatabases(t *testing.T) { } func TestListAllTables(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -128,8 +124,6 @@ func TestListAllTables(t *testing.T) { } func TestListAllTablesByTableStatus(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -196,8 +190,6 @@ func TestListAllTablesByTableStatus(t *testing.T) { } func TestListAllTablesByShowFullTables(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -273,8 +265,6 @@ func TestListAllTablesByShowFullTables(t *testing.T) { } func TestConfigValidation(t *testing.T) { - t.Parallel() - conf := defaultConfigForTest(t) conf.Where = "id < 5" conf.SQL = "select * from t where id > 3" @@ -308,8 +298,6 @@ func TestConfigValidation(t *testing.T) { } func TestValidateResolveAutoConsistency(t *testing.T) { - t.Parallel() - conf1 := defaultConfigForTest(t) d := &Dumper{conf: conf1} conf := d.conf diff --git a/dumpling/export/sql_test.go b/dumpling/export/sql_test.go index 4732cd8807aa6..5ae4c7278efa4 100644 --- a/dumpling/export/sql_test.go +++ b/dumpling/export/sql_test.go @@ -47,8 +47,6 @@ const ( ) func TestBuildSelectAllQuery(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -172,8 +170,6 @@ func TestBuildSelectAllQuery(t *testing.T) { } func TestBuildOrderByClause(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -252,8 +248,6 @@ func TestBuildOrderByClause(t *testing.T) { } func TestBuildSelectField(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -317,8 +311,6 @@ func TestBuildSelectField(t *testing.T) { } func TestParseSnapshotToTSO(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -347,8 +339,6 @@ func TestParseSnapshotToTSO(t *testing.T) { } func TestShowCreateView(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -376,8 +366,6 @@ func TestShowCreateView(t *testing.T) { } func TestShowCreateSequence(t *testing.T) { - t.Parallel() - conf := defaultConfigForTest(t) db, mock, err := sqlmock.New() require.NoError(t, err) @@ -418,8 +406,6 @@ func TestShowCreateSequence(t *testing.T) { } func TestShowCreatePolicy(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -442,8 +428,6 @@ func TestShowCreatePolicy(t *testing.T) { } func TestListPolicyNames(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -474,8 +458,6 @@ func TestListPolicyNames(t *testing.T) { } func TestGetSuitableRows(t *testing.T) { - t.Parallel() - testCases := []struct { avgRowLength uint64 expectedRows uint64 @@ -504,8 +486,6 @@ func TestGetSuitableRows(t *testing.T) { } func TestSelectTiDBRowID(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -543,8 +523,6 @@ func TestSelectTiDBRowID(t *testing.T) { } func TestBuildTableSampleQueries(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -864,8 +842,6 @@ func TestBuildTableSampleQueries(t *testing.T) { } func TestBuildPartitionClauses(t *testing.T) { - t.Parallel() - const ( dbName = "test" tbName = "t" @@ -924,8 +900,6 @@ func TestBuildPartitionClauses(t *testing.T) { } func TestBuildWhereCondition(t *testing.T) { - t.Parallel() - conf := DefaultConfig() testCases := []struct { confWhere string @@ -961,8 +935,6 @@ func TestBuildWhereCondition(t *testing.T) { } func TestBuildRegionQueriesWithoutPartition(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -1124,8 +1096,6 @@ func TestBuildRegionQueriesWithoutPartition(t *testing.T) { } func TestBuildRegionQueriesWithPartitions(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -1363,8 +1333,6 @@ func readRegionCsvDriverValues(t *testing.T) [][]driver.Value { } func TestBuildVersion3RegionQueries(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -1643,8 +1611,6 @@ func TestBuildVersion3RegionQueries(t *testing.T) { } func TestCheckTiDBWithTiKV(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -1692,8 +1658,6 @@ func TestCheckTiDBWithTiKV(t *testing.T) { } func TestPickupPossibleField(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -1839,8 +1803,6 @@ func TestPickupPossibleField(t *testing.T) { } func TestCheckIfSeqExists(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -1868,8 +1830,6 @@ func TestCheckIfSeqExists(t *testing.T) { } func TestGetCharsetAndDefaultCollation(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -1891,8 +1851,6 @@ func TestGetCharsetAndDefaultCollation(t *testing.T) { } func TestGetSpecifiedColumnValueAndClose(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { @@ -1923,8 +1881,6 @@ func TestGetSpecifiedColumnValueAndClose(t *testing.T) { } func TestGetSpecifiedColumnValuesAndClose(t *testing.T) { - t.Parallel() - db, mock, err := sqlmock.New() require.NoError(t, err) defer func() { diff --git a/dumpling/export/sql_type_test.go b/dumpling/export/sql_type_test.go index 97ae6d058123f..1ed75a3247472 100644 --- a/dumpling/export/sql_type_test.go +++ b/dumpling/export/sql_type_test.go @@ -10,8 +10,6 @@ import ( ) func TestEscape(t *testing.T) { - t.Parallel() - var bf bytes.Buffer str := []byte(`MWQeWw""'\rNmtGxzGp`) expectStrBackslash := `MWQeWw\"\"\'\\rNmtGxzGp` diff --git a/dumpling/export/status_test.go b/dumpling/export/status_test.go index 095dd11f99dd2..7c340b06dcf83 100644 --- a/dumpling/export/status_test.go +++ b/dumpling/export/status_test.go @@ -11,8 +11,6 @@ import ( ) func TestGetParameters(t *testing.T) { - t.Parallel() - conf := defaultConfigForTest(t) d := &Dumper{conf: conf, speedRecorder: NewSpeedRecorder()} d.metrics = newMetrics(conf.PromFactory, nil) @@ -36,8 +34,6 @@ func TestGetParameters(t *testing.T) { } func TestSpeedRecorder(t *testing.T) { - t.Parallel() - testCases := []struct { spentTime int64 finished float64 diff --git a/dumpling/export/util_test.go b/dumpling/export/util_test.go index c32d7f71b9fd9..35de448432cd0 100644 --- a/dumpling/export/util_test.go +++ b/dumpling/export/util_test.go @@ -11,8 +11,6 @@ import ( ) func TestRepeatableRead(t *testing.T) { - t.Parallel() - data := [][]interface{}{ {version.ServerTypeUnknown, ConsistencyTypeNone, true}, {version.ServerTypeMySQL, ConsistencyTypeFlush, true}, @@ -33,8 +31,6 @@ func TestRepeatableRead(t *testing.T) { } func TestInfiniteChan(t *testing.T) { - t.Parallel() - in, out := infiniteChan[int]() go func() { for i := 0; i < 10000; i++ { diff --git a/dumpling/export/writer_serial_test.go b/dumpling/export/writer_serial_test.go index 7052bb6a4b5ee..2290ca86cdfa2 100644 --- a/dumpling/export/writer_serial_test.go +++ b/dumpling/export/writer_serial_test.go @@ -16,8 +16,6 @@ import ( ) func TestWriteMeta(t *testing.T) { - t.Parallel() - createTableStmt := "CREATE TABLE `t1` (\n" + " `a` int(11) DEFAULT NULL\n" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;\n" @@ -36,8 +34,6 @@ func TestWriteMeta(t *testing.T) { } func TestWriteInsert(t *testing.T) { - t.Parallel() - cfg := createMockConfig() data := [][]driver.Value{ @@ -73,8 +69,6 @@ func TestWriteInsert(t *testing.T) { } func TestWriteInsertReturnsError(t *testing.T) { - t.Parallel() - cfg := createMockConfig() data := [][]driver.Value{ @@ -113,8 +107,6 @@ func TestWriteInsertReturnsError(t *testing.T) { } func TestWriteInsertInCsv(t *testing.T) { - t.Parallel() - cfg := createMockConfig() data := [][]driver.Value{ @@ -202,8 +194,6 @@ func TestWriteInsertInCsv(t *testing.T) { } func TestWriteInsertInCsvReturnsError(t *testing.T) { - t.Parallel() - cfg := createMockConfig() data := [][]driver.Value{ @@ -237,8 +227,6 @@ func TestWriteInsertInCsvReturnsError(t *testing.T) { } func TestSQLDataTypes(t *testing.T) { - t.Parallel() - cfg := createMockConfig() data := [][]driver.Value{ @@ -270,8 +258,6 @@ func TestSQLDataTypes(t *testing.T) { } func TestWrite(t *testing.T) { - t.Parallel() - mocksw := &mockPoisonWriter{} src := []string{"test", "loooooooooooooooooooong", "poison"} exp := []string{"test", "loooooooooooooooooooong", "poison_error"} diff --git a/dumpling/export/writer_test.go b/dumpling/export/writer_test.go index ccc20936a8be4..09e43c469e5bf 100644 --- a/dumpling/export/writer_test.go +++ b/dumpling/export/writer_test.go @@ -17,8 +17,6 @@ import ( ) func TestWriteDatabaseMeta(t *testing.T) { - t.Parallel() - dir := t.TempDir() config := defaultConfigForTest(t) config.OutputDirPath = dir @@ -38,8 +36,6 @@ func TestWriteDatabaseMeta(t *testing.T) { } func TestWritePolicyMeta(t *testing.T) { - t.Parallel() - dir := t.TempDir() config := defaultConfigForTest(t) config.OutputDirPath = dir @@ -59,8 +55,6 @@ func TestWritePolicyMeta(t *testing.T) { } func TestWriteTableMeta(t *testing.T) { - t.Parallel() - dir := t.TempDir() config := defaultConfigForTest(t) @@ -79,8 +73,6 @@ func TestWriteTableMeta(t *testing.T) { } func TestWriteViewMeta(t *testing.T) { - t.Parallel() - dir := t.TempDir() config := defaultConfigForTest(t) config.OutputDirPath = dir @@ -109,8 +101,6 @@ func TestWriteViewMeta(t *testing.T) { } func TestWriteTableData(t *testing.T) { - t.Parallel() - dir := t.TempDir() config := defaultConfigForTest(t) config.OutputDirPath = dir @@ -149,8 +139,6 @@ func TestWriteTableData(t *testing.T) { } func TestWriteTableDataWithFileSize(t *testing.T) { - t.Parallel() - dir := t.TempDir() config := defaultConfigForTest(t) config.OutputDirPath = dir @@ -200,8 +188,6 @@ func TestWriteTableDataWithFileSize(t *testing.T) { } func TestWriteTableDataWithFileSizeAndRows(t *testing.T) { - t.Parallel() - dir := t.TempDir() config := defaultConfigForTest(t) config.OutputDirPath = dir @@ -252,8 +238,6 @@ func TestWriteTableDataWithFileSizeAndRows(t *testing.T) { } func TestWriteTableDataWithStatementSize(t *testing.T) { - t.Parallel() - dir := t.TempDir() config := defaultConfigForTest(t) config.OutputDirPath = dir