Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

casetest: split test for improving ci #45246

Merged
merged 13 commits into from
Jul 10, 2023
22 changes: 0 additions & 22 deletions planner/core/casetest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,14 @@ go_test(
name = "casetest_test",
timeout = "moderate",
srcs = [
"binary_plan_test.go",
"enforce_mpp_test.go",
"expression_rewriter_test.go",
"flat_plan_test.go",
"integration_partition_test.go",
"integration_test.go",
"main_test.go",
"partition_pruner_test.go",
"plan_test.go",
"point_get_plan_test.go",
"predicate_simplification_test.go",
"rule_derive_topn_from_window_test.go",
"rule_inject_extra_projection_test.go",
"rule_join_reorder_test.go",
"rule_result_reorder_test.go",
"stats_test.go",
"tiflash_selection_late_materialization_test.go",
"window_push_down_test.go",
Expand All @@ -28,18 +21,10 @@ go_test(
race = "on",
shard_count = 50,
deps = [
"//config",
"//domain",
"//expression",
"//expression/aggregation",
"//infoschema",
"//kv",
"//parser",
"//parser/ast",
"//parser/model",
"//parser/mysql",
"//parser/terror",
"//planner",
"//planner/core",
"//planner/core/internal",
"//planner/property",
Expand All @@ -48,20 +33,13 @@ go_test(
"//sessionctx/variable",
"//statistics/handle",
"//testkit",
"//testkit/external",
"//testkit/testdata",
"//testkit/testmain",
"//testkit/testsetup",
"//types",
"//util",
"//util/collate",
"//util/hint",
"//util/logutil",
"//util/mock",
"//util/plancodec",
"@com_github_golang_snappy//:snappy",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_pingcap_tipb//go-tipb",
"@com_github_stretchr_testify//require",
"@org_uber_go_goleak//:goleak",
],
Expand Down
24 changes: 24 additions & 0 deletions planner/core/casetest/binaryplan/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
load("@io_bazel_rules_go//go:def.bzl", "go_test")

go_test(
name = "binaryplan_test",
timeout = "short",
srcs = [
"binary_plan_test.go",
"main_test.go",
],
data = glob(["testdata/**"]),
flaky = True,
deps = [
"//config",
"//testkit",
"//testkit/testdata",
"//testkit/testmain",
"//testkit/testsetup",
"//util/logutil",
"@com_github_golang_snappy//:snappy",
"@com_github_pingcap_tipb//go-tipb",
"@com_github_stretchr_testify//require",
"@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 casetest
package binaryplan

import (
"encoding/base64"
Expand Down
53 changes: 53 additions & 0 deletions planner/core/casetest/binaryplan/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 binaryplan

import (
"flag"
"testing"

"github.com/pingcap/tidb/testkit/testdata"
"github.com/pingcap/tidb/testkit/testmain"
"github.com/pingcap/tidb/testkit/testsetup"
"go.uber.org/goleak"
)

var testDataMap = make(testdata.BookKeeper)

func TestMain(m *testing.M) {
testsetup.SetupForCommonTest()
flag.Parse()
testDataMap.LoadTestSuiteData("testdata", "binary_plan_suite")

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.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
}

callback := func(i int) int {
testDataMap.GenerateOutputIfNeeded()
return i
}

goleak.VerifyTestMain(testmain.WrapTestingM(m, callback), opts...)
}

func GetBinaryPlanSuiteData() testdata.TestData {
return testDataMap["binary_plan_suite"]
}
27 changes: 27 additions & 0 deletions planner/core/casetest/enforcempp/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
load("@io_bazel_rules_go//go:def.bzl", "go_test")

go_test(
name = "enforcempp_test",
timeout = "short",
srcs = [
"enforce_mpp_test.go",
"main_test.go",
],
data = glob(["testdata/**"]),
flaky = True,
shard_count = 12,
deps = [
"//domain",
"//parser/model",
"//planner/core/internal",
"//sessionctx/stmtctx",
"//testkit",
"//testkit/external",
"//testkit/testdata",
"//testkit/testmain",
"//testkit/testsetup",
"//util/collate",
"@com_github_stretchr_testify//require",
"@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 casetest
package enforcempp

import (
"strings"
Expand Down
53 changes: 53 additions & 0 deletions planner/core/casetest/enforcempp/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 enforcempp

import (
"flag"
"testing"

"github.com/pingcap/tidb/testkit/testdata"
"github.com/pingcap/tidb/testkit/testmain"
"github.com/pingcap/tidb/testkit/testsetup"
"go.uber.org/goleak"
)

var testDataMap = make(testdata.BookKeeper)

func TestMain(m *testing.M) {
testsetup.SetupForCommonTest()
flag.Parse()
testDataMap.LoadTestSuiteData("testdata", "enforce_mpp_suite")

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.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
}

callback := func(i int) int {
testDataMap.GenerateOutputIfNeeded()
return i
}

goleak.VerifyTestMain(testmain.WrapTestingM(m, callback), opts...)
}

func GetEnforceMPPSuiteData() testdata.TestData {
return testDataMap["enforce_mpp_suite"]
}
26 changes: 26 additions & 0 deletions planner/core/casetest/flatplan/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
load("@io_bazel_rules_go//go:def.bzl", "go_test")

go_test(
name = "flatplan_test",
timeout = "short",
srcs = [
"flat_plan_test.go",
"main_test.go",
],
data = glob(["testdata/**"]),
flaky = True,
deps = [
"//infoschema",
"//kv",
"//parser",
"//parser/model",
"//planner",
"//planner/core",
"//testkit",
"//testkit/testdata",
"//testkit/testmain",
"//testkit/testsetup",
"@com_github_stretchr_testify//require",
"@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 casetest
package flatplan

import (
"context"
Expand Down
54 changes: 54 additions & 0 deletions planner/core/casetest/flatplan/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// 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 flatplan

import (
"flag"
"testing"

"github.com/pingcap/tidb/testkit/testdata"
"github.com/pingcap/tidb/testkit/testmain"
"github.com/pingcap/tidb/testkit/testsetup"
"go.uber.org/goleak"
)

var testDataMap = make(testdata.BookKeeper)

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

flag.Parse()
testDataMap.LoadTestSuiteData("testdata", "flat_plan_suite")

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.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
}

callback := func(i int) int {
testDataMap.GenerateOutputIfNeeded()
return i
}

goleak.VerifyTestMain(testmain.WrapTestingM(m, callback), opts...)
}

func GetFlatPlanSuiteData() testdata.TestData {
return testDataMap["flat_plan_suite"]
}
Loading