fix: Fix the unstable unit test TestReplicateManager (#28718)

/kind improvement

Signed-off-by: SimFG <bang.fu@zilliz.com>
This commit is contained in:
SimFG 2023-11-24 17:50:30 +08:00 committed by GitHub
parent 86ccb8e146
commit 089e58dfbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,7 +52,10 @@ func TestReplicateManager(t *testing.T) {
assert.Equal(t, 3, i) assert.Equal(t, 3, i)
res := resourceManager.Delete(ReplicateMsgStreamTyp, "test") res := resourceManager.Delete(ReplicateMsgStreamTyp, "test")
assert.NotNil(t, res) assert.NotNil(t, res)
time.Sleep(2 * time.Second)
assert.Eventually(t, func() bool {
return resourceManager.Delete(ReplicateMsgStreamTyp, "test") == nil
}, time.Second*4, time.Millisecond*500)
_, err = manager.GetReplicateMsgStream(context.Background(), "test") _, err = manager.GetReplicateMsgStream(context.Background(), "test")
assert.NoError(t, err) assert.NoError(t, err)
@ -61,7 +64,10 @@ func TestReplicateManager(t *testing.T) {
{ {
res := resourceManager.Delete(ReplicateMsgStreamTyp, "test") res := resourceManager.Delete(ReplicateMsgStreamTyp, "test")
assert.NotNil(t, res) assert.NotNil(t, res)
time.Sleep(2 * time.Second)
assert.Eventually(t, func() bool {
return resourceManager.Delete(ReplicateMsgStreamTyp, "test") == nil
}, time.Second*4, time.Millisecond*500)
res, err := resourceManager.Get(ReplicateMsgStreamTyp, "test", func() (resource.Resource, error) { res, err := resourceManager.Get(ReplicateMsgStreamTyp, "test", func() (resource.Resource, error) {
return resource.NewResource(resource.WithObj("str")), nil return resource.NewResource(resource.WithObj("str")), nil