Skip to content

Commit

Permalink
executor: fix unstable test of topsql (#30257)
Browse files Browse the repository at this point in the history
  • Loading branch information
mornyx authored Nov 30, 2021
1 parent 8fa0cae commit 0c8614a
Showing 1 changed file with 25 additions and 29 deletions.
54 changes: 25 additions & 29 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8782,47 +8782,46 @@ func (s *testResourceTagSuite) TestResourceGroupTag(c *C) {

cases := []struct {
sql string
tagLabels []tipb.ResourceGroupTagLabel
tagLabels map[tipb.ResourceGroupTagLabel]struct{}
ignore bool
}{
{
sql: "insert into t values(1,1),(2,2),(3,3)",
tagLabels: []tipb.ResourceGroupTagLabel{
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelIndex,
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelIndex,
tagLabels: map[tipb.ResourceGroupTagLabel]struct{}{
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelIndex: {},
},
},
{
sql: "select * from t use index (idx) where a=1",
tagLabels: []tipb.ResourceGroupTagLabel{
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelIndex,
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelRow,
tagLabels: map[tipb.ResourceGroupTagLabel]struct{}{
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelRow: {},
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelIndex: {},
},
},
{
sql: "select * from t use index (idx) where a in (1,2,3)",
tagLabels: []tipb.ResourceGroupTagLabel{
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelIndex,
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelRow,
tagLabels: map[tipb.ResourceGroupTagLabel]struct{}{
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelRow: {},
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelIndex: {},
},
},
{
sql: "select * from t use index (idx) where a>1",
tagLabels: []tipb.ResourceGroupTagLabel{
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelIndex,
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelRow,
tagLabels: map[tipb.ResourceGroupTagLabel]struct{}{
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelRow: {},
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelIndex: {},
},
},
{
sql: "select * from t where b>1",
tagLabels: []tipb.ResourceGroupTagLabel{
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelRow,
tagLabels: map[tipb.ResourceGroupTagLabel]struct{}{
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelRow: {},
},
},
{
sql: "select a from t use index (idx) where a>1",
tagLabels: []tipb.ResourceGroupTagLabel{
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelIndex,
tagLabels: map[tipb.ResourceGroupTagLabel]struct{}{
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelIndex: {},
},
},
{
Expand All @@ -8831,9 +8830,9 @@ func (s *testResourceTagSuite) TestResourceGroupTag(c *C) {
},
{
sql: "insert into t values(4,4)",
tagLabels: []tipb.ResourceGroupTagLabel{
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelIndex,
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelRow,
tagLabels: map[tipb.ResourceGroupTagLabel]struct{}{
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelRow: {},
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelIndex: {},
},
},
{
Expand All @@ -8842,15 +8841,14 @@ func (s *testResourceTagSuite) TestResourceGroupTag(c *C) {
},
{
sql: "update t set a=5,b=5 where a=5",
tagLabels: []tipb.ResourceGroupTagLabel{
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelIndex,
tagLabels: map[tipb.ResourceGroupTagLabel]struct{}{
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelIndex: {},
},
},
{
sql: "replace into t values(6,6)",
tagLabels: []tipb.ResourceGroupTagLabel{
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelIndex,
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelIndex,
tagLabels: map[tipb.ResourceGroupTagLabel]struct{}{
tipb.ResourceGroupTagLabel_ResourceGroupTagLabelIndex: {},
},
},
}
Expand All @@ -8874,10 +8872,8 @@ func (s *testResourceTagSuite) TestResourceGroupTag(c *C) {
}
c.Assert(sqlDigest.String(), Equals, expectSQLDigest.String(), commentf)
c.Assert(planDigest.String(), Equals, expectPlanDigest.String())
if len(ca.tagLabels) > 0 {
c.Assert(tagLabel, Equals, ca.tagLabels[0])
ca.tagLabels = ca.tagLabels[1:] // next label
}
_, ok := ca.tagLabels[tagLabel]
c.Assert(ok, Equals, true)
checkCnt++
}

Expand Down

0 comments on commit 0c8614a

Please sign in to comment.