Fix data race of data node test (#22221)

Signed-off-by: aoiasd <zhicheng.yue@zilliz.com>
pull/22346/head
aoiasd 2023-02-22 10:28:26 +08:00 committed by GitHub
parent c3e8ad3629
commit 27b456dd46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 10 deletions

View File

@ -111,6 +111,7 @@ func TestDataNode(t *testing.T) {
node.chunkManager = storage.NewLocalChunkManager(storage.RootPath("/tmp/milvus_test/datanode"))
paramtable.SetNodeID(1)
defer cancel()
t.Run("Test SetRootCoord", func(t *testing.T) {
emptyDN := &DataNode{}
tests := []struct {
@ -196,19 +197,22 @@ func TestDataNode(t *testing.T) {
}{
{"fake-by-dev-rootcoord-dml-backgroundgc-1"},
{"fake-by-dev-rootcoord-dml-backgroundgc-2"},
{"fake-by-dev-rootcoord-dml-backgroundgc-3"},
{""},
{""},
}
for i, test := range testDataSyncs {
if i <= 2 {
err = node.flowgraphManager.addAndStart(node, &datapb.VchannelInfo{CollectionID: 1, ChannelName: test.dmChannelName}, nil, genTestTickler())
assert.Nil(t, err)
vchanNameCh <- test.dmChannelName
}
for _, test := range testDataSyncs {
err = node.flowgraphManager.addAndStart(node, &datapb.VchannelInfo{CollectionID: 1, ChannelName: test.dmChannelName}, nil, genTestTickler())
assert.Nil(t, err)
vchanNameCh <- test.dmChannelName
}
cancel()
assert.Eventually(t, func() bool {
for _, test := range testDataSyncs {
if node.flowgraphManager.exist(test.dmChannelName) {
return false
}
}
return true
}, 2*time.Second, 10*time.Millisecond)
})
}