Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions support/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (
InstaScaleOcmSecret = "INSTASCALE_OCM_SECRET"

// Cluster ID for OSD cluster used in tests, used for testing InstaScale
OsdClusterID = "CLUSTERID"
ClusterID = "CLUSTERID"

// Type of cluster test is run on
ClusterTypeEnvVar = "CLUSTER_TYPE"
Expand Down Expand Up @@ -77,8 +77,8 @@ func GetInstascaleOcmSecret() (string, string) {
return res[0], res[1]
}

func GetOsdClusterId() (string, bool) {
return os.LookupEnv(OsdClusterID)
func GetClusterId() (string, bool) {
return os.LookupEnv(ClusterID)
}

func GetClusterType(t Test) ClusterType {
Expand Down
22 changes: 21 additions & 1 deletion support/ocm.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func buildOCMConnection(secret string) (*ocmsdk.Connection, error) {
}

func MachinePools(t Test, connection *ocmsdk.Connection) func(g gomega.Gomega) []*cmv1.MachinePool {
osdClusterId, found := GetOsdClusterId()
osdClusterId, found := GetClusterId()
t.Expect(found).To(gomega.BeTrue(), "OSD cluster id not found, please configure environment properly")

return func(g gomega.Gomega) []*cmv1.MachinePool {
Expand All @@ -76,3 +76,23 @@ func MachinePoolId(machinePool *cmv1.MachinePool) string {
func MachinePoolLabels(machinePool *cmv1.MachinePool) map[string]string {
return machinePool.Labels()
}

func NodePools(t Test, connection *ocmsdk.Connection) func(g gomega.Gomega) []*cmv1.NodePool {
clusterId, found := GetClusterId()
t.Expect(found).To(gomega.BeTrue(), "Cluster id not found, please configure environment properly")

return func(g gomega.Gomega) []*cmv1.NodePool {
nodePoolsListResponse, err := connection.ClustersMgmt().V1().Clusters().Cluster(clusterId).NodePools().List().Send()
g.Expect(err).NotTo(gomega.HaveOccurred())
return nodePoolsListResponse.Items().Slice()
}
}

func GetNodePools(t Test, connection *ocmsdk.Connection) []*cmv1.NodePool {
t.T().Helper()
return NodePools(t, connection)(t)
}

func NodePoolLabels(nodePool *cmv1.NodePool) map[string]string {
return nodePool.Labels()
}