From e974a2cdc0c1cf33a79664d77217cd87390e67c6 Mon Sep 17 00:00:00 2001 From: Suriya Ganesh Date: Sat, 2 Oct 2021 22:49:12 +0530 Subject: [PATCH 1/4] Fix for issue https://github.com/pingcap/tidb/issues/28498 --- executor/adapter_test.go | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/executor/adapter_test.go b/executor/adapter_test.go index ebc7fc60246d0..2fb8520765976 100644 --- a/executor/adapter_test.go +++ b/executor/adapter_test.go @@ -15,24 +15,31 @@ package executor_test import ( + "testing" "time" - . "github.com/pingcap/check" - "github.com/pingcap/tidb/util/testkit" + "github.com/pingcap/tidb/testkit" + "github.com/stretchr/testify/require" ) -func (s *testSuiteP2) TestQueryTime(c *C) { - tk := testkit.NewTestKit(c, s.store) +func TestQueryTime(t *testing.T) { + + store, clean := testkit.CreateMockStore(t) + defer clean() + + tk := testkit.NewTestKit(t, store) tk.MustExec("use test") - costTime := time.Since(tk.Se.GetSessionVars().StartTime) - c.Assert(costTime < 1*time.Second, IsTrue) + costTime := time.Since(tk.Session().GetSessionVars().StartTime) + + require.Equal(t, true, true, costTime < 1*time.Second) tk.MustExec("drop table if exists t") tk.MustExec("create table t(a int)") tk.MustExec("insert into t values(1), (1), (1), (1), (1)") tk.MustExec("select * from t t1 join t t2 on t1.a = t2.a") - costTime = time.Since(tk.Se.GetSessionVars().StartTime) - c.Assert(costTime < 1*time.Second, IsTrue) + costTime = time.Since(tk.Session().GetSessionVars().StartTime) + + require.Equal(t, true, costTime < 1*time.Second) } From 313a5d09354765734fd07749a685bbd056b23bfe Mon Sep 17 00:00:00 2001 From: Suriya Ganesh Date: Sun, 3 Oct 2021 10:48:31 +0530 Subject: [PATCH 2/4] Fixing review comments --- executor/adapter_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/executor/adapter_test.go b/executor/adapter_test.go index 2fb8520765976..227c830b55ea0 100644 --- a/executor/adapter_test.go +++ b/executor/adapter_test.go @@ -24,6 +24,7 @@ import ( func TestQueryTime(t *testing.T) { + t.Parallel() store, clean := testkit.CreateMockStore(t) defer clean() @@ -32,7 +33,7 @@ func TestQueryTime(t *testing.T) { costTime := time.Since(tk.Session().GetSessionVars().StartTime) - require.Equal(t, true, true, costTime < 1*time.Second) + require.Less(t, costTime , time.Second) tk.MustExec("drop table if exists t") tk.MustExec("create table t(a int)") @@ -41,5 +42,5 @@ func TestQueryTime(t *testing.T) { costTime = time.Since(tk.Session().GetSessionVars().StartTime) - require.Equal(t, true, costTime < 1*time.Second) + require.Less(t, costTime, time.Second) } From 418131251360251033880b47f158617a0d385788 Mon Sep 17 00:00:00 2001 From: Suriya Ganesh Date: Sun, 3 Oct 2021 12:59:32 +0530 Subject: [PATCH 3/4] go fmt fix for failing jenkins job --- executor/adapter_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executor/adapter_test.go b/executor/adapter_test.go index 227c830b55ea0..f447e04cb21ba 100644 --- a/executor/adapter_test.go +++ b/executor/adapter_test.go @@ -33,7 +33,7 @@ func TestQueryTime(t *testing.T) { costTime := time.Since(tk.Session().GetSessionVars().StartTime) - require.Less(t, costTime , time.Second) + require.Less(t, costTime, time.Second) tk.MustExec("drop table if exists t") tk.MustExec("create table t(a int)") From 931fa6e79381a2533030045bd06454b86048984f Mon Sep 17 00:00:00 2001 From: mmyj Date: Tue, 5 Oct 2021 00:29:16 +0800 Subject: [PATCH 4/4] remove blank lines. --- executor/adapter_test.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/executor/adapter_test.go b/executor/adapter_test.go index f447e04cb21ba..40ae6e168b1f0 100644 --- a/executor/adapter_test.go +++ b/executor/adapter_test.go @@ -23,7 +23,6 @@ import ( ) func TestQueryTime(t *testing.T) { - t.Parallel() store, clean := testkit.CreateMockStore(t) defer clean() @@ -32,7 +31,6 @@ func TestQueryTime(t *testing.T) { tk.MustExec("use test") costTime := time.Since(tk.Session().GetSessionVars().StartTime) - require.Less(t, costTime, time.Second) tk.MustExec("drop table if exists t") @@ -41,6 +39,5 @@ func TestQueryTime(t *testing.T) { tk.MustExec("select * from t t1 join t t2 on t1.a = t2.a") costTime = time.Since(tk.Session().GetSessionVars().StartTime) - require.Less(t, costTime, time.Second) }