Skip to content

Commit

Permalink
tests, ddl: move IT in ddl/ to tests/integrationtest (Part 2) (pi…
Browse files Browse the repository at this point in the history
  • Loading branch information
Defined2014 authored Oct 11, 2023
1 parent cf22c52 commit 937feda
Show file tree
Hide file tree
Showing 25 changed files with 4,975 additions and 3,148 deletions.
1 change: 0 additions & 1 deletion ddl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ go_test(
"db_cache_test.go",
"db_change_failpoints_test.go",
"db_change_test.go",
"db_foreign_key_test.go",
"db_integration_test.go",
"db_rename_test.go",
"db_table_test.go",
Expand Down
911 changes: 0 additions & 911 deletions ddl/constraint_test.go

Large diffs are not rendered by default.

102 changes: 0 additions & 102 deletions ddl/db_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,95 +37,6 @@ func checkTableCacheStatus(t *testing.T, tk *testkit.TestKit, dbName, tableName
require.Equal(t, status, tb.Meta().TableCacheStatusType)
}

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

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test;")
tk.MustExec("drop table if exists cache_partition_table;")
tk.MustExec("create table cache_partition_table (a int, b int) partition by hash(a) partitions 3;")
tk.MustGetErrCode("alter table cache_partition_table cache", errno.ErrOptOnCacheTable)
defer tk.MustExec("drop table if exists cache_partition_table;")
tk.MustExec("drop table if exists cache_partition_range_table;")
tk.MustExec(`create table cache_partition_range_table (c1 smallint(6) not null, c2 char(5) default null) partition by range ( c1 ) (
partition p0 values less than (10),
partition p1 values less than (20),
partition p2 values less than (30),
partition p3 values less than (MAXVALUE)
);`)
tk.MustGetErrCode("alter table cache_partition_range_table cache;", errno.ErrOptOnCacheTable)
defer tk.MustExec("drop table if exists cache_partition_range_table;")
tk.MustExec("drop table if exists partition_list_table;")
tk.MustExec("set @@session.tidb_enable_list_partition = ON")
tk.MustExec(`create table cache_partition_list_table (id int) partition by list (id) (
partition p0 values in (1,2),
partition p1 values in (3,4),
partition p3 values in (5,null)
);`)
tk.MustGetErrCode("alter table cache_partition_list_table cache", errno.ErrOptOnCacheTable)
tk.MustExec("drop table if exists cache_partition_list_table;")
}

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

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test;")
tk.MustExec("drop table if exists cache_view_t")
tk.MustExec("create table cache_view_t (id int);")
tk.MustExec("create view v as select * from cache_view_t")
tk.MustGetErrCode("alter table v cache", errno.ErrWrongObject)
}

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

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists nocache_t1")
/* Test of cache table */
tk.MustExec("create table nocache_t1 ( n int auto_increment primary key)")
tk.MustExec("alter table nocache_t1 cache")
checkTableCacheStatus(t, tk, "test", "nocache_t1", model.TableCacheStatusEnable)
tk.MustExec("alter table nocache_t1 nocache")
checkTableCacheStatus(t, tk, "test", "nocache_t1", model.TableCacheStatusDisable)
tk.MustExec("drop table if exists t1")
// Test if a table is not exists
tk.MustExec("drop table if exists nocache_t")
tk.MustGetErrCode("alter table nocache_t cache", errno.ErrNoSuchTable)
tk.MustExec("create table nocache_t (a int)")
tk.MustExec("alter table nocache_t nocache")
// Multiple no alter cache is okay
tk.MustExec("alter table nocache_t nocache")
tk.MustExec("alter table nocache_t nocache")
}

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

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test;")
/*Test cache table can't add/drop/rename index */
tk.MustExec("drop table if exists cache_index")
tk.MustExec("create table cache_index (c1 int primary key, c2 int, c3 int, index ok2(c2))")
defer tk.MustExec("drop table if exists cache_index")
tk.MustExec("alter table cache_index cache")
tk.MustGetErrCode("create index cache_c2 on cache_index(c2)", errno.ErrOptOnCacheTable)
tk.MustGetErrCode("alter table cache_index add index k2(c2)", errno.ErrOptOnCacheTable)
tk.MustGetErrCode("alter table cache_index drop index ok2", errno.ErrOptOnCacheTable)
/*Test rename index*/
tk.MustGetErrCode("alter table cache_index rename index ok2 to ok", errno.ErrOptOnCacheTable)
/*Test drop different indexes*/
tk.MustExec("drop table if exists cache_index_1")
tk.MustExec("create table cache_index_1 (id int, c1 int, c2 int, primary key(id), key i1(c1), key i2(c2));")
tk.MustExec("alter table cache_index_1 cache")
tk.MustGetErrCode("alter table cache_index_1 drop index i1, drop index i2;", errno.ErrOptOnCacheTable)

// cleanup
tk.MustExec("alter table cache_index_1 nocache")
tk.MustExec("alter table cache_index nocache")
}

func TestAlterTableCache(t *testing.T) {
store, dom := testkit.CreateMockStoreAndDomain(t)

Expand Down Expand Up @@ -245,19 +156,6 @@ func TestCacheTableSizeLimit(t *testing.T) {
tk.MustGetErrCode("insert into cache_t2 select * from tmp;", errno.ErrOptOnCacheTable)
}

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

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test;")
tk.MustExec("create table cache_t2 (c1 int);")
tk.MustExec("alter table cache_t2 cache;")
tk.MustExec("alter table cache_t2 nocache;")
// Check no warning message here.
tk.MustExec("alter table cache_t2 cache;")
tk.MustQuery("show warnings").Check(testkit.Rows())
}

func TestIssue34069(t *testing.T) {
store := testkit.CreateMockStore(t)
sem.Enable()
Expand Down
36 changes: 0 additions & 36 deletions ddl/db_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/pingcap/tidb/ddl"
"github.com/pingcap/tidb/ddl/util/callback"
"github.com/pingcap/tidb/domain"
"github.com/pingcap/tidb/errno"
"github.com/pingcap/tidb/executor"
"github.com/pingcap/tidb/infoschema"
"github.com/pingcap/tidb/kv"
Expand Down Expand Up @@ -414,32 +413,6 @@ type expectQuery struct {
rows []string
}

func TestAppendEnum(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("create database test_db_state default charset utf8 default collate utf8_bin")
tk.MustExec("use test_db_state")
tk.MustExec(`create table t (
c1 varchar(64),
c2 enum('N','Y') not null default 'N',
c3 timestamp on update current_timestamp,
c4 int primary key,
unique key idx2 (c2, c3))`)
tk.MustExec("insert into t values('a', 'N', '2017-07-01', 8)")
// Make sure these SQLs use the plan of index scan.
tk.MustExec("drop stats t")
tk.MustGetErrMsg("insert into t values('a', 'A', '2018-09-19', 9)", "[types:1265]Data truncated for column 'c2' at row 1")
tk.MustExec("alter table t change c2 c2 enum('N') DEFAULT 'N'")
tk.MustExec("alter table t change c2 c2 int default 0")
tk.MustExec("alter table t change c2 c2 enum('N','Y','A') DEFAULT 'A'")
tk.MustExec("insert into t values('a', 'A', '2018-09-20', 10)")
tk.MustExec("insert into t (c1, c3, c4) values('a', '2018-09-21', 11)")
tk.MustQuery("select c4, c2 from t order by c4 asc").Check(testkit.Rows("8 N", "10 A", "11 A"))
// fixed
tk.MustExec("update t set c2='N' where c4 = 10")
tk.MustQuery("select c2 from t where c4 = 10").Check(testkit.Rows("N"))
}

// https://github.com/pingcap/tidb/pull/6249 fixes the following two test cases.
func TestWriteOnlyWriteNULL(t *testing.T) {
store, dom := testkit.CreateMockStoreAndDomain(t)
Expand Down Expand Up @@ -1899,15 +1872,6 @@ func TestDropExpressionIndex(t *testing.T) {
tk.MustQuery("select * from t order by a, b").Check(testkit.Rows("0 9", "0 11", "1 7", "2 7", "5 7", "8 8", "10 10"))
}

func TestExpressionIndexDDLError(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t(a int, b int, index idx((a+b)))")
tk.MustGetErrCode("alter table t rename column b to b2", errno.ErrDependentByFunctionalIndex)
tk.MustGetErrCode("alter table t drop column b", errno.ErrDependentByFunctionalIndex)
}

func TestParallelRenameTable(t *testing.T) {
store, dom := testkit.CreateMockStoreAndDomain(t)
tk := testkit.NewTestKit(t, store)
Expand Down
65 changes: 0 additions & 65 deletions ddl/db_foreign_key_test.go

This file was deleted.

Loading

0 comments on commit 937feda

Please sign in to comment.