Skip to content

Commit e7b612e

Browse files
authored
tests: fix TestEtcdClientSync (#9947)
close #8085 Signed-off-by: Ryan Leung <rleungx@gmail.com>
1 parent 4a11b99 commit e7b612e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

pkg/utils/etcdutil/etcdutil_test.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,18 @@ func TestEtcdClientSync(t *testing.T) {
187187
}
188188
}
189189

190-
_, err = RemoveEtcdMember(client1, memIDToRemove)
191-
re.NoError(err)
190+
// Use testutil.Eventually to handle potential transient errors during member removal.
191+
// The removed member will be shut down immediately, which may cause the removal RPC
192+
// to fail with "server stopped", but we verify success by checking the member list.
193+
testutil.Eventually(re, func() bool {
194+
_, err := RemoveEtcdMember(client1, memIDToRemove)
195+
if err == nil {
196+
return true
197+
}
198+
// Verify if the member was actually removed by checking the member list
199+
listResp, listErr := ListEtcdMembers(client1.Ctx(), client1)
200+
return listErr == nil && len(listResp.Members) == 1
201+
})
192202

193203
// Check the client can get the new member with the new endpoints.
194204
checkEtcdEndpointNum(re, client1, 1)

0 commit comments

Comments
 (0)