Skip to content

Commit

Permalink
test(dm): fix one deadlock (#5795)
Browse files Browse the repository at this point in the history
close #5793
  • Loading branch information
lance6716 authored Jun 9, 2022
1 parent 94bd690 commit 275306b
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions dm/dm/master/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1896,7 +1896,6 @@ func (t *testMaster) TestOperateSource(c *check.C) {

func (t *testMaster) TestOfflineMember(c *check.C) {
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()

cfg1 := generateServerConfig(c, "dm-master-1")
cfg2 := generateServerConfig(c, "dm-master-2")
Expand All @@ -1911,15 +1910,21 @@ func (t *testMaster) TestOfflineMember(c *check.C) {

var wg sync.WaitGroup
s1 := NewServer(cfg1)
defer s1.Close()
defer func() {
cancel()
s1.Close()
}()
wg.Add(1)
go func() {
c.Assert(s1.Start(ctx), check.IsNil)
wg.Done()
}()

s2 := NewServer(cfg2)
defer s2.Close()
defer func() {
cancel()
s2.Close()
}()
wg.Add(1)
go func() {
c.Assert(s2.Start(ctx), check.IsNil)
Expand All @@ -1929,8 +1934,10 @@ func (t *testMaster) TestOfflineMember(c *check.C) {
ctx3, cancel3 := context.WithCancel(ctx)
s3 := NewServer(cfg3)
c.Assert(s3.Start(ctx3), check.IsNil)
defer s3.Close()
defer cancel3()
defer func() {
cancel3()
s3.Close()
}()

wg.Wait()

Expand Down

0 comments on commit 275306b

Please sign in to comment.