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

executor, tests: move some test cases from admin_test.go and foreign_key_test.go to integrationtest #47333

Merged
merged 4 commits into from
Sep 28, 2023
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
3 changes: 1 addition & 2 deletions executor/test/admintest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go_test(
"main_test.go",
],
flaky = True,
shard_count = 26,
shard_count = 21,
deps = [
"//config",
"//domain",
Expand All @@ -17,7 +17,6 @@ go_test(
"//kv",
"//meta/autoid",
"//parser/model",
"//planner/core",
"//session",
"//sessionctx/stmtctx",
"//sessionctx/variable",
Expand Down
116 changes: 0 additions & 116 deletions executor/test/admintest/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/pingcap/tidb/executor"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/parser/model"
"github.com/pingcap/tidb/planner/core"
"github.com/pingcap/tidb/session"
"github.com/pingcap/tidb/sessionctx/stmtctx"
"github.com/pingcap/tidb/sessionctx/variable"
Expand Down Expand Up @@ -93,100 +92,6 @@ func TestAdminCheckIndex(t *testing.T) {
check()
}

func TestAdminCheckIndexInTemporaryMode(t *testing.T) {
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists temporary_admin_test;")
tk.MustExec("create global temporary table temporary_admin_test (c1 int, c2 int, c3 int default 1, primary key (c1), index (c1), unique key(c2)) ON COMMIT DELETE ROWS;")
tk.MustExec("insert temporary_admin_test (c1, c2) values (1, 1), (2, 2), (3, 3);")
err := tk.ExecToErr("admin check table temporary_admin_test;")
require.EqualError(t, err, core.ErrOptOnTemporaryTable.GenWithStackByArgs("admin check table").Error())
err = tk.ExecToErr("admin check index temporary_admin_test c1;")
require.EqualError(t, err, core.ErrOptOnTemporaryTable.GenWithStackByArgs("admin check index").Error())
tk.MustExec("drop table if exists temporary_admin_test;")

tk.MustExec("drop table if exists non_temporary_admin_test;")
tk.MustExec("create table non_temporary_admin_test (c1 int, c2 int, c3 int default 1, primary key (c1), index (c1), unique key(c2));")
tk.MustExec("insert non_temporary_admin_test (c1, c2) values (1, 1), (2, 2), (3, 3);")
tk.MustExec("admin check table non_temporary_admin_test;")
tk.MustExec("drop table if exists non_temporary_admin_test;")

tk.MustExec("drop table if exists temporary_admin_checksum_table_with_index_test;")
tk.MustExec("drop table if exists temporary_admin_checksum_table_without_index_test;")
tk.MustExec("create global temporary table temporary_admin_checksum_table_with_index_test (id int, count int, PRIMARY KEY(id), KEY(count)) ON COMMIT DELETE ROWS;")
tk.MustExec("create global temporary table temporary_admin_checksum_table_without_index_test (id int, count int, PRIMARY KEY(id)) ON COMMIT DELETE ROWS;")
err = tk.ExecToErr("admin checksum table temporary_admin_checksum_table_with_index_test;")
require.EqualError(t, err, core.ErrOptOnTemporaryTable.GenWithStackByArgs("admin checksum table").Error())
err = tk.ExecToErr("admin checksum table temporary_admin_checksum_table_without_index_test;")
require.EqualError(t, err, core.ErrOptOnTemporaryTable.GenWithStackByArgs("admin checksum table").Error())
tk.MustExec("drop table if exists temporary_admin_checksum_table_with_index_test,temporary_admin_checksum_table_without_index_test;")
}

func TestAdminCheckIndexInLocalTemporaryMode(t *testing.T) {
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists local_temporary_admin_test;")
tk.MustExec("create temporary table local_temporary_admin_test (c1 int, c2 int, c3 int default 1, primary key (c1), index (c1), unique key(c2))")
tk.MustExec("insert local_temporary_admin_test (c1, c2) values (1,1), (2,2), (3,3);")
err := tk.ExecToErr("admin check table local_temporary_admin_test;")
require.EqualError(t, err, core.ErrOptOnTemporaryTable.GenWithStackByArgs("admin check table").Error())
tk.MustExec("drop table if exists temporary_admin_test;")

tk.MustExec("drop table if exists local_temporary_admin_checksum_table_with_index_test;")
tk.MustExec("drop table if exists local_temporary_admin_checksum_table_without_index_test;")
tk.MustExec("create temporary table local_temporary_admin_checksum_table_with_index_test (id int, count int, PRIMARY KEY(id), KEY(count))")
tk.MustExec("create temporary table local_temporary_admin_checksum_table_without_index_test (id int, count int, PRIMARY KEY(id))")
err = tk.ExecToErr("admin checksum table local_temporary_admin_checksum_table_with_index_test;")
require.EqualError(t, err, core.ErrOptOnTemporaryTable.GenWithStackByArgs("admin checksum table").Error())
err = tk.ExecToErr("admin checksum table local_temporary_admin_checksum_table_without_index_test;")
require.EqualError(t, err, core.ErrOptOnTemporaryTable.GenWithStackByArgs("admin checksum table").Error())
tk.MustExec("drop table if exists local_temporary_admin_checksum_table_with_index_test,local_temporary_admin_checksum_table_without_index_test;")
}

func TestAdminCheckIndexInCacheTable(t *testing.T) {
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists cache_admin_test;")
tk.MustExec("create table cache_admin_test (c1 int, c2 int, c3 int default 1, index (c1), unique key(c2))")
tk.MustExec("insert cache_admin_test (c1, c2) values (1, 1), (2, 2), (5, 5), (10, 10), (11, 11)")
tk.MustExec("alter table cache_admin_test cache")
tk.MustExec("admin check table cache_admin_test;")
tk.MustExec("admin check index cache_admin_test c1;")
tk.MustExec("admin check index cache_admin_test c2;")
tk.MustExec("alter table cache_admin_test nocache;")
tk.MustExec("drop table if exists cache_admin_test;")

tk.MustExec(`drop table if exists check_index_test;`)
tk.MustExec(`create table check_index_test (a int, b varchar(10), index a_b (a, b), index b (b))`)
tk.MustExec(`insert check_index_test values (3, "ab"),(2, "cd"),(1, "ef"),(-1, "hi")`)
tk.MustExec("alter table check_index_test cache")
result := tk.MustQuery("admin check index check_index_test a_b (2, 4);")
result.Check(testkit.Rows("1 ef 3", "2 cd 2"))
result = tk.MustQuery("admin check index check_index_test a_b (3, 5);")
result.Check(testkit.Rows("-1 hi 4", "1 ef 3"))
tk.MustExec("alter table check_index_test nocache;")
tk.MustExec("drop table if exists check_index_test;")

tk.MustExec("drop table if exists cache_admin_table_with_index_test;")
tk.MustExec("drop table if exists cache_admin_table_without_index_test;")
tk.MustExec("create table cache_admin_table_with_index_test (id int, count int, PRIMARY KEY(id), KEY(count))")
tk.MustExec("create table cache_admin_table_without_index_test (id int, count int, PRIMARY KEY(id))")
tk.MustExec("alter table cache_admin_table_with_index_test cache")
tk.MustExec("alter table cache_admin_table_without_index_test cache")
tk.MustExec("admin checksum table cache_admin_table_with_index_test;")
tk.MustExec("admin checksum table cache_admin_table_without_index_test;")

tk.MustExec("alter table cache_admin_table_with_index_test nocache;")
tk.MustExec("alter table cache_admin_table_without_index_test nocache;")
tk.MustExec("drop table if exists cache_admin_table_with_index_test,cache_admin_table_without_index_test;")
}

func TestAdminRecoverIndex(t *testing.T) {
store, domain := testkit.CreateMockStoreAndDomain(t)

Expand Down Expand Up @@ -599,17 +504,6 @@ func TestAdminRecoverIndex1(t *testing.T) {
tk.MustExec("admin check index admin_test `primary`")
}

// https://github.com/pingcap/tidb/issues/32915.
func TestAdminRecoverIndexEdge(t *testing.T) {
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t(id bigint(20) primary key, col varchar(255) unique key);")
tk.MustExec("insert into t values(9223372036854775807, 'test');")
tk.MustQuery("admin recover index t col;").Check(testkit.Rows("0 1"))
}

func TestAdminCleanupIndex(t *testing.T) {
store, domain := testkit.CreateMockStoreAndDomain(t)

Expand Down Expand Up @@ -1407,16 +1301,6 @@ func TestCheckFailReport(t *testing.T) {
}()
}

func TestAdminCheckPrimaryIndex(t *testing.T) {
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t(a bigint unsigned primary key, b int, c int, index idx(a, b));")
tk.MustExec("insert into t values(1, 1, 1), (9223372036854775807, 2, 2);")
tk.MustExec("admin check index t idx;")
}

func TestAdminCheckWithSnapshot(t *testing.T) {
store, domain := testkit.CreateMockStoreAndDomain(t)

Expand Down
2 changes: 1 addition & 1 deletion executor/test/fktest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go_test(
"main_test.go",
],
flaky = True,
shard_count = 39,
shard_count = 26,
deps = [
"//config",
"//executor",
Expand Down
Loading