Fix TestChannelMetaMockSkipBFLoad/transient_error not stable (#24928)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/24933/head
congqixia 2023-06-16 09:50:44 +08:00 committed by GitHub
parent 5e7446e65e
commit d186f35895
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -1201,16 +1201,22 @@ func (s *ChannelMetaMockSuite) TestAddSegment_SkipBFLoad() {
s.Run("transient_error", func() {
defer s.SetupTest()
ch := make(chan struct{})
counter := 0
done := func() bool {
select {
case <-ch:
return true
default:
return false
}
}
s.cm.EXPECT().MultiRead(mock.Anything, []string{"rootPath/stats/1/0/100/10001"}).Call.
Return(func(_ context.Context, arg []string) [][]byte {
if counter == 0 {
if !done() {
return nil
}
return [][]byte{}
}, func(_ context.Context, arg []string) error {
if counter == 0 {
counter++
if !done() {
return errors.New("transient error")
}
return nil