Skip to content

Commit

Permalink
sessiontest: split test for improve ci (#45198)
Browse files Browse the repository at this point in the history
ref #44940
  • Loading branch information
hawkingrei authored Jul 6, 2023
1 parent b540db9 commit c6f5151
Show file tree
Hide file tree
Showing 8 changed files with 1,380 additions and 1,143 deletions.
3 changes: 0 additions & 3 deletions session/sessiontest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ go_test(
deps = [
"//config",
"//domain",
"//errno",
"//expression",
"//kv",
"//parser/ast",
Expand All @@ -22,7 +21,6 @@ go_test(
"//parser/model",
"//parser/mysql",
"//parser/terror",
"//planner/core",
"//privilege/privileges",
"//session",
"//sessionctx",
Expand All @@ -41,7 +39,6 @@ go_test(
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_stretchr_testify//require",
"@com_github_tikv_client_go_v2//tikv",
"@com_github_tikv_client_go_v2//txnkv/transaction",
"@org_uber_go_goleak//:goleak",
],
)
1,140 changes: 0 additions & 1,140 deletions session/sessiontest/session_test.go

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions session/sessiontest/txn/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
load("@io_bazel_rules_go//go:def.bzl", "go_test")

go_test(
name = "txn_test",
timeout = "short",
srcs = [
"main_test.go",
"txn_test.go",
],
flaky = True,
race = "on",
shard_count = 11,
deps = [
"//config",
"//kv",
"//parser/auth",
"//parser/mysql",
"//parser/terror",
"//planner/core",
"//testkit",
"//testkit/testmain",
"//testkit/testsetup",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_stretchr_testify//require",
"@com_github_tikv_client_go_v2//tikv",
"@org_uber_go_goleak//:goleak",
],
)
61 changes: 61 additions & 0 deletions session/sessiontest/txn/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// 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 txn

import (
"flag"
"testing"
"time"

"github.com/pingcap/tidb/config"
"github.com/pingcap/tidb/testkit/testmain"
"github.com/pingcap/tidb/testkit/testsetup"
"github.com/tikv/client-go/v2/tikv"
"go.uber.org/goleak"
)

func TestMain(m *testing.M) {
testmain.ShortCircuitForBench(m)

testsetup.SetupForCommonTest()

flag.Parse()
config.UpdateGlobal(func(conf *config.Config) {
conf.TiKVClient.AsyncCommit.SafeWindow = 0
conf.TiKVClient.AsyncCommit.AllowedClockDrift = 0
})
tikv.EnableFailpoints()
opts := []goleak.Option{
// TODO: figure the reason and shorten this list
goleak.IgnoreTopFunction("github.com/golang/glog.(*fileSink).flushDaemon"),
goleak.IgnoreTopFunction("github.com/lestrrat-go/httprc.runFetchWorker"),
goleak.IgnoreTopFunction("github.com/tikv/client-go/v2/internal/retry.newBackoffFn.func1"),
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/v3.waitRetryBackoff"),
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"),
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
goleak.IgnoreTopFunction("google.golang.org/grpc.(*addrConn).resetTransport"),
goleak.IgnoreTopFunction("google.golang.org/grpc.(*ccBalancerWrapper).watcher"),
goleak.IgnoreTopFunction("google.golang.org/grpc/internal/transport.(*controlBuffer).get"),
goleak.IgnoreTopFunction("google.golang.org/grpc/internal/transport.(*http2Client).keepalive"),
goleak.IgnoreTopFunction("internal/poll.runtime_pollWait"),
goleak.IgnoreTopFunction("net/http.(*persistConn).writeLoop"),
}
callback := func(i int) int {
// wait for MVCCLevelDB to close, MVCCLevelDB will be closed in one second
time.Sleep(time.Second)
return i
}
goleak.VerifyTestMain(testmain.WrapTestingM(m, callback), opts...)
}
Loading

0 comments on commit c6f5151

Please sign in to comment.