From e3b95fbc76e6d93d80422732d2736d1510fdff35 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sat, 5 Aug 2023 22:53:40 +0800 Subject: [PATCH] executor: split ddl test into new package (#45834) close pingcap/tidb#44940 --- executor/BUILD.bazel | 6 ---- executor/test/ddl/BUILD.bazel | 44 +++++++++++++++++++++++++++++ executor/{ => test/ddl}/ddl_test.go | 2 +- executor/test/ddl/main_test.go | 44 +++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 7 deletions(-) create mode 100644 executor/test/ddl/BUILD.bazel rename executor/{ => test/ddl}/ddl_test.go (99%) create mode 100644 executor/test/ddl/main_test.go diff --git a/executor/BUILD.bazel b/executor/BUILD.bazel index 1e79baac45..83f6a577be 100644 --- a/executor/BUILD.bazel +++ b/executor/BUILD.bazel @@ -297,7 +297,6 @@ go_test( "concurrent_map_test.go", "copr_cache_test.go", "cte_test.go", - "ddl_test.go", "delete_test.go", "distsql_test.go", "executor_failpoint_test.go", @@ -372,8 +371,6 @@ go_test( "//config", "//ddl", "//ddl/placement", - "//ddl/schematracker", - "//ddl/testutil", "//ddl/util", "//distsql", "//domain", @@ -387,7 +384,6 @@ go_test( "//expression/aggregation", "//infoschema", "//kv", - "//meta", "//meta/autoid", "//metrics", "//parser", @@ -406,7 +402,6 @@ go_test( "//sessionctx/binloginfo", "//sessionctx/stmtctx", "//sessionctx/variable", - "//sessionctx/variable/featuretag/disttask", "//sessiontxn", "//sessiontxn/staleread", "//statistics", @@ -424,7 +419,6 @@ go_test( "//testkit/testdata", "//testkit/testmain", "//testkit/testsetup", - "//testkit/testutil", "//types", "//util", "//util/benchdaily", diff --git a/executor/test/ddl/BUILD.bazel b/executor/test/ddl/BUILD.bazel new file mode 100644 index 0000000000..9ecaaa0b63 --- /dev/null +++ b/executor/test/ddl/BUILD.bazel @@ -0,0 +1,44 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_test") + +go_test( + name = "ddl_test", + timeout = "short", + srcs = [ + "ddl_test.go", + "main_test.go", + ], + flaky = True, + shard_count = 42, + deps = [ + "//config", + "//ddl/schematracker", + "//ddl/testutil", + "//ddl/util", + "//domain", + "//errno", + "//infoschema", + "//kv", + "//meta", + "//meta/autoid", + "//parser/model", + "//parser/mysql", + "//parser/terror", + "//planner/core", + "//sessionctx/variable", + "//sessionctx/variable/featuretag/disttask", + "//sessiontxn", + "//store/mockstore", + "//table", + "//table/tables", + "//testkit", + "//testkit/testutil", + "//types", + "//util/chunk", + "//util/dbterror", + "//util/dbterror/exeerrors", + "@com_github_pingcap_failpoint//:failpoint", + "@com_github_stretchr_testify//require", + "@com_github_tikv_client_go_v2//tikv", + "@org_uber_go_goleak//:goleak", + ], +) diff --git a/executor/ddl_test.go b/executor/test/ddl/ddl_test.go similarity index 99% rename from executor/ddl_test.go rename to executor/test/ddl/ddl_test.go index 53fe11c2ea..e0244ee576 100644 --- a/executor/ddl_test.go +++ b/executor/test/ddl/ddl_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package executor_test +package ddl import ( "context" diff --git a/executor/test/ddl/main_test.go b/executor/test/ddl/main_test.go new file mode 100644 index 0000000000..454579cc72 --- /dev/null +++ b/executor/test/ddl/main_test.go @@ -0,0 +1,44 @@ +// Copyright 2023 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 ddl + +import ( + "testing" + + "github.com/pingcap/tidb/config" + "github.com/pingcap/tidb/meta/autoid" + "github.com/tikv/client-go/v2/tikv" + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + autoid.SetStep(5000) + config.UpdateGlobal(func(conf *config.Config) { + conf.Log.SlowThreshold = 30000 // 30s + conf.TiKVClient.AsyncCommit.SafeWindow = 0 + conf.TiKVClient.AsyncCommit.AllowedClockDrift = 0 + conf.Experimental.AllowsExpressionIndex = true + }) + tikv.EnableFailpoints() + + opts := []goleak.Option{ + goleak.IgnoreTopFunction("github.com/golang/glog.(*fileSink).flushDaemon"), + goleak.IgnoreTopFunction("github.com/lestrrat-go/httprc.runFetchWorker"), + goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"), + goleak.IgnoreTopFunction("gopkg.in/natefinch/lumberjack%2ev2.(*Logger).millRun"), + goleak.IgnoreTopFunction("github.com/tikv/client-go/v2/txnkv/transaction.keepAlive"), + } + goleak.VerifyTestMain(m, opts...) +}