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

tests: reduce some flaky timeout tests #56171

Merged
merged 4 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pkg/executor/test/cte/cte_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,15 @@ func TestCTEDelSpillFile(t *testing.T) {
tk.MustExec("drop table if exists t1, t2;")
tk.MustExec("create table t1(c1 int, c2 int);")
tk.MustExec("create table t2(c1 int);")
tk.MustExec("set @@cte_max_recursion_depth = 1000000;")
tk.MustExec("set global tidb_mem_oom_action = 'log';")
tk.MustExec("set @@tidb_mem_quota_query = 100;")
tk.MustExec("insert into t2 values(1);")
tk.MustExec("insert into t1 (c1, c2) with recursive cte1 as (select c1 from t2 union select cte1.c1 + 1 from cte1 where cte1.c1 < 100000) select cte1.c1, cte1.c1+1 from cte1;")
tk.MustExec("set @@cte_max_recursion_depth = 100;")
tk.MustExec("set @@tidb_mem_quota_query = 100;")
tk.MustExec("set global tidb_mem_oom_action = 'cancel';")
// Make sure the OOM happens.
tk.MustExecToErr("insert into t1 (c1, c2) with recursive cte1 as (select c1 from t2 union select cte1.c1 + 1 from cte1 where cte1.c1 < 100) select cte1.c1, cte1.c1+1 from cte1;")
tk.MustExec("set global tidb_mem_oom_action = 'log';")
// Test that the storage is cleaned as expected.
tk.MustExec("insert into t1 (c1, c2) with recursive cte1 as (select c1 from t2 union select cte1.c1 + 1 from cte1 where cte1.c1 < 100) select cte1.c1, cte1.c1+1 from cte1;")
require.Nil(t, tk.Session().GetSessionVars().StmtCtx.CTEStorageMap)
}

Expand Down
8 changes: 7 additions & 1 deletion pkg/infoschema/test/clustertablestest/cluster_tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,8 @@ func TestMDLView(t *testing.T) {
}
}

func TestMDLViewPrivilege(t *testing.T) {
func TestMDLViewWithNoPrivilege(t *testing.T) {
// It's with TestMDLViewWithPrivilege. Split to two tests just because it runs too much time.
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil, nil))
Expand All @@ -920,9 +921,14 @@ func TestMDLViewPrivilege(t *testing.T) {
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "test", Hostname: "%"}, nil, nil, nil))
_, err := tk.Exec("select * from mysql.tidb_mdl_view;")
require.ErrorContains(t, err, "view lack rights")
}

func TestMDLViewWithPrivilege(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
// grant all privileges to test user.
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil, nil))
tk.MustExec("create user 'test'@'%' identified by '';")
tk.MustExec("grant all privileges on *.* to 'test'@'%';")
tk.MustExec("flush privileges;")
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "test", Hostname: "%"}, nil, nil, nil))
Expand Down
14 changes: 13 additions & 1 deletion pkg/planner/core/memtable_infoschema_extractor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,12 @@ func TestMemtableInfoschemaExtractorPart1(t *testing.T) {
prepareData: prepareDataViews,
cleanData: cleanDataViews,
},
}
testMemtableInfoschemaExtractor(t, tcs)
}

func TestMemtableInfoschemaExtractorPart2(t *testing.T) {
tcs := []testCase{
{
memTableName: infoschema.TableKeyColumn,
prepareData: prepareDataKeyColumnUsage,
Expand All @@ -409,7 +415,7 @@ func TestMemtableInfoschemaExtractorPart1(t *testing.T) {
testMemtableInfoschemaExtractor(t, tcs)
}

func TestMemtableInfoschemaExtractorPart2(t *testing.T) {
func TestMemtableInfoschemaExtractorPart3(t *testing.T) {
tcs := []testCase{
{
memTableName: infoschema.TableStatistics,
Expand All @@ -426,6 +432,12 @@ func TestMemtableInfoschemaExtractorPart2(t *testing.T) {
prepareData: prepareDataCheckConstraints,
cleanData: cleanDataCheckConstraints,
},
}
testMemtableInfoschemaExtractor(t, tcs)
}

func TestMemtableInfoschemaExtractorPart4(t *testing.T) {
tcs := []testCase{
{
memTableName: infoschema.TableTiDBCheckConstraints,
prepareData: prepareDataTidbCheckConstraints,
Expand Down
2 changes: 1 addition & 1 deletion pkg/planner/core/plan_cost_ver1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func TestScanOnSmallTable(t *testing.T) {
tk.MustExec("use test")
tk.MustExec(`create table t (a int)`)
tk.MustExec("insert into t values (1), (2), (3), (4), (5)")
tk.MustExec("analyze table t")
tk.MustExec("analyze table t all columns")
tk.MustExec(`set @@tidb_cost_model_version=2`)

// Create virtual tiflash replica info.
Expand Down
3 changes: 1 addition & 2 deletions pkg/server/handler/tests/http_handler_serial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,10 @@ func TestDebugRoutes(t *testing.T) {
"/debug/pprof/block?debug=1",
"/debug/pprof/threadcreate?debug=1",
"/debug/pprof/cmdline",
"/debug/pprof/profile",
"/debug/pprof/profile?seconds=5",
"/debug/pprof/mutex?debug=1",
"/debug/pprof/symbol",
"/debug/pprof/trace",
"/debug/pprof/profile",
"/debug/gogc",
// "/debug/zip", // this creates unexpected goroutines which will make goleak complain, so we skip it for now
"/debug/ballast-object-sz",
Expand Down