From 163064d94de41dc27448792b3c27e52de44c2189 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Mon, 14 Feb 2022 14:17:37 +0800 Subject: [PATCH] executor: migrate test-infra to testify for explain_test (#32307) close pingcap/tidb#28578 --- executor/explain_test.go | 207 ++++++++++++++++++++++----------------- 1 file changed, 119 insertions(+), 88 deletions(-) diff --git a/executor/explain_test.go b/executor/explain_test.go index a26f373e10..abb25fb956 100644 --- a/executor/explain_test.go +++ b/executor/explain_test.go @@ -18,21 +18,24 @@ import ( "bytes" "fmt" "strings" + "testing" - . "github.com/pingcap/check" "github.com/pingcap/tidb/parser/auth" plannercore "github.com/pingcap/tidb/planner/core" "github.com/pingcap/tidb/session" - "github.com/pingcap/tidb/util/testkit" + "github.com/pingcap/tidb/testkit" "github.com/pingcap/tidb/util/testutil" + "github.com/stretchr/testify/require" ) -func (s *testSuite1) TestExplainPrivileges(c *C) { - se, err := session.CreateSession4Test(s.store) - c.Assert(err, IsNil) - c.Assert(se.Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil), IsTrue) - tk := testkit.NewTestKit(c, s.store) - tk.Se = se +func TestExplainPrivileges(t *testing.T) { + store, clean := testkit.CreateMockStore(t) + defer clean() + se, err := session.CreateSession4Test(store) + require.NoError(t, err) + require.True(t, se.Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil)) + tk := testkit.NewTestKit(t, store) + tk.SetSession(se) tk.MustExec("create database explaindatabase") tk.MustExec("use explaindatabase") @@ -40,11 +43,11 @@ func (s *testSuite1) TestExplainPrivileges(c *C) { tk.MustExec("create view v as select * from t") tk.MustExec(`create user 'explain'@'%'`) - tk1 := testkit.NewTestKit(c, s.store) - se, err = session.CreateSession4Test(s.store) - c.Assert(err, IsNil) - c.Assert(se.Auth(&auth.UserIdentity{Username: "explain", Hostname: "%"}, nil, nil), IsTrue) - tk1.Se = se + tk1 := testkit.NewTestKit(t, store) + se, err = session.CreateSession4Test(store) + require.NoError(t, err) + require.True(t, se.Auth(&auth.UserIdentity{Username: "explain", Hostname: "%"}, nil, nil)) + tk1.SetSession(se) tk.MustExec(`grant select on explaindatabase.v to 'explain'@'%'`) tk1.MustQuery("show databases").Check(testkit.Rows("INFORMATION_SCHEMA", "explaindatabase")) @@ -52,7 +55,7 @@ func (s *testSuite1) TestExplainPrivileges(c *C) { tk1.MustExec("use explaindatabase") tk1.MustQuery("select * from v") err = tk1.ExecToErr("explain format = 'brief' select * from v") - c.Assert(err.Error(), Equals, plannercore.ErrViewNoExplain.Error()) + require.Equal(t, plannercore.ErrViewNoExplain.Error(), err.Error()) tk.MustExec(`grant show view on explaindatabase.v to 'explain'@'%'`) tk1.MustQuery("explain format = 'brief' select * from v") @@ -60,11 +63,14 @@ func (s *testSuite1) TestExplainPrivileges(c *C) { tk.MustExec(`revoke select on explaindatabase.v from 'explain'@'%'`) err = tk1.ExecToErr("explain format = 'brief' select * from v") - c.Assert(err.Error(), Equals, plannercore.ErrTableaccessDenied.GenWithStackByArgs("SELECT", "explain", "%", "v").Error()) + require.Equal(t, plannercore.ErrTableaccessDenied.GenWithStackByArgs("SELECT", "explain", "%", "v").Error(), err.Error()) } -func (s *testSuite1) TestExplainCartesianJoin(c *C) { - tk := testkit.NewTestKitWithInit(c, s.store) +func TestExplainCartesianJoin(t *testing.T) { + store, clean := testkit.CreateMockStore(t) + defer clean() + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test") tk.MustExec("drop table if exists t") tk.MustExec("create table t (v int)") @@ -87,12 +93,15 @@ func (s *testSuite1) TestExplainCartesianJoin(c *C) { } } - c.Assert(ok, Equals, ca.isCartesianJoin) + require.Equal(t, ca.isCartesianJoin, ok) } } -func (s *testSuite1) TestExplainWrite(c *C) { - tk := testkit.NewTestKitWithInit(c, s.store) +func TestExplainWrite(t *testing.T) { + store, clean := testkit.CreateMockStore(t) + defer clean() + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test") tk.MustExec("drop table if exists t") tk.MustExec("create table t (a int)") tk.MustQuery("explain analyze insert into t select 1") @@ -106,28 +115,31 @@ func (s *testSuite1) TestExplainWrite(c *C) { tk.MustQuery("select * from t order by a").Check(testkit.Rows("1", "2", "3")) } -func (s *testSuite1) TestExplainAnalyzeMemory(c *C) { - tk := testkit.NewTestKitWithInit(c, s.store) +func TestExplainAnalyzeMemory(t *testing.T) { + store, clean := testkit.CreateMockStore(t) + defer clean() + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test") tk.MustExec("drop table if exists t") tk.MustExec("create table t (v int, k int, key(k))") tk.MustExec("insert into t values (1, 1), (1, 1), (1, 1), (1, 1), (1, 1)") - s.checkMemoryInfo(c, tk, "explain analyze select * from t order by v") - s.checkMemoryInfo(c, tk, "explain analyze select * from t order by v limit 5") - s.checkMemoryInfo(c, tk, "explain analyze select /*+ HASH_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.v = t2.v+1") - s.checkMemoryInfo(c, tk, "explain analyze select /*+ MERGE_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.k = t2.k+1") - s.checkMemoryInfo(c, tk, "explain analyze select /*+ INL_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.k = t2.k and t1.v=1") - s.checkMemoryInfo(c, tk, "explain analyze select /*+ INL_HASH_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.k = t2.k and t1.v=1") - s.checkMemoryInfo(c, tk, "explain analyze select /*+ INL_MERGE_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.k = t2.k and t1.v=1") - s.checkMemoryInfo(c, tk, "explain analyze select sum(k) from t group by v") - s.checkMemoryInfo(c, tk, "explain analyze select sum(v) from t group by k") - s.checkMemoryInfo(c, tk, "explain analyze select * from t") - s.checkMemoryInfo(c, tk, "explain analyze select k from t use index(k)") - s.checkMemoryInfo(c, tk, "explain analyze select * from t use index(k)") - s.checkMemoryInfo(c, tk, "explain analyze select v+k from t") + checkMemoryInfo(t, tk, "explain analyze select * from t order by v") + checkMemoryInfo(t, tk, "explain analyze select * from t order by v limit 5") + checkMemoryInfo(t, tk, "explain analyze select /*+ HASH_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.v = t2.v+1") + checkMemoryInfo(t, tk, "explain analyze select /*+ MERGE_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.k = t2.k+1") + checkMemoryInfo(t, tk, "explain analyze select /*+ INL_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.k = t2.k and t1.v=1") + checkMemoryInfo(t, tk, "explain analyze select /*+ INL_HASH_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.k = t2.k and t1.v=1") + checkMemoryInfo(t, tk, "explain analyze select /*+ INL_MERGE_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.k = t2.k and t1.v=1") + checkMemoryInfo(t, tk, "explain analyze select sum(k) from t group by v") + checkMemoryInfo(t, tk, "explain analyze select sum(v) from t group by k") + checkMemoryInfo(t, tk, "explain analyze select * from t") + checkMemoryInfo(t, tk, "explain analyze select k from t use index(k)") + checkMemoryInfo(t, tk, "explain analyze select * from t use index(k)") + checkMemoryInfo(t, tk, "explain analyze select v+k from t") } -func (s *testSuite1) checkMemoryInfo(c *C, tk *testkit.TestKit, sql string) { +func checkMemoryInfo(t *testing.T, tk *testkit.TestKit, sql string) { memCol := 6 ops := []string{"Join", "Reader", "Top", "Sort", "LookUp", "Projection", "Selection", "Agg"} rows := tk.MustQuery(sql).Rows() @@ -149,31 +161,34 @@ func (s *testSuite1) checkMemoryInfo(c *C, tk *testkit.TestKit, sql string) { } if shouldHasMem { - c.Assert(strs[memCol], Not(Equals), "N/A") + require.NotEqual(t, "N/A", strs[memCol]) } else { - c.Assert(strs[memCol], Equals, "N/A") + require.Equal(t, "N/A", strs[memCol]) } } } -func (s *testSuite1) TestMemoryAndDiskUsageAfterClose(c *C) { - tk := testkit.NewTestKitWithInit(c, s.store) +func TestMemoryAndDiskUsageAfterClose(t *testing.T) { + store, clean := testkit.CreateMockStore(t) + defer clean() + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test") tk.MustExec("drop table if exists t") tk.MustExec("create table t (v int, k int, key(k))") batch := 128 - limit := tk.Se.GetSessionVars().MaxChunkSize*2 + 10 + limit := tk.Session().GetSessionVars().MaxChunkSize*2 + 10 var buf bytes.Buffer for i := 0; i < limit; { buf.Reset() _, err := buf.WriteString("insert into t values ") - c.Assert(err, IsNil) + require.NoError(t, err) for j := 0; j < batch && i < limit; i, j = i+1, j+1 { if j > 0 { _, err = buf.WriteString(", ") - c.Assert(err, IsNil) + require.NoError(t, err) } _, err = buf.WriteString(fmt.Sprintf("(%v,%v)", i, i)) - c.Assert(err, IsNil) + require.NoError(t, err) } tk.MustExec(buf.String()) } @@ -185,31 +200,34 @@ func (s *testSuite1) TestMemoryAndDiskUsageAfterClose(c *C) { } for _, sql := range SQLs { tk.MustQuery(sql) - c.Assert(tk.Se.GetSessionVars().StmtCtx.MemTracker.BytesConsumed(), Equals, int64(0)) - c.Assert(tk.Se.GetSessionVars().StmtCtx.MemTracker.MaxConsumed(), Greater, int64(0)) - c.Assert(tk.Se.GetSessionVars().StmtCtx.DiskTracker.BytesConsumed(), Equals, int64(0)) + require.Equal(t, int64(0), tk.Session().GetSessionVars().StmtCtx.MemTracker.BytesConsumed()) + require.Greater(t, tk.Session().GetSessionVars().StmtCtx.MemTracker.MaxConsumed(), int64(0)) + require.Equal(t, int64(0), tk.Session().GetSessionVars().StmtCtx.DiskTracker.BytesConsumed()) } } -func (s *testSuite2) TestExplainAnalyzeExecutionInfo(c *C) { - tk := testkit.NewTestKitWithInit(c, s.store) +func TestExplainAnalyzeExecutionInfo(t *testing.T) { + store, clean := testkit.CreateMockStore(t) + defer clean() + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test") tk.MustExec("drop table if exists t") tk.MustExec("create table t (v int, k int, key(k))") tk.MustExec("insert into t values (1, 1), (1, 1), (1, 1), (1, 1), (1, 1)") - s.checkExecutionInfo(c, tk, "explain analyze select * from t order by v") - s.checkExecutionInfo(c, tk, "explain analyze select * from t order by v limit 5") - s.checkExecutionInfo(c, tk, "explain analyze select /*+ HASH_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.v = t2.v+1") - s.checkExecutionInfo(c, tk, "explain analyze select /*+ MERGE_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.k = t2.k+1") - s.checkExecutionInfo(c, tk, "explain analyze select /*+ INL_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.k = t2.k and t1.v=1") - s.checkExecutionInfo(c, tk, "explain analyze select /*+ INL_HASH_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.k = t2.k and t1.v=1") - s.checkExecutionInfo(c, tk, "explain analyze select /*+ INL_MERGE_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.k = t2.k and t1.v=1") - s.checkExecutionInfo(c, tk, "explain analyze select sum(k) from t group by v") - s.checkExecutionInfo(c, tk, "explain analyze select sum(v) from t group by k") - s.checkExecutionInfo(c, tk, "explain analyze select * from t") - s.checkExecutionInfo(c, tk, "explain analyze select k from t use index(k)") - s.checkExecutionInfo(c, tk, "explain analyze select * from t use index(k)") - s.checkExecutionInfo(c, tk, "explain analyze with recursive cte(a) as (select 1 union select a + 1 from cte where a < 1000) select * from cte;") + checkExecutionInfo(t, tk, "explain analyze select * from t order by v") + checkExecutionInfo(t, tk, "explain analyze select * from t order by v limit 5") + checkExecutionInfo(t, tk, "explain analyze select /*+ HASH_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.v = t2.v+1") + checkExecutionInfo(t, tk, "explain analyze select /*+ MERGE_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.k = t2.k+1") + checkExecutionInfo(t, tk, "explain analyze select /*+ INL_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.k = t2.k and t1.v=1") + checkExecutionInfo(t, tk, "explain analyze select /*+ INL_HASH_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.k = t2.k and t1.v=1") + checkExecutionInfo(t, tk, "explain analyze select /*+ INL_MERGE_JOIN(t1, t2) */ t1.k from t t1, t t2 where t1.k = t2.k and t1.v=1") + checkExecutionInfo(t, tk, "explain analyze select sum(k) from t group by v") + checkExecutionInfo(t, tk, "explain analyze select sum(v) from t group by k") + checkExecutionInfo(t, tk, "explain analyze select * from t") + checkExecutionInfo(t, tk, "explain analyze select k from t use index(k)") + checkExecutionInfo(t, tk, "explain analyze select * from t use index(k)") + checkExecutionInfo(t, tk, "explain analyze with recursive cte(a) as (select 1 union select a + 1 from cte where a < 1000) select * from cte;") tk.MustExec("CREATE TABLE IF NOT EXISTS nation ( N_NATIONKEY BIGINT NOT NULL,N_NAME CHAR(25) NOT NULL,N_REGIONKEY BIGINT NOT NULL,N_COMMENT VARCHAR(152),PRIMARY KEY (N_NATIONKEY));") tk.MustExec("CREATE TABLE IF NOT EXISTS part ( P_PARTKEY BIGINT NOT NULL,P_NAME VARCHAR(55) NOT NULL,P_MFGR CHAR(25) NOT NULL,P_BRAND CHAR(10) NOT NULL,P_TYPE VARCHAR(25) NOT NULL,P_SIZE BIGINT NOT NULL,P_CONTAINER CHAR(10) NOT NULL,P_RETAILPRICE DECIMAL(15,2) NOT NULL,P_COMMENT VARCHAR(23) NOT NULL,PRIMARY KEY (P_PARTKEY));") @@ -218,7 +236,7 @@ func (s *testSuite2) TestExplainAnalyzeExecutionInfo(c *C) { tk.MustExec("CREATE TABLE IF NOT EXISTS orders ( O_ORDERKEY BIGINT NOT NULL,O_CUSTKEY BIGINT NOT NULL,O_ORDERSTATUS CHAR(1) NOT NULL,O_TOTALPRICE DECIMAL(15,2) NOT NULL,O_ORDERDATE DATE NOT NULL,O_ORDERPRIORITY CHAR(15) NOT NULL,O_CLERK CHAR(15) NOT NULL,O_SHIPPRIORITY BIGINT NOT NULL,O_COMMENT VARCHAR(79) NOT NULL,PRIMARY KEY (O_ORDERKEY),CONSTRAINT FOREIGN KEY ORDERS_FK1 (O_CUSTKEY) references customer(C_CUSTKEY));") tk.MustExec("CREATE TABLE IF NOT EXISTS lineitem ( L_ORDERKEY BIGINT NOT NULL,L_PARTKEY BIGINT NOT NULL,L_SUPPKEY BIGINT NOT NULL,L_LINENUMBER BIGINT NOT NULL,L_QUANTITY DECIMAL(15,2) NOT NULL,L_EXTENDEDPRICE DECIMAL(15,2) NOT NULL,L_DISCOUNT DECIMAL(15,2) NOT NULL,L_TAX DECIMAL(15,2) NOT NULL,L_RETURNFLAG CHAR(1) NOT NULL,L_LINESTATUS CHAR(1) NOT NULL,L_SHIPDATE DATE NOT NULL,L_COMMITDATE DATE NOT NULL,L_RECEIPTDATE DATE NOT NULL,L_SHIPINSTRUCT CHAR(25) NOT NULL,L_SHIPMODE CHAR(10) NOT NULL,L_COMMENT VARCHAR(44) NOT NULL,PRIMARY KEY (L_ORDERKEY,L_LINENUMBER),CONSTRAINT FOREIGN KEY LINEITEM_FK1 (L_ORDERKEY) references orders(O_ORDERKEY),CONSTRAINT FOREIGN KEY LINEITEM_FK2 (L_PARTKEY,L_SUPPKEY) references partsupp(PS_PARTKEY, PS_SUPPKEY));") - s.checkExecutionInfo(c, tk, "select nation, o_year, sum(amount) as sum_profit from ( select n_name as nation, extract(year from o_orderdate) as o_year, l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount from part, supplier, lineitem, partsupp, orders, nation where s_suppkey = l_suppkey and ps_suppkey = l_suppkey and ps_partkey = l_partkey and p_partkey = l_partkey and o_orderkey = l_orderkey and s_nationkey = n_nationkey and p_name like '%dim%' ) as profit group by nation, o_year order by nation, o_year desc;") + checkExecutionInfo(t, tk, "select nation, o_year, sum(amount) as sum_profit from ( select n_name as nation, extract(year from o_orderdate) as o_year, l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount from part, supplier, lineitem, partsupp, orders, nation where s_suppkey = l_suppkey and ps_suppkey = l_suppkey and ps_partkey = l_partkey and p_partkey = l_partkey and o_orderkey = l_orderkey and s_nationkey = n_nationkey and p_name like '%dim%' ) as profit group by nation, o_year order by nation, o_year desc;") tk.MustExec("drop table if exists nation") tk.MustExec("drop table if exists part") @@ -228,7 +246,7 @@ func (s *testSuite2) TestExplainAnalyzeExecutionInfo(c *C) { tk.MustExec("drop table if exists lineitem") } -func (s *testSuite2) checkExecutionInfo(c *C, tk *testkit.TestKit, sql string) { +func checkExecutionInfo(t *testing.T, tk *testkit.TestKit, sql string) { executionInfoCol := 4 rows := tk.MustQuery(sql).Rows() for _, row := range rows { @@ -236,21 +254,23 @@ func (s *testSuite2) checkExecutionInfo(c *C, tk *testkit.TestKit, sql string) { for i, c := range row { strs[i] = c.(string) } - - c.Assert(strs[executionInfoCol], Not(Equals), "time:0s, loops:0, rows:0") + require.NotEqual(t, "time:0s, loops:0, rows:0", strs[executionInfoCol]) } } -func (s *testSuite2) TestExplainAnalyzeActRowsNotEmpty(c *C) { - tk := testkit.NewTestKitWithInit(c, s.store) +func TestExplainAnalyzeActRowsNotEmpty(t *testing.T) { + store, clean := testkit.CreateMockStore(t) + defer clean() + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test") tk.MustExec("drop table if exists t") tk.MustExec("create table t (a int, b int, index (a))") tk.MustExec("insert into t values (1, 1)") - s.checkActRowsNotEmpty(c, tk, "explain analyze select * from t t1, t t2 where t1.b = t2.a and t1.b = 2333") + checkActRowsNotEmpty(t, tk, "explain analyze select * from t t1, t t2 where t1.b = t2.a and t1.b = 2333") } -func (s *testSuite2) checkActRowsNotEmpty(c *C, tk *testkit.TestKit, sql string) { +func checkActRowsNotEmpty(t *testing.T, tk *testkit.TestKit, sql string) { actRowsCol := 2 rows := tk.MustQuery(sql).Rows() for _, row := range rows { @@ -258,28 +278,30 @@ func (s *testSuite2) checkActRowsNotEmpty(c *C, tk *testkit.TestKit, sql string) for i, c := range row { strs[i] = c.(string) } - - c.Assert(strs[actRowsCol], Not(Equals), "") + require.NotEqual(t, "", strs[actRowsCol]) } } -func checkActRows(c *C, tk *testkit.TestKit, sql string, expected []string) { +func checkActRows(t *testing.T, tk *testkit.TestKit, sql string, expected []string) { actRowsCol := 2 rows := tk.MustQuery("explain analyze " + sql).Rows() - c.Assert(len(rows), Equals, len(expected)) + require.Equal(t, len(expected), len(rows)) for id, row := range rows { strs := make([]string, len(row)) for i, c := range row { strs[i] = c.(string) } - c.Assert(strs[actRowsCol], Equals, expected[id]) + require.Equal(t, expected[id], strs[actRowsCol]) } } -func (s *testSuite1) TestCheckActRowsWithUnistore(c *C) { +func TestCheckActRowsWithUnistore(t *testing.T) { + store, clean := testkit.CreateMockStore(t) + defer clean() // testSuite1 use default mockstore which is unistore - tk := testkit.NewTestKitWithInit(c, s.store) + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test") tk.MustExec("drop table if exists t_unistore_act_rows") tk.MustExec("create table t_unistore_act_rows(a int, b int, index(a, b))") tk.MustExec("insert into t_unistore_act_rows values (1, 0), (1, 0), (2, 0), (2, 1)") @@ -330,12 +352,15 @@ func (s *testSuite1) TestCheckActRowsWithUnistore(c *C) { } for _, test := range tests { - checkActRows(c, tk, test.sql, test.expected) + checkActRows(t, tk, test.sql, test.expected) } } -func (s *testSuite2) TestExplainAnalyzeCTEMemoryAndDiskInfo(c *C) { - tk := testkit.NewTestKitWithInit(c, s.store) +func TestExplainAnalyzeCTEMemoryAndDiskInfo(t *testing.T) { + store, clean := testkit.CreateMockStore(t) + defer clean() + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test") tk.MustExec("drop table if exists t") tk.MustExec("create table t (a int)") tk.MustExec("insert into t with recursive cte(a) as (select 1 union select a + 1 from cte where a < 1000) select * from cte;") @@ -343,19 +368,22 @@ func (s *testSuite2) TestExplainAnalyzeCTEMemoryAndDiskInfo(c *C) { rows := tk.MustQuery("explain analyze with recursive cte(a) as (select 1 union select a + 1 from cte where a < 1000)" + " select * from cte, t;").Rows() - c.Assert(rows[4][7].(string), Not(Equals), "N/A") - c.Assert(rows[4][8].(string), Equals, "0 Bytes") + require.NotEqual(t, "N/A", rows[4][7].(string)) + require.Equal(t, "0 Bytes", rows[4][8].(string)) tk.MustExec("set @@tidb_mem_quota_query=10240;") rows = tk.MustQuery("explain analyze with recursive cte(a) as (select 1 union select a + 1 from cte where a < 1000)" + " select * from cte, t;").Rows() - c.Assert(rows[4][7].(string), Not(Equals), "N/A") - c.Assert(rows[4][8].(string), Not(Equals), "N/A") + require.NotEqual(t, "N/A", rows[4][7].(string)) + require.NotEqual(t, "N/A", rows[4][8].(string)) } -func (s *testSuite) TestExplainStatementsSummary(c *C) { - tk := testkit.NewTestKitWithInit(c, s.store) +func TestExplainStatementsSummary(t *testing.T) { + store, clean := testkit.CreateMockStore(t) + defer clean() + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test") tk.MustQuery("desc select * from information_schema.statements_summary").Check(testkit.Rows( `MemTableScan_4 10000.00 root table:STATEMENTS_SUMMARY `)) tk.MustQuery("desc select * from information_schema.statements_summary where digest is null").Check(testutil.RowsWithSep("|", @@ -366,8 +394,11 @@ func (s *testSuite) TestExplainStatementsSummary(c *C) { `MemTableScan_5 10000.00 root table:STATEMENTS_SUMMARY digests: ["a","b","c"]`)) } -func (s *testSuite) TestFix29401(c *C) { - tk := testkit.NewTestKitWithInit(c, s.store) +func TestFix29401(t *testing.T) { + store, clean := testkit.CreateMockStore(t) + defer clean() + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test") tk.MustExec("drop table if exists tt123;") tk.MustExec(`CREATE TABLE tt123 ( id int(11) NOT NULL,