Fix data race in datacoord test (#9936)

issue: #9935
Signed-off-by: sunby <bingyi.sun@zilliz.com>
This commit is contained in:
sunby 2021-10-15 15:56:35 +08:00 committed by GitHub
parent 2cfdf22897
commit bfc9e47e2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -573,7 +573,10 @@ func TestGetFlushedSegments(t *testing.T) {
}
func TestService_WatchServices(t *testing.T) {
svr := newTestServer(t, nil)
factory := msgstream.NewPmsFactory()
svr, err := CreateServer(context.TODO(), factory)
assert.Nil(t, err)
svr.serverLoopWg.Add(1)
ech := make(chan *sessionutil.SessionEvent)
svr.eventCh = ech
@ -596,6 +599,8 @@ func TestService_WatchServices(t *testing.T) {
flag = false
svr.eventCh = ech
ctx, cancel := context.WithCancel(context.Background())
svr.serverLoopWg.Add(1)
go func() {
svr.startWatchService(ctx)
flag = true