From 1b87ec499eda656fc091cd538c32ecc4b19a29eb Mon Sep 17 00:00:00 2001 From: Benjamin Wang Date: Wed, 6 Sep 2023 08:24:31 +0100 Subject: [PATCH] test: de-flake test case TestMemberList get memberlist immediately before each time checking the members. Signed-off-by: Benjamin Wang --- tests/common/member_test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/common/member_test.go b/tests/common/member_test.go index 7bace819728..a2436055b9f 100644 --- a/tests/common/member_test.go +++ b/tests/common/member_test.go @@ -50,15 +50,18 @@ func TestMemberList(t *testing.T) { if expectNum != gotNum { t.Fatalf("number of members not equal, expect: %d, got: %d", expectNum, gotNum) } - assert.Eventually(t, func() (done bool) { + assert.Eventually(t, func() bool { + resp, err := cc.MemberList(ctx, false) + if err != nil { + t.Logf("Failed to get member list, err: %v", err) + return false + } for _, m := range resp.Members { if len(m.ClientURLs) == 0 { t.Logf("member is not started, memberId:%d, memberName:%s", m.ID, m.Name) - done = false - return done + return false } } - done = true return true }, time.Second*5, time.Millisecond*100) })