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

testify: migrate test-infra to testify for distsql_test.go #28574 #30654

Closed
wants to merge 132 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
ba2121e
migrate test-infra to testify for distsql_test.go #28574
znhh6018 Dec 12, 2021
74a6f18
optimize dom
znhh6018 Dec 12, 2021
affd3c7
Merge branch 'master' into fix_distsql_test
hawkingrei Dec 13, 2021
6495a5a
planner: add trace for join eliminate rule (#30343)
Yisaer Dec 13, 2021
9a64217
executor: migrate test-infra to testify for executor/shuffle_test.go…
tongtongyin Dec 13, 2021
b8dcc09
planner: make (*AccessPath).OnlyPointRange more succinct (#30520)
xuyifangreeneyes Dec 13, 2021
a532973
planner: add trace for join reorder (#30394)
Yisaer Dec 13, 2021
d3833c2
executor: migrate test-infra to testify for executor/union_scan_test.…
tongtongyin Dec 13, 2021
e8577c7
expression: make cast return error if cast binary literal to another …
xiongjiwei Dec 13, 2021
68118f1
*: update tikv client (#30670)
Yisaer Dec 13, 2021
d8a48d9
*: update sysutil in go.mod to fix panic when search log (#30523)
crazycs520 Dec 13, 2021
12e2288
topsql: shouldn't evict the SQL meta, since the evicted SQL can be ap…
crazycs520 Dec 13, 2021
b876788
testify: migrate test-infra to testify for analyze_test.go (#30640)
znhh6018 Dec 13, 2021
5494d06
fix CheckGoroutineExists,still bugs
znhh6018 Dec 13, 2021
8475adf
Merge branch 'fix_distsql_test' of github.com:znhh6018/tidb into fix_…
znhh6018 Dec 13, 2021
b626745
util: replace compareDatum by compare, point part (#30575)
wjhuang2016 Dec 13, 2021
b4df7ca
test: make all the tests run in serial (#30692)
tangenta Dec 14, 2021
ac25e9f
statistics: add mutex for Handle.globalMap and Handle.feedback (#30550)
xuyifangreeneyes Dec 14, 2021
a8ad203
executor: fix regular expression in json so that it could match ident…
znhh6018 Dec 14, 2021
dd7f71f
util/testkit/testkit.go: fix typo (#30638)
eddiearc Dec 14, 2021
c30d34f
planner: Introduce a new global variable to control the historical st…
An-DJ Dec 14, 2021
e9b1fb8
topsql: introduce datasink interface (#30662)
zhongzc Dec 14, 2021
2f42f7c
planner: unify the argument of stats functions to use SessionCtx inst…
qw4990 Dec 14, 2021
5d463f3
metrics: fix the Max SafeTS Gap metrics (#30689)
JmPotato Dec 14, 2021
4b48e55
lightning: Add source dir existence check for s3 (#30674)
glorv Dec 14, 2021
950a274
golangci-lint: support durationcheck (#30027)
wangggong Dec 14, 2021
6c0fcea
executor: fix data race on IndexHashJoin.cancelFunc (#30701)
XuHuaiyu Dec 14, 2021
813f6ef
sessionctx/variable: change tidb_store_limit to global only (#30522)
morgo Dec 15, 2021
0d0805d
statistics: remove reassignment of Handle.pool in NewHandle (#30675)
xuyifangreeneyes Dec 15, 2021
93b0a58
br: fix some unstable unit test cases. (#30716)
3pointer Dec 15, 2021
22418cd
bindinfo: fix the comment typo (#30616)
zhangjinpeng87 Dec 15, 2021
04a9618
server: support decoding prepared string args to character_set_client…
tangenta Dec 15, 2021
3fe9263
expression: fix enum type join binary get wrong result (#30445)
sylzd Dec 15, 2021
64f7309
cmd/explaintest: fix wrong result comparison for explain test (#30717)
xuyifangreeneyes Dec 15, 2021
87dbcc2
metrics: fix copr-cache metrics (#30712)
jackysp Dec 15, 2021
2e79433
test: merge executor's serial tests to other tests (#30711)
tangenta Dec 15, 2021
0c7528a
statistics: avoid deadlock when create/drop extended stats and analyz…
time-and-fate Dec 15, 2021
d660e48
sessionctx: fix the value of analyze_version when upgrading 4.x to 5.…
winoros Dec 15, 2021
05b9960
server: disable socket listener for `basicHTTPHandlerTestSuite` (#30680)
bb7133 Dec 16, 2021
af259fa
planner: support the plan cache aware of bindings (#30169)
Reminiscent Dec 16, 2021
5d62c2a
planner: fix early set of plan's statisticsTable (#30754)
chrysan Dec 16, 2021
6eb11b3
*: implement renew write lock lease for cached table (#30206)
tiancaiamao Dec 16, 2021
bb8774b
*: Modify placement rule index to reserve some indexes for future wor…
lcwangchao Dec 16, 2021
8cf847a
executor: add an unit test case for unreasonable invoking Close (#30696)
XuHuaiyu Dec 16, 2021
86ed4c4
planner: fix wrong subquery's coercibility (#30750)
wjhuang2016 Dec 16, 2021
4069b10
executor: add more testcases for index merge (#30497)
guo-shaoge Dec 16, 2021
eed16a6
server: add grpc server config for a suitable behavior (#30774)
zhongzc Dec 16, 2021
43caa02
config, charset: make charset config not affected by collation config…
xiongjiwei Dec 16, 2021
5eac82b
lightning: emit tidb log by change FilterCore to only allow matched p…
glorv Dec 16, 2021
d208b62
topsql: a centralized place to generate tipb report data (#30781)
zhongzc Dec 16, 2021
fa10cd1
planner: add trace for partition pruning (#30546)
Yisaer Dec 16, 2021
ae5638c
planner: refine collation handling for between (#30793)
wjhuang2016 Dec 16, 2021
1e5e869
test: merge serial tests in bindinfo, expression, parser and statisti…
tangenta Dec 16, 2021
83af272
br: update log description for split check (#30763)
3pointer Dec 16, 2021
daf525a
*: replace compareDatum by compare, range part (#30710)
wjhuang2016 Dec 16, 2021
ad740a6
*: placement policy ref will be converted to direct options when reco…
lcwangchao Dec 16, 2021
c75ea85
ddl: handle the incorrect number of placement followers (#30715)
sylzd Dec 16, 2021
a6fc5c6
ddl: revert "ddl: remove unnecessary locking when adding an index" (#…
wjhuang2016 Dec 16, 2021
d0fc70e
br/pkg/task: migrate test-infra to testify (#30605)
tisonkun Dec 17, 2021
8e11e03
*: fix the flen type datetime for union/case-when/control-funcs (#30588)
bestwoody Dec 17, 2021
321d307
types, util: clean up compareDatum (#30815)
wjhuang2016 Dec 17, 2021
1cf2a6d
ddl: add helper function to set and query TiFlash's sync status (#30473)
CalvinNeo Dec 17, 2021
93f21b9
dumpling: fix more dumpling log level query template (#30176)
lichunzhu Dec 17, 2021
dd95dd6
parser: support `admin flush plan_cache` (#30747)
Reminiscent Dec 17, 2021
c0888f5
topsql: support multiple datasinks (#30808)
zhongzc Dec 17, 2021
778e188
br: update permission, so tikv can write to folder when backup to loc…
fengou1 Dec 17, 2021
866c551
session: fix bootstrap to only persist global variables (#30593)
morgo Dec 19, 2021
1721706
docs/design: update collation compatibility issues in charsets doc (#…
zimulala Dec 19, 2021
24d970f
executor: improve SET sysvar=DEFAULT handling (#29680)
morgo Dec 19, 2021
e1fb2f5
br: add error handling for group context cancel when restore file is …
fengou1 Dec 20, 2021
e3c56b7
executor: buildWindow cannot call typeInfer twice (#30773)
fzhedu Dec 20, 2021
ab35db1
*: refactor encoding and uniform usages (#30288)
tangenta Dec 20, 2021
9220700
lightning: optimize region split check logic (#30428)
glorv Dec 20, 2021
c44630e
br: ignore mock directory when gcov in br (#30586)
joccau Dec 20, 2021
b9d9f19
*: forbid set tiflash replica count for a placement table (#30844)
lcwangchao Dec 20, 2021
23c71f1
execute: don't transform charset in internal sql (#30843)
Defined2014 Dec 20, 2021
b27a2d7
planner: update PlanBuilder.windowSpecs when building subquery (#30878)
xuyifangreeneyes Dec 20, 2021
b09c63b
br: fix S3 backup endpoint suffix (#30530)
tongtongyin Dec 20, 2021
eb6c89d
lightning: make pre-check output message clearer (#30439)
glorv Dec 20, 2021
87ab28e
expression: wrap to_binary and from_binary for cast function's argume…
xiongjiwei Dec 20, 2021
66d7673
executor: fix bug when using IndexMerge in transaction (#30719)
guo-shaoge Dec 21, 2021
cbe7492
ddl: migrate test-infra to testify for ddl/foreign_key_test.go (#30853)
Mini256 Dec 21, 2021
f1e5877
expression: fix wrong retType for reverse function (#30829)
wjhuang2016 Dec 21, 2021
06c1e8c
planner: support trace topn push down (#30800)
Yisaer Dec 21, 2021
77b4e40
github: add issue requirement to pull request template (#30817)
zhangyangyu Dec 21, 2021
fe1aaf2
topsql: introduce stmtstats and sql execution count (#30277)
mornyx Dec 21, 2021
a8a858b
topsql: add pubsub datasink (#30860)
zhongzc Dec 21, 2021
2b7ce8e
executor: fix the incorrect untouch used in optimistic transactions (…
cfzjywxk Dec 21, 2021
55a38cb
expression, cmd: let crc32() support gbk (#30900)
Defined2014 Dec 21, 2021
feee7c2
server: Add uptime status var and statistics (#29790)
dveeden Dec 21, 2021
e12342b
br: error log optimization (#29640)
fengou1 Dec 21, 2021
416617e
planner: fix wrong collation when rewrite in condition (#30492)
wjhuang2016 Dec 21, 2021
63d23f8
planner: add extractor for tikv_region_peers (#30656)
IcePigZDB Dec 21, 2021
3934157
lightning: add back table empty check and add a switch config (#30887)
glorv Dec 22, 2021
3bd732f
br: improve backoff unit test (#30892)
fengou1 Dec 22, 2021
529ce88
*: add TxnManager to manage txn in session (#30574)
lcwangchao Dec 22, 2021
46e67db
Makefile: add `t.Parallel` check to ensure tests are run in serial (#…
tangenta Dec 22, 2021
9d1e29d
placement: remove isolationlevel (#30859)
xhebox Dec 22, 2021
beb5451
planner: revise the optimize trace output (#30882)
Yisaer Dec 22, 2021
9063d3b
table: set the datum collation correctly in CastValue() (#30931)
tangenta Dec 22, 2021
1f6d2dd
*: Use TxnManager.GetTxnInfoSchema() to get the txn infoschema (#30934)
lcwangchao Dec 22, 2021
d543b60
parser: add IsValid() to Encoding to speed up string validation for U…
tangenta Dec 22, 2021
713e699
planner: rename pstmtPlanCacheXX to PlanCacheXX (#30909)
Reminiscent Dec 22, 2021
2fb260f
table/tables: make CI TestCacheTableBasicReadAndWrite more stable (#3…
tiancaiamao Dec 22, 2021
efb5330
restore: use new ScatterRegions API (#30899)
YuJuncen Dec 22, 2021
b53f349
*: when placement conflicts with tiflash, cancel the job (#30945)
lcwangchao Dec 22, 2021
ec55c38
Makefile,tools: make CI great again! (#30828)
tiancaiamao Dec 23, 2021
dfc25ff
br/pkg/membuf: remove global buffer pool (#29934)
sleepymole Dec 23, 2021
b9eb9f6
ddl: add format error for incorrect dict syntax in the placement rule…
hawkingrei Dec 23, 2021
7121bf0
planner: fix index merge plan when expr cannot be pushed to tikv (#30…
guo-shaoge Dec 23, 2021
d2ed2ae
executor: display 'show create table' and INFOSCHEMA for cached table…
tiancaiamao Dec 23, 2021
693946b
br: extend the timeout for scan region since 3 seconds is not enough …
fengou1 Dec 23, 2021
0d899cd
planner: remove bindSQL from planCacheKey to planCacheValue (#30916)
Reminiscent Dec 23, 2021
df58e6c
execution: refine precision of cast as decimal in agg func (#30805)
dragonly Dec 23, 2021
dfaabf4
*: fix data race in the tikv_client (#30964)
hawkingrei Dec 23, 2021
586eed9
ddl: migrate test-infra to testify for ddl/db_partition_test.go (#30952)
MiaoMiaoGarden Dec 23, 2021
e24493f
planner: fix `AccessPath.TableFilters` got modified unexpectedly (#30…
time-and-fate Dec 23, 2021
4dc385c
test: merge serial tests in ddl, infoschema, session, store, table, t…
tangenta Dec 23, 2021
404895c
executor: fix the returned field count of the prepare statement (#30981)
tiancaiamao Dec 23, 2021
6e6db1f
binlog: allow multiple ddl targets (#30904)
hicqu Dec 24, 2021
30c5f5b
planner: trace predicate push down (#30902)
Yisaer Dec 24, 2021
93d28b9
placement: give default 2 followers for non-sugar syntax (#31000)
xhebox Dec 24, 2021
42cf333
flatten the json output (#30905)
Yisaer Dec 24, 2021
3de1384
test: control log level with environment variables (#30871)
tangenta Dec 24, 2021
ab821eb
planner: add usage of paging copr in optimizer (#30536)
you06 Dec 24, 2021
9ad0096
test: merge serial tests in cmd, planner, server, util (#31003)
tangenta Dec 24, 2021
76aae0d
planner: change predicateColumnCollector to columnStatsUsageCollector…
xuyifangreeneyes Dec 25, 2021
c57e629
migrate test-infra to testify for distsql_test.go #28574
znhh6018 Dec 12, 2021
a0702b2
optimize dom
znhh6018 Dec 12, 2021
7ee2583
fix CheckGoroutineExists,still bugs
znhh6018 Dec 13, 2021
fbf67aa
remove t.parallel() at distsql_test.go:line 373,revert to origin state
znhh6018 Dec 25, 2021
dc8c2bf
a
znhh6018 Dec 25, 2021
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
194 changes: 123 additions & 71 deletions executor/distsql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,26 @@ import (
"math/rand"
"runtime/pprof"
"strings"
"testing"
"time"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/domain"
"github.com/pingcap/tidb/executor"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/parser/model"
"github.com/pingcap/tidb/session"
"github.com/pingcap/tidb/store/copr"
"github.com/pingcap/tidb/store/mockstore"
"github.com/pingcap/tidb/table/tables"
"github.com/pingcap/tidb/tablecodec"
"github.com/pingcap/tidb/testkit"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/israce"
"github.com/pingcap/tidb/util/mock"
"github.com/pingcap/tidb/util/testkit"
"github.com/stretchr/testify/require"
"github.com/tikv/client-go/v2/testutils"
)

// nolint:unused
func checkGoroutineExists(keyword string) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can remove because no one uses it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean removing the checkGoroutineExists function ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

[2021-12-12T12:11:56.974Z] executor/distsql_test.go:43:6: func `checkGoroutineExists` is unused (unused)

[2021-12-12T12:11:56.974Z] func checkGoroutineExists(keyword string) bool {

[2021-12-12T12:11:56.974Z]      ^

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
I found checkGoroutineExists is called in line 123...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know.

func checkGoroutineExists(keyword string) bool {

there is the same function.

Copy link
Member

@hawkingrei hawkingrei Dec 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to delete executor/distsql_test.go:43:6 checkGoroutineExists or checkGoroutineExists in tidb/executor/seqtest/seq_executor_serial_test.go?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make checkGoroutineExists public and delete the redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay , let me try

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package name executor_test can be replaced by executor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did as follows,
1.make checkGoroutineExists public in tidb/executor/seqtest/seq_executor_serial_test.go
2.package name executor_test replaced by executor in tidb/executor/seqtest/seq_executor_serial_test.go
3.remove checkGoroutineExists in executor/distsql_test.go , use executor.CheckGoroutineExists instead, it prompted CheckGoroutineExists not declared by executor
how could I solve this...

buf := new(bytes.Buffer)
profile := pprof.Lookup("goroutine")
Expand All @@ -49,13 +52,21 @@ func checkGoroutineExists(keyword string) bool {
return strings.Contains(str, keyword)
}

func (s *testSuite3) TestCopClientSend(c *C) {
c.Skip("not stable")
if _, ok := s.store.GetClient().(*copr.CopClient); !ok {
func TestCopClientSend(t *testing.T) {
t.Parallel()
t.Skip("not stable")
var cluster testutils.Cluster
store, clean := testkit.CreateMockStore(t, mockstore.WithClusterInspector(func(c testutils.Cluster) {
mockstore.BootstrapWithSingleStore(c)
cluster = c
}))
defer clean()
if _, ok := store.GetClient().(*copr.CopClient); !ok {
// Make sure the store is tikv store.
return
}
tk := testkit.NewTestKit(c, s.store)
tk := testkit.NewTestKit(t, store)

tk.MustExec("use test")
tk.MustExec("create table copclient (id int primary key)")

Expand All @@ -67,53 +78,53 @@ func (s *testSuite3) TestCopClientSend(c *C) {
tk.MustExec("insert copclient values " + strings.Join(values, ","))

// Get table ID for split.
dom := domain.GetDomain(tk.Se)
dom := domain.GetDomain(tk.Session())
is := dom.InfoSchema()
tbl, err := is.TableByName(model.NewCIStr("test"), model.NewCIStr("copclient"))
c.Assert(err, IsNil)
require.NoError(t, err)
tblID := tbl.Meta().ID

// Split the table.
tableStart := tablecodec.GenTableRecordPrefix(tblID)
s.cluster.SplitKeys(tableStart, tableStart.PrefixNext(), 100)
cluster.SplitKeys(tableStart, tableStart.PrefixNext(), 100)

ctx := context.Background()
// Send coprocessor request when the table split.
rs, err := tk.Exec("select sum(id) from copclient")
c.Assert(err, IsNil)
require.NoError(t, err)
req := rs.NewChunk(nil)
err = rs.Next(ctx, req)
c.Assert(err, IsNil)
c.Assert(req.GetRow(0).GetMyDecimal(0).String(), Equals, "499500")
c.Assert(rs.Close(), IsNil)
require.NoError(t, err)
require.Equal(t, "499500", req.GetRow(0).GetMyDecimal(0).String())
require.NoError(t, rs.Close())

// Split one region.
key := tablecodec.EncodeRowKeyWithHandle(tblID, kv.IntHandle(500))
region, _ := s.cluster.GetRegionByKey(key)
peerID := s.cluster.AllocID()
s.cluster.Split(region.GetId(), s.cluster.AllocID(), key, []uint64{peerID}, peerID)
region, _ := cluster.GetRegionByKey(key)
peerID := cluster.AllocID()
cluster.Split(region.GetId(), cluster.AllocID(), key, []uint64{peerID}, peerID)

// Check again.
rs, err = tk.Exec("select sum(id) from copclient")
c.Assert(err, IsNil)
require.NoError(t, err)
req = rs.NewChunk(nil)
err = rs.Next(ctx, req)
c.Assert(err, IsNil)
c.Assert(req.GetRow(0).GetMyDecimal(0).String(), Equals, "499500")
c.Assert(rs.Close(), IsNil)
require.NoError(t, err)
require.Equal(t, "499500", req.GetRow(0).GetMyDecimal(0).String())
require.NoError(t, rs.Close())

// Check there is no goroutine leak.
rs, err = tk.Exec("select * from copclient order by id")
c.Assert(err, IsNil)
require.NoError(t, err)
req = rs.NewChunk(nil)
err = rs.Next(ctx, req)
c.Assert(err, IsNil)
c.Assert(rs.Close(), IsNil)
require.NoError(t, err)
require.NoError(t, rs.Close())
keyword := "(*copIterator).work"
c.Check(checkGoroutineExists(keyword), IsFalse)
require.False(t, checkGoroutineExists(keyword))
}

func (s *testSuite3) TestGetLackHandles(c *C) {
func TestGetLackHandles(t *testing.T) {
expectedHandles := []kv.Handle{kv.IntHandle(1), kv.IntHandle(2), kv.IntHandle(3), kv.IntHandle(4),
kv.IntHandle(5), kv.IntHandle(6), kv.IntHandle(7), kv.IntHandle(8), kv.IntHandle(9), kv.IntHandle(10)}
handlesMap := kv.NewHandleMap()
Expand All @@ -124,8 +135,8 @@ func (s *testSuite3) TestGetLackHandles(c *C) {
// expected handles 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
// obtained handles 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
diffHandles := executor.GetLackHandles(expectedHandles, handlesMap)
c.Assert(diffHandles, HasLen, 0)
c.Assert(handlesMap.Len(), Equals, 0)
require.Len(t, diffHandles, 0)
require.Equal(t, 0, handlesMap.Len())

// expected handles 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
// obtained handles 2, 3, 4, 6, 7, 8, 9
Expand All @@ -136,19 +147,27 @@ func (s *testSuite3) TestGetLackHandles(c *C) {
handlesMap.Set(kv.IntHandle(5), true)
handlesMap.Set(kv.IntHandle(10), true)
diffHandles = executor.GetLackHandles(expectedHandles, handlesMap)
c.Assert(retHandles, DeepEquals, diffHandles)
require.Equal(t, diffHandles, retHandles) // deep equal
}

func (s *testSuite3) TestBigIntPK(c *C) {
tk := testkit.NewTestKit(c, s.store)
func TestBigIntPK(t *testing.T) {
t.Parallel()
store, clean := testkit.CreateMockStore(t)
defer clean()
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.MustQuery("select * from t use index(idx) order by a").Check(testkit.Rows("1 1 1", "9223372036854775807 2 2"))
}

func (s *testSuite3) TestCorColToRanges(c *C) {
tk := testkit.NewTestKit(c, s.store)
func TestCorColToRanges(t *testing.T) {
t.Parallel()
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)

tk.MustExec("use test")
tk.MustExec("set sql_mode='STRICT_TRANS_TABLES'") // disable only-full-group-by
tk.MustExec("drop table if exists t")
Expand All @@ -163,8 +182,12 @@ func (s *testSuite3) TestCorColToRanges(c *C) {
tk.MustQuery("select t.c in (select count(*) from t s use index(idx), t t1 where s.b = t.a and s.c = t1.a) from t order by 1 desc").Check(testkit.Rows("1", "0", "0", "0", "0", "0", "0", "0", "0"))
}

func (s *testSuiteP1) TestUniqueKeyNullValueSelect(c *C) {
tk := testkit.NewTestKit(c, s.store)
func TestUniqueKeyNullValueSelect(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")
// test null in unique-key
Expand All @@ -189,8 +212,12 @@ func (s *testSuiteP1) TestUniqueKeyNullValueSelect(c *C) {
}

// TestIssue10178 contains tests for https://github.com/pingcap/tidb/issues/10178 .
func (s *testSuite3) TestIssue10178(c *C) {
tk := testkit.NewTestKit(c, s.store)
func TestIssue10178(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 bigint unsigned primary key)")
Expand All @@ -200,58 +227,67 @@ func (s *testSuite3) TestIssue10178(c *C) {
tk.MustQuery("select * from t where a < 9223372036854775808").Check(testkit.Rows("9223372036854775807"))
}

func (s *testSuite3) TestInconsistentIndex(c *C) {
tk := testkit.NewTestKit(c, s.store)
func TestInconsistentIndex(t *testing.T) {
t.Parallel()
store, clean := testkit.CreateMockStore(t)
defer clean()
dom, err := session.BootstrapSession(store)
znhh6018 marked this conversation as resolved.
Show resolved Hide resolved
require.NoError(t, err)
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_a(a))")
is := s.domain.InfoSchema()
is := dom.InfoSchema()
tbl, err := is.TableByName(model.NewCIStr("test"), model.NewCIStr("t"))
c.Assert(err, IsNil)
require.NoError(t, err)
idx := tbl.Meta().FindIndexByName("idx_a")
idxOp := tables.NewIndex(tbl.Meta().ID, tbl.Meta(), idx)
ctx := mock.NewContext()
ctx.Store = s.store
ctx.Store = store

for i := 0; i < 10; i++ {
tk.MustExec(fmt.Sprintf("insert into t values (%d, %d)", i+10, i))
c.Assert(tk.QueryToErr("select * from t where a>=0"), IsNil)
require.NoError(t, tk.QueryToErr("select * from t where a>=0"))
}

for i := 0; i < 10; i++ {
tk.MustExec(fmt.Sprintf("update t set a=%d where a=%d", i, i+10))
c.Assert(tk.QueryToErr("select * from t where a>=0"), IsNil)
require.NoError(t, tk.QueryToErr("select * from t where a>=0"))
}

for i := 0; i < 10; i++ {
txn, err := s.store.Begin()
c.Assert(err, IsNil)
txn, err := store.Begin()
require.NoError(t, err)
_, err = idxOp.Create(ctx, txn, types.MakeDatums(i+10), kv.IntHandle(100+i), nil)
c.Assert(err, IsNil)
require.NoError(t, err)
err = txn.Commit(context.Background())
c.Assert(err, IsNil)
require.NoError(t, err)

err = tk.QueryToErr("select * from t use index(idx_a) where a >= 0")
c.Assert(err.Error(), Equals, fmt.Sprintf("inconsistent index idx_a handle count %d isn't equal to value count 10", i+11))

require.Equal(t, fmt.Sprintf("inconsistent index idx_a handle count %d isn't equal to value count 10", i+11), err.Error())
// if has other conditions, the inconsistent index check doesn't work.
err = tk.QueryToErr("select * from t where a>=0 and b<10")
c.Assert(err, IsNil)
require.NoError(t, err)
}

// fix inconsistent problem to pass CI
for i := 0; i < 10; i++ {
txn, err := s.store.Begin()
c.Assert(err, IsNil)
txn, err := store.Begin()
require.NoError(t, err)
err = idxOp.Delete(ctx.GetSessionVars().StmtCtx, txn, types.MakeDatums(i+10), kv.IntHandle(100+i))
c.Assert(err, IsNil)
require.NoError(t, err)
err = txn.Commit(context.Background())
c.Assert(err, IsNil)
require.NoError(t, err)
}
}

func (s *testSuite3) TestPushLimitDownIndexLookUpReader(c *C) {
tk := testkit.NewTestKit(c, s.store)
func TestPushLimitDownIndexLookUpReader(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 tbl")
tk.MustExec("create table tbl(a int, b int, c int, key idx_b_c(b,c))")
Expand All @@ -265,8 +301,12 @@ func (s *testSuite3) TestPushLimitDownIndexLookUpReader(c *C) {
tk.MustQuery("select * from tbl use index(idx_b_c) where b > 1 and c > 1 limit 2,1").Check(testkit.Rows("4 4 4"))
}

func (s *testSuite3) TestPartitionTableIndexLookUpReader(c *C) {
tk := testkit.NewTestKit(c, s.store)
func TestPartitionTableIndexLookUpReader(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, key(a))
Expand All @@ -289,11 +329,15 @@ func (s *testSuite3) TestPartitionTableIndexLookUpReader(c *C) {
tk.MustQuery("select * from t where a>=1 and a<15 order by a limit 3").Check(testkit.Rows("1 1", "2 2", "11 11"))
}

func (s *testSuite3) TestPartitionTableRandomlyIndexLookUpReader(c *C) {
func TestPartitionTableRandomlyIndexLookUpReader(t *testing.T) {
if israce.RaceEnabled {
c.Skip("exhaustive types test, skip race test")
t.Skip("exhaustive types test, skip race test")
}
tk := testkit.NewTestKit(c, s.store)
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, key(a))
Expand Down Expand Up @@ -326,7 +370,7 @@ func (s *testSuite3) TestPartitionTableRandomlyIndexLookUpReader(c *C) {
}
}

func (s *testSuite3) TestIndexLookUpStats(c *C) {
func TestIndexLookUpStats(t *testing.T) {
stats := &executor.IndexLookUpRunTimeStats{
FetchHandleTotal: int64(5 * time.Second),
FetchHandle: int64(2 * time.Second),
Expand All @@ -335,14 +379,18 @@ func (s *testSuite3) TestIndexLookUpStats(c *C) {
TableTaskNum: 2,
Concurrency: 1,
}
c.Assert(stats.String(), Equals, "index_task: {total_time: 5s, fetch_handle: 2s, build: 1s, wait: 2s}, table_task: {total_time: 2s, num: 2, concurrency: 1}")
c.Assert(stats.String(), Equals, stats.Clone().String())
require.Equal(t, "index_task: {total_time: 5s, fetch_handle: 2s, build: 1s, wait: 2s}, table_task: {total_time: 2s, num: 2, concurrency: 1}", stats.String())
require.Equal(t, stats.Clone().String(), stats.String())
stats.Merge(stats.Clone())
c.Assert(stats.String(), Equals, "index_task: {total_time: 10s, fetch_handle: 4s, build: 2s, wait: 4s}, table_task: {total_time: 4s, num: 4, concurrency: 2}")
require.Equal(t, "index_task: {total_time: 10s, fetch_handle: 4s, build: 2s, wait: 4s}, table_task: {total_time: 4s, num: 4, concurrency: 2}", stats.String())
}

func (s *testSuite3) TestIndexLookUpGetResultChunk(c *C) {
tk := testkit.NewTestKit(c, s.store)
func TestIndexLookUpGetResultChunk(t *testing.T) {
t.Parallel()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t.Parallel() need to be removed. it is a decision that we have made recently.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry , not familiar with some git operations , things seemed went bad , just close and create a new PR............

store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)

tk.MustExec("use test")
tk.MustExec("drop table if exists tbl")
tk.MustExec("create table tbl(a int, b int, c int, key idx_a(a))")
Expand All @@ -353,11 +401,15 @@ func (s *testSuite3) TestIndexLookUpGetResultChunk(c *C) {
tk.MustQuery("select * from tbl use index(idx_a) where a > 10 order by a asc limit 4,1").Check(testkit.Rows("15 15 15"))
}

func (s *testSuite3) TestPartitionTableIndexJoinIndexLookUp(c *C) {
func TestPartitionTableIndexJoinIndexLookUp(t *testing.T) {
if israce.RaceEnabled {
c.Skip("exhaustive types test, skip race test")
t.Skip("exhaustive types test, skip race test")
}
tk := testkit.NewTestKit(c, s.store)
t.Parallel()
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)

tk.MustExec("use test")
tk.MustExec("set @@tidb_partition_prune_mode='dynamic'")
tk.MustExec(`create table t (a int, b int, key(a)) partition by hash(a) partitions 4`)
Expand Down