fix: [skip e2e] Dedup available ports and retry for integration setup (#31902)

See also #31901

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2024-04-08 10:35:17 +08:00 committed by GitHub
parent 019d76c79d
commit 1c2ae59ece
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -51,6 +51,7 @@ import (
"github.com/milvus-io/milvus/pkg/log" "github.com/milvus-io/milvus/pkg/log"
"github.com/milvus-io/milvus/pkg/util/etcd" "github.com/milvus-io/milvus/pkg/util/etcd"
"github.com/milvus-io/milvus/pkg/util/paramtable" "github.com/milvus-io/milvus/pkg/util/paramtable"
"github.com/milvus-io/milvus/pkg/util/typeutil"
) )
var params *paramtable.ComponentParam = paramtable.Get() var params *paramtable.ComponentParam = paramtable.Get()
@ -427,15 +428,15 @@ func (cluster *MiniClusterV2) GetFactory() dependency.Factory {
} }
func (cluster *MiniClusterV2) GetAvailablePorts(n int) ([]int, error) { func (cluster *MiniClusterV2) GetAvailablePorts(n int) ([]int, error) {
ports := make([]int, n) ports := typeutil.NewSet[int]()
for i := range ports { for ports.Len() < n {
port, err := cluster.GetAvailablePort() port, err := cluster.GetAvailablePort()
if err != nil { if err != nil {
return nil, err return nil, err
} }
ports[i] = port ports.Insert(port)
} }
return ports, nil return ports.Collect(), nil
} }
func (cluster *MiniClusterV2) GetAvailablePort() (int, error) { func (cluster *MiniClusterV2) GetAvailablePort() (int, error) {