From e0917a0ffd2ff9ded950308448ceb8c1f4f0fee6 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Wed, 1 Dec 2021 11:23:34 +0800 Subject: [PATCH 1/3] ddltest: remove logutil.InitLogger to avoid data race Signed-off-by: Weizhen Wang --- cmd/ddltest/ddl_serial_test.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cmd/ddltest/ddl_serial_test.go b/cmd/ddltest/ddl_serial_test.go index d5dcda20a7529..a92ef55447d53 100644 --- a/cmd/ddltest/ddl_serial_test.go +++ b/cmd/ddltest/ddl_serial_test.go @@ -33,7 +33,6 @@ import ( _ "github.com/go-sql-driver/mysql" "github.com/pingcap/errors" "github.com/pingcap/log" - zaplog "github.com/pingcap/log" "github.com/pingcap/tidb/ddl" "github.com/pingcap/tidb/domain" "github.com/pingcap/tidb/kv" @@ -48,7 +47,6 @@ import ( "github.com/pingcap/tidb/table/tables" "github.com/pingcap/tidb/testkit" "github.com/pingcap/tidb/types" - "github.com/pingcap/tidb/util/logutil" "github.com/stretchr/testify/require" "go.uber.org/zap" goctx "golang.org/x/net/context" @@ -91,11 +89,9 @@ type ddlSuite struct { } func createDDLSuite(t *testing.T) (s *ddlSuite) { + var err error s = new(ddlSuite) - err := logutil.InitLogger(&logutil.LogConfig{Config: zaplog.Config{Level: *logLevel}}) - require.NoError(t, err) - s.quit = make(chan struct{}) s.store, err = store.New(fmt.Sprintf("tikv://%s%s", *etcd, *tikvPath)) From 437a3b09de85126da325f1b75da58f48330a527d Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Wed, 1 Dec 2021 11:33:15 +0800 Subject: [PATCH 2/3] ddl: migrate test-infra to testify for ddl/table_test.go Signed-off-by: Weizhen Wang --- cmd/ddltest/main_test.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 cmd/ddltest/main_test.go diff --git a/cmd/ddltest/main_test.go b/cmd/ddltest/main_test.go new file mode 100644 index 0000000000000..25e66ee8329d6 --- /dev/null +++ b/cmd/ddltest/main_test.go @@ -0,0 +1,37 @@ +// Copyright 2021 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ddltest + +import ( + "fmt" + "os" + "testing" + + zaplog "github.com/pingcap/log" + "github.com/pingcap/tidb/util/logutil" + "github.com/pingcap/tidb/util/testbridge" + "go.uber.org/goleak" +) + + +func TestMain(m *testing.M) { + testbridge.WorkaroundGoCheckFlags() + err := logutil.InitLogger(&logutil.LogConfig{Config: zaplog.Config{Level: *logLevel}}) + if err != nil { + fmt.Fprint(os.Stderr, err.Error()) + os.Exit(1) + } + goleak.VerifyTestMain(m) +} From f88e6ce125c00f7e9f9b9f98c62c3c424ee4fee4 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Wed, 1 Dec 2021 11:41:36 +0800 Subject: [PATCH 3/3] ddl: migrate test-infra to testify for ddl/table_test.go Signed-off-by: Weizhen Wang --- cmd/ddltest/main_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/ddltest/main_test.go b/cmd/ddltest/main_test.go index 25e66ee8329d6..60acefcf2eaff 100644 --- a/cmd/ddltest/main_test.go +++ b/cmd/ddltest/main_test.go @@ -25,7 +25,6 @@ import ( "go.uber.org/goleak" ) - func TestMain(m *testing.M) { testbridge.WorkaroundGoCheckFlags() err := logutil.InitLogger(&logutil.LogConfig{Config: zaplog.Config{Level: *logLevel}})