Skip to content

Commit 9bcae5e

Browse files
authored
*: replace failpoint.Enable with testfailpoint.Enable (#63295)
1 parent 8d5fd73 commit 9bcae5e

19 files changed

+38
-47
lines changed

pkg/executor/partition_table_test.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/pingcap/tidb/pkg/parser/ast"
3030
"github.com/pingcap/tidb/pkg/testkit"
3131
"github.com/pingcap/tidb/pkg/testkit/external"
32+
"github.com/pingcap/tidb/pkg/testkit/testfailpoint"
3233
"github.com/pingcap/tidb/pkg/util/dbterror/exeerrors"
3334
"github.com/stretchr/testify/require"
3435
)
@@ -752,8 +753,7 @@ func TestView(t *testing.T) {
752753
}
753754

754755
func TestDirectReadingwithIndexJoin(t *testing.T) {
755-
failpoint.Enable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
756-
defer failpoint.Disable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune")
756+
testfailpoint.Enable(t, "github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
757757
store := testkit.CreateMockStore(t)
758758

759759
tk := testkit.NewTestKit(t, store)
@@ -866,8 +866,7 @@ func TestDirectReadingwithIndexJoin(t *testing.T) {
866866
}
867867

868868
func TestDynamicPruningUnderIndexJoin(t *testing.T) {
869-
failpoint.Enable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
870-
defer failpoint.Disable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune")
869+
testfailpoint.Enable(t, "github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
871870
store := testkit.CreateMockStore(t)
872871

873872
tk := testkit.NewTestKit(t, store)
@@ -1028,8 +1027,7 @@ func TestBatchGetforRangeandListPartitionTable(t *testing.T) {
10281027
}
10291028

10301029
func TestPartitionTableWithDifferentJoin(t *testing.T) {
1031-
failpoint.Enable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
1032-
defer failpoint.Disable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune")
1030+
testfailpoint.Enable(t, "github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
10331031
store := testkit.CreateMockStore(t)
10341032

10351033
tk := testkit.NewTestKit(t, store)
@@ -1263,8 +1261,7 @@ func TestPartitionTableWithDifferentJoin(t *testing.T) {
12631261
}
12641262

12651263
func TestMPPQueryExplainInfo(t *testing.T) {
1266-
failpoint.Enable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
1267-
defer failpoint.Disable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune")
1264+
testfailpoint.Enable(t, "github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
12681265
store := testkit.CreateMockStore(t)
12691266

12701267
tk := testkit.NewTestKit(t, store)
@@ -1469,8 +1466,7 @@ func TestSubqueries(t *testing.T) {
14691466
}
14701467

14711468
func TestSplitRegion(t *testing.T) {
1472-
failpoint.Enable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
1473-
defer failpoint.Disable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune")
1469+
testfailpoint.Enable(t, "github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
14741470
store := testkit.CreateMockStore(t)
14751471

14761472
tk := testkit.NewTestKit(t, store)
@@ -1507,8 +1503,7 @@ func TestSplitRegion(t *testing.T) {
15071503
}
15081504

15091505
func TestParallelApply(t *testing.T) {
1510-
failpoint.Enable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
1511-
defer failpoint.Disable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune")
1506+
testfailpoint.Enable(t, "github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
15121507

15131508
store := testkit.CreateMockStore(t)
15141509

pkg/executor/test/analyzetest/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ go_test(
3030
"//pkg/statistics/handle/ddl/testutil",
3131
"//pkg/testkit",
3232
"//pkg/testkit/analyzehelper",
33+
"//pkg/testkit/testfailpoint",
3334
"//pkg/util/dbterror/exeerrors",
3435
"@com_github_pingcap_errors//:errors",
3536
"@com_github_pingcap_failpoint//:failpoint",

pkg/executor/test/analyzetest/analyze_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
statstestutil "github.com/pingcap/tidb/pkg/statistics/handle/ddl/testutil"
4444
"github.com/pingcap/tidb/pkg/testkit"
4545
"github.com/pingcap/tidb/pkg/testkit/analyzehelper"
46+
"github.com/pingcap/tidb/pkg/testkit/testfailpoint"
4647
"github.com/pingcap/tidb/pkg/util/dbterror/exeerrors"
4748
"github.com/stretchr/testify/require"
4849
)
@@ -646,8 +647,7 @@ func TestAnalyzeSamplingWorkPanic(t *testing.T) {
646647
}
647648

648649
func TestSmallTableAnalyzeV2(t *testing.T) {
649-
failpoint.Enable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
650-
defer failpoint.Disable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune")
650+
testfailpoint.Enable(t, "github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
651651
store := testkit.CreateMockStore(t)
652652

653653
tk := testkit.NewTestKit(t, store)
@@ -2482,8 +2482,7 @@ PARTITION BY RANGE ( a ) (
24822482
}
24832483

24842484
func TestAnalyzePartitionStaticToDynamic(t *testing.T) {
2485-
failpoint.Enable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
2486-
defer failpoint.Disable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune")
2485+
testfailpoint.Enable(t, "github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
24872486
store, dom := testkit.CreateMockStoreAndDomain(t)
24882487
tk := testkit.NewTestKit(t, store)
24892488
originalVal := tk.MustQuery("select @@tidb_persist_analyze_options").Rows()[0][0].(string)

pkg/executor/test/tiflashtest/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ go_test(
2222
"//pkg/store/mockstore/unistore",
2323
"//pkg/testkit",
2424
"//pkg/testkit/external",
25+
"//pkg/testkit/testfailpoint",
2526
"//pkg/util/dbterror/exeerrors",
2627
"//pkg/util/sqlkiller",
2728
"//pkg/util/tiflashcompute",

pkg/executor/test/tiflashtest/tiflash_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"github.com/pingcap/tidb/pkg/store/mockstore/unistore"
3838
"github.com/pingcap/tidb/pkg/testkit"
3939
"github.com/pingcap/tidb/pkg/testkit/external"
40+
"github.com/pingcap/tidb/pkg/testkit/testfailpoint"
4041
"github.com/pingcap/tidb/pkg/util/dbterror/exeerrors"
4142
"github.com/pingcap/tidb/pkg/util/sqlkiller"
4243
"github.com/pingcap/tidb/pkg/util/tiflashcompute"
@@ -464,8 +465,7 @@ func TestTiFlashPartitionTableReader(t *testing.T) {
464465
}
465466

466467
func TestPartitionTable(t *testing.T) {
467-
failpoint.Enable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
468-
defer failpoint.Disable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune")
468+
testfailpoint.Enable(t, "github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
469469
store := testkit.CreateMockStore(t, withMockTiFlash(2))
470470
tk := testkit.NewTestKit(t, store)
471471
tk.MustExec("use test")

pkg/planner/core/casetest/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ go_test(
3535
"//pkg/testkit/testsetup",
3636
"//pkg/util/hint",
3737
"//pkg/util/plancodec",
38-
"@com_github_pingcap_failpoint//:failpoint",
3938
"@com_github_stretchr_testify//require",
4039
"@org_uber_go_goleak//:goleak",
4140
],

pkg/planner/core/casetest/integration_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ import (
1919
"strings"
2020
"testing"
2121

22-
"github.com/pingcap/failpoint"
2322
"github.com/pingcap/tidb/pkg/domain"
2423
"github.com/pingcap/tidb/pkg/meta/model"
2524
"github.com/pingcap/tidb/pkg/parser/ast"
2625
statstestutil "github.com/pingcap/tidb/pkg/statistics/handle/ddl/testutil"
2726
"github.com/pingcap/tidb/pkg/testkit"
2827
"github.com/pingcap/tidb/pkg/testkit/testdata"
28+
"github.com/pingcap/tidb/pkg/testkit/testfailpoint"
2929
"github.com/stretchr/testify/require"
3030
)
3131

@@ -251,8 +251,7 @@ func TestIssue32632(t *testing.T) {
251251
}
252252

253253
func TestTiFlashPartitionTableScan(t *testing.T) {
254-
failpoint.Enable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
255-
defer failpoint.Disable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune")
254+
testfailpoint.Enable(t, "github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
256255

257256
testkit.RunTestUnderCascadesWithDomain(t, func(t *testing.T, testKit *testkit.TestKit, dom *domain.Domain, cascades, caller string) {
258257
testKit.MustExec("use test")

pkg/planner/core/casetest/partition/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ go_test(
1717
"//pkg/sessionctx/vardef",
1818
"//pkg/testkit",
1919
"//pkg/testkit/testdata",
20+
"//pkg/testkit/testfailpoint",
2021
"//pkg/testkit/testmain",
2122
"//pkg/testkit/testsetup",
2223
"@com_github_pingcap_failpoint//:failpoint",

pkg/planner/core/casetest/partition/integration_partition_test.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ import (
1818
"strings"
1919
"testing"
2020

21-
"github.com/pingcap/failpoint"
2221
"github.com/pingcap/tidb/pkg/testkit"
2322
"github.com/pingcap/tidb/pkg/testkit/testdata"
23+
"github.com/pingcap/tidb/pkg/testkit/testfailpoint"
2424
"github.com/stretchr/testify/require"
2525
)
2626

2727
func TestListPartitionPruning(t *testing.T) {
28-
failpoint.Enable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
29-
defer failpoint.Disable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune")
28+
testfailpoint.Enable(t, "github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
3029

3130
testkit.RunTestUnderCascades(t, func(t *testing.T, testKit *testkit.TestKit, cascades, caller string) {
3231
testKit.MustExec("create database list_partition_pruning")
@@ -72,8 +71,7 @@ func TestListPartitionPruning(t *testing.T) {
7271
}
7372

7473
func TestPartitionTableExplain(t *testing.T) {
75-
failpoint.Enable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
76-
defer failpoint.Disable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune")
74+
testfailpoint.Enable(t, "github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
7775

7876
testkit.RunTestUnderCascades(t, func(t *testing.T, testKit *testkit.TestKit, cascades, caller string) {
7977
testKit.MustExec("use test")
@@ -109,8 +107,7 @@ func TestPartitionTableExplain(t *testing.T) {
109107
}
110108

111109
func TestBatchPointGetTablePartition(t *testing.T) {
112-
failpoint.Enable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
113-
defer failpoint.Disable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune")
110+
testfailpoint.Enable(t, "github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
114111

115112
testkit.RunTestUnderCascades(t, func(t *testing.T, testKit *testkit.TestKit, cascades, caller string) {
116113
testKit.MustExec("use test")
@@ -195,8 +192,7 @@ func TestBatchPointGetTablePartition(t *testing.T) {
195192
}
196193

197194
func TestBatchPointGetPartitionForAccessObject(t *testing.T) {
198-
failpoint.Enable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
199-
defer failpoint.Disable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune")
195+
testfailpoint.Enable(t, "github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
200196

201197
testkit.RunTestUnderCascades(t, func(t *testing.T, testKit *testkit.TestKit, cascades, caller string) {
202198
testKit.MustExec("use test")

pkg/planner/core/casetest/partition/partition_pruner_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ import (
2727
"github.com/pingcap/tidb/pkg/sessionctx/vardef"
2828
"github.com/pingcap/tidb/pkg/testkit"
2929
"github.com/pingcap/tidb/pkg/testkit/testdata"
30+
"github.com/pingcap/tidb/pkg/testkit/testfailpoint"
3031
"github.com/stretchr/testify/require"
3132
)
3233

3334
func TestHashPartitionPruner(t *testing.T) {
34-
failpoint.Enable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
35-
defer failpoint.Disable("github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune")
35+
testfailpoint.Enable(t, "github.com/pingcap/tidb/pkg/planner/core/forceDynamicPrune", `return(true)`)
3636
testkit.RunTestUnderCascades(t, func(t *testing.T, testKit *testkit.TestKit, cascades, caller string) {
3737
testKit.MustExec("create database test_partition")
3838
testKit.MustExec("use test_partition")

0 commit comments

Comments
 (0)