|
| 1 | +// Copyright 2023 PingCAP, Inc. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package constantpropagation |
| 16 | + |
| 17 | +import ( |
| 18 | + "testing" |
| 19 | + |
| 20 | + "github.com/pingcap/tidb/pkg/config" |
| 21 | + "github.com/pingcap/tidb/pkg/testkit/testmain" |
| 22 | + "github.com/pingcap/tidb/pkg/testkit/testsetup" |
| 23 | + "github.com/pingcap/tidb/pkg/util/timeutil" |
| 24 | + "github.com/tikv/client-go/v2/tikv" |
| 25 | + "go.uber.org/goleak" |
| 26 | +) |
| 27 | + |
| 28 | +func TestMain(m *testing.M) { |
| 29 | + testsetup.SetupForCommonTest() |
| 30 | + testmain.ShortCircuitForBench(m) |
| 31 | + |
| 32 | + config.UpdateGlobal(func(conf *config.Config) { |
| 33 | + conf.TiKVClient.AsyncCommit.SafeWindow = 0 |
| 34 | + conf.TiKVClient.AsyncCommit.AllowedClockDrift = 0 |
| 35 | + conf.Experimental.AllowsExpressionIndex = true |
| 36 | + }) |
| 37 | + tikv.EnableFailpoints() |
| 38 | + |
| 39 | + // Some test depends on the values of timeutil.SystemLocation() |
| 40 | + // If we don't SetSystemTZ() here, the value would change unpredictable. |
| 41 | + // Affected by the order whether a testsuite runs before or after integration test. |
| 42 | + // Note, SetSystemTZ() is a sync.Once operation. |
| 43 | + timeutil.SetSystemTZ("system") |
| 44 | + |
| 45 | + opts := []goleak.Option{ |
| 46 | + goleak.IgnoreTopFunction("github.com/golang/glog.(*fileSink).flushDaemon"), |
| 47 | + goleak.IgnoreTopFunction("github.com/bazelbuild/rules_go/go/tools/bzltestutil.RegisterTimeoutHandler.func1"), |
| 48 | + goleak.IgnoreTopFunction("github.com/lestrrat-go/httprc.runFetchWorker"), |
| 49 | + goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"), |
| 50 | + goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"), |
| 51 | + goleak.IgnoreTopFunction("github.com/pingcap/tidb/pkg/ttl/ttlworker.(*ttlScanWorker).loop"), |
| 52 | + goleak.IgnoreTopFunction("github.com/pingcap/tidb/pkg/ttl/client.(*mockClient).WatchCommand.func1"), |
| 53 | + goleak.IgnoreTopFunction("github.com/pingcap/tidb/pkg/ttl/ttlworker.(*JobManager).jobLoop"), |
| 54 | + } |
| 55 | + |
| 56 | + goleak.VerifyTestMain(m, opts...) |
| 57 | +} |
0 commit comments