Skip to content

Commit

Permalink
*: update bazel (#41369)
Browse files Browse the repository at this point in the history
ref #41377
  • Loading branch information
hawkingrei committed Feb 14, 2023
1 parent 71ed267 commit 84871df
Show file tree
Hide file tree
Showing 17 changed files with 1,286 additions and 1,024 deletions.
4 changes: 2 additions & 2 deletions executor/aggfuncs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ go_library(

go_test(
name = "aggfuncs_test",
timeout = "moderate",
timeout = "short",
srcs = [
"aggfunc_test.go",
"export_test.go",
Expand Down Expand Up @@ -89,7 +89,7 @@ go_test(
embed = [":aggfuncs"],
flaky = True,
race = "on",
shard_count = 40,
shard_count = 50,
deps = [
"//expression",
"//expression/aggregation",
Expand Down
3 changes: 2 additions & 1 deletion executor/oomtest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ load("@io_bazel_rules_go//go:def.bzl", "go_test")

go_test(
name = "oomtest_test",
timeout = "moderate",
timeout = "short",
srcs = ["oom_test.go"],
flaky = True,
race = "on",
shard_count = 2,
deps = [
"//testkit",
"//testkit/testsetup",
Expand Down
6 changes: 0 additions & 6 deletions expression/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ go_test(
"function_traits_test.go",
"helper_test.go",
"integration_serial_test.go",
"integration_test.go",
"main_test.go",
"multi_valued_index_test.go",
"scalar_function_test.go",
Expand All @@ -190,7 +189,6 @@ go_test(
shard_count = 50,
deps = [
"//config",
"//domain",
"//errno",
"//kv",
"//parser",
Expand Down Expand Up @@ -224,16 +222,12 @@ go_test(
"//util/mathutil",
"//util/mock",
"//util/printer",
"//util/sem",
"//util/sqlexec",
"//util/timeutil",
"//util/versioninfo",
"@com_github_gogo_protobuf//proto",
"@com_github_google_uuid//:uuid",
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_pingcap_tipb//go-tipb",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
"@com_github_tikv_client_go_v2//oracle",
"@com_github_tikv_client_go_v2//tikv",
Expand Down
43 changes: 43 additions & 0 deletions expression/integration_test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
load("@io_bazel_rules_go//go:def.bzl", "go_test")

go_test(
name = "integration_test_test",
timeout = "short",
srcs = [
"integration_test.go",
"main_test.go",
],
flaky = True,
shard_count = 50,
deps = [
"//config",
"//domain",
"//errno",
"//expression",
"//kv",
"//parser/auth",
"//parser/model",
"//parser/mysql",
"//parser/terror",
"//planner/core",
"//session",
"//sessionctx/variable",
"//table",
"//tablecodec",
"//testkit",
"//testkit/testmain",
"//testkit/testsetup",
"//types",
"//util/codec",
"//util/collate",
"//util/sem",
"//util/sqlexec",
"//util/timeutil",
"//util/versioninfo",
"@com_github_pingcap_errors//:errors",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
"@com_github_tikv_client_go_v2//tikv",
"@org_uber_go_goleak//:goleak",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package expression_test
package integration_test

import (
"bytes"
Expand Down
53 changes: 53 additions & 0 deletions expression/integration_test/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// 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 integration_test

import (
"testing"

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

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

config.UpdateGlobal(func(conf *config.Config) {
conf.TiKVClient.AsyncCommit.SafeWindow = 0
conf.TiKVClient.AsyncCommit.AllowedClockDrift = 0
conf.Experimental.AllowsExpressionIndex = true
})
tikv.EnableFailpoints()

// Some test depends on the values of timeutil.SystemLocation()
// If we don't SetSystemTZ() here, the value would change unpredictable.
// Affected by the order whether a testsuite runs before or after integration test.
// Note, SetSystemTZ() is a sync.Once operation.
timeutil.SetSystemTZ("system")

opts := []goleak.Option{
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
goleak.IgnoreTopFunction("github.com/lestrrat-go/httprc.runFetchWorker"),
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"),
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
}

goleak.VerifyTestMain(m, opts...)
}
4 changes: 1 addition & 3 deletions session/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,14 @@ go_library(

go_test(
name = "session_test",
timeout = "moderate",
timeout = "short",
srcs = [
"bench_test.go",
"bootstrap_test.go",
"bootstrap_upgrade_test.go",
"clustered_index_test.go",
"index_usage_sync_lease_test.go",
"main_test.go",
"nontransactional_test.go",
"schema_test.go",
"session_test.go",
"tidb_test.go",
Expand Down Expand Up @@ -168,7 +167,6 @@ go_test(
"@com_github_stretchr_testify//require",
"@com_github_tikv_client_go_v2//testutils",
"@com_github_tikv_client_go_v2//tikv",
"@com_github_tikv_client_go_v2//util",
"@org_uber_go_atomic//:atomic",
"@org_uber_go_goleak//:goleak",
"@org_uber_go_zap//:zap",
Expand Down
23 changes: 23 additions & 0 deletions session/nontransactionaltest/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
load("@io_bazel_rules_go//go:def.bzl", "go_test")

go_test(
name = "nontransactionaltest_test",
timeout = "short",
srcs = [
"main_test.go",
"nontransactional_test.go",
],
flaky = True,
shard_count = 20,
deps = [
"//config",
"//testkit",
"//testkit/testmain",
"//testkit/testsetup",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_stretchr_testify//require",
"@com_github_tikv_client_go_v2//tikv",
"@com_github_tikv_client_go_v2//util",
"@org_uber_go_goleak//:goleak",
],
)
61 changes: 61 additions & 0 deletions session/nontransactionaltest/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 nontransactionaltest

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.(*loggingT).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...)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package session_test
package nontransactionaltest

import (
"fmt"
Expand Down

0 comments on commit 84871df

Please sign in to comment.