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: migrate test-infra to testify for executor/union_scan_test.go #30525

Merged
merged 12 commits into from
Dec 13, 2021
Merged
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
57 changes: 38 additions & 19 deletions executor/union_scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ package executor_test

import (
"fmt"
"testing"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/util/testkit"
"github.com/pingcap/tidb/testkit"
"github.com/stretchr/testify/require"
)

func (s *testSuite7) TestDirtyTransaction(c *C) {
tk := testkit.NewTestKit(c, s.store)
func TestDirtyTransaction(t *testing.T) {
t.Parallel()
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("set @@session.tidb_executor_concurrency = 4;")
tk.MustExec("set @@session.tidb_hash_join_concurrency = 5;")
tk.MustExec("set @@session.tidb_distsql_scan_concurrency = 15;")
Expand Down Expand Up @@ -149,8 +153,11 @@ func (s *testSuite7) TestDirtyTransaction(c *C) {
tk.MustExec("commit;")
}

func (s *testSuite7) TestUnionScanWithCastCondition(c *C) {
tk := testkit.NewTestKit(c, s.store)
func TestUnionScanWithCastCondition(t *testing.T) {
hawkingrei marked this conversation as resolved.
Show resolved Hide resolved
t.Parallel()
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table ta (a varchar(20))")
tk.MustExec("insert ta values ('1'), ('2')")
Expand All @@ -162,8 +169,11 @@ func (s *testSuite7) TestUnionScanWithCastCondition(c *C) {
tk.MustExec("rollback")
}

func (s *testSuite7) TestUnionScanForMemBufferReader(c *C) {
tk := testkit.NewTestKit(c, s.store)
func TestUnionScanForMemBufferReader(t *testing.T) {
t.Parallel()
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 idx(b))")
Expand Down Expand Up @@ -214,8 +224,8 @@ func (s *testSuite7) TestUnionScanForMemBufferReader(c *C) {
tk.MustExec("insert t values (1,1),(2,2)")
tk.MustExec("begin")
_, err := tk.Exec("update t set b=b+1")
c.Assert(err, NotNil)
c.Assert(err.Error(), Equals, "[kv:1062]Duplicate entry '2' for key 'idx'")
require.NotNil(t, err)
require.EqualError(t, err, "[kv:1062]Duplicate entry '2' for key 'idx'")
// update with unchange index column.
tk.MustExec("update t set a=a+1")
tk.MustQuery("select * from t use index (idx)").Check(testkit.Rows("2 1", "3 2"))
Expand Down Expand Up @@ -298,8 +308,11 @@ func (s *testSuite7) TestUnionScanForMemBufferReader(c *C) {
tk.MustExec("admin check table t1;")
}

func (s *testSuite7) TestForUpdateUntouchedIndex(c *C) {
tk := testkit.NewTestKit(c, s.store)
func TestForUpdateUntouchedIndex(t *testing.T) {
t.Parallel()
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")

Expand Down Expand Up @@ -330,14 +343,17 @@ func (s *testSuite7) TestForUpdateUntouchedIndex(c *C) {
tk.MustExec("create table t (a int,b int, unique index(a))")
tk.MustExec("begin")
_, err := tk.Exec("insert into t values (1, 1), (2, 2), (1, 3) on duplicate key update a = a + 1;")
c.Assert(err, NotNil)
c.Assert(err.Error(), Equals, "[kv:1062]Duplicate entry '2' for key 'a'")
require.NotNil(t, err)
require.EqualError(t, err, "[kv:1062]Duplicate entry '2' for key 'a'")
tk.MustExec("commit")
tk.MustExec("admin check table t")
}

func (s *testSuite7) TestUpdateScanningHandles(c *C) {
tk := testkit.NewTestKit(c, s.store)
func TestUpdateScanningHandles(t *testing.T) {
t.Parallel()
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 primary key, b int);")
Expand All @@ -363,13 +379,16 @@ func (s *testSuite7) TestUpdateScanningHandles(c *C) {
tk.MustExec("insert into t values (1, 1);")
tk.MustExec("update /*+ INL_JOIN(t1) */ t t1, (select a, b from t) t2 set t1.b = t2.b where t1.a = t2.a + 1000;")
result := tk.MustQuery("select a, a-b from t where a > 1000 and a - b != 1000;")
c.Assert(result.Rows(), HasLen, 0)
require.Len(t, result.Rows(), 0)
tk.MustExec("rollback;")
}

// See https://github.com/pingcap/tidb/issues/19136
func (s *testSuite7) TestForApplyAndUnionScan(c *C) {
tk := testkit.NewTestKit(c, s.store)
func TestForApplyAndUnionScan(t *testing.T) {
t.Parallel()
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")

Expand Down