fix: Wait check node id goroutine in case of data race (#36302)

Resolves: #36301

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2024-09-19 10:41:10 +08:00 committed by GitHub
parent e013ef1908
commit c0317ce672
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -21,6 +21,7 @@ import (
"flag"
"os"
"strings"
"sync"
"time"
"github.com/stretchr/testify/suite"
@ -104,8 +105,11 @@ func (s *MiniClusterSuite) SetupTest() {
s.Require().NoError(err)
s.Cluster = c
checkWg := sync.WaitGroup{}
checkWg.Add(1)
// start mini cluster
nodeIDCheckReport := func() {
defer checkWg.Done()
timeoutCtx, cancelFunc := context.WithTimeout(ctx, 5*time.Second)
defer cancelFunc()
@ -124,6 +128,7 @@ func (s *MiniClusterSuite) SetupTest() {
}
go nodeIDCheckReport()
s.Require().NoError(s.Cluster.Start())
checkWg.Wait()
}
func (s *MiniClusterSuite) TearDownTest() {