Skip to content

Commit

Permalink
test: fix unstable TestIssue20658 (pingcap#24425) (pingcap#24466)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-srebot authored Jun 2, 2021
1 parent f610f8b commit 0ecd6bd
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions executor/aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,7 @@ func (s *testSuiteAgg) TestIssue20658(c *C) {
for _, sql := range sqls {
var expected [][]interface{}
for _, con := range concurrencies {
comment := Commentf("sql: %s; concurrency: %d", sql, con)
tk.MustExec(fmt.Sprintf("set @@tidb_streamagg_concurrency=%d;", con))
if con == 1 {
expected = tk.MustQuery(sql).Sort().Rows()
Expand All @@ -1320,16 +1321,20 @@ func (s *testSuiteAgg) TestIssue20658(c *C) {
break
}
}
c.Assert(ok, Equals, true)
c.Assert(ok, Equals, true, comment)
rows := tk.MustQuery(sql).Sort().Rows()

c.Assert(len(rows), Equals, len(expected))
c.Assert(len(rows), Equals, len(expected), comment)
for i := range rows {
v1, err := strconv.ParseFloat(rows[i][0].(string), 64)
c.Assert(err, IsNil)
v2, err := strconv.ParseFloat(expected[i][0].(string), 64)
c.Assert(err, IsNil)
c.Assert(math.Abs(v1-v2), Less, 1e-3)
rowStr, expStr := rows[i][0].(string), expected[i][0].(string)
if rowStr == "<nil>" && expStr == "<nil>" {
continue
}
v1, err := strconv.ParseFloat(rowStr, 64)
c.Assert(err, IsNil, comment)
v2, err := strconv.ParseFloat(expStr, 64)
c.Assert(err, IsNil, comment)
c.Assert(math.Abs(v1-v2), Less, 1e-3, comment)
}
}
}
Expand Down

0 comments on commit 0ecd6bd

Please sign in to comment.