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

Cherry-pick from master
pr: #36302
Resolves: #36301

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2024-09-20 13:03:12 +08:00 committed by GitHub
parent eb1602a374
commit 210adbaffc
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() {