Skip to content

Commit

Permalink
stats: fix the data race in test (#7434)
Browse files Browse the repository at this point in the history
  • Loading branch information
alivxxx committed Aug 20, 2018
1 parent 7773b28 commit b1aef89
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions statistics/update_test.go
Expand Up @@ -39,10 +39,13 @@ var _ = Suite(&testStatsUpdateSuite{})
type testStatsUpdateSuite struct {
store kv.Storage
do *domain.Domain
hook logHook
}

func (s *testStatsUpdateSuite) SetUpSuite(c *C) {
testleak.BeforeTest()
// Add the hook here to avoid data race.
log.AddHook(&s.hook)
var err error
s.store, s.do, err = newStoreWithBootstrap(0)
c.Assert(err, IsNil)
Expand Down Expand Up @@ -796,11 +799,9 @@ func (s *testStatsUpdateSuite) TestLogDetailedInfo(c *C) {
},
}
log.SetLevel(log.DebugLevel)
var hook logHook
log.AddHook(&hook)
for _, t := range tests {
hook.results = ""
s.hook.results = ""
testKit.MustQuery(t.sql)
c.Assert(hook.results, Equals, t.result)
c.Assert(s.hook.results, Equals, t.result)
}
}

0 comments on commit b1aef89

Please sign in to comment.