Skip to content

Commit c99fa58

Browse files
committed
Adding node pool functions
1 parent 988ba1d commit c99fa58

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

Diff for: support/environment.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const (
3737
InstaScaleOcmSecret = "INSTASCALE_OCM_SECRET"
3838

3939
// Cluster ID for OSD cluster used in tests, used for testing InstaScale
40-
OsdClusterID = "CLUSTERID"
40+
ClusterID = "CLUSTERID"
4141

4242
// Type of cluster test is run on
4343
ClusterTypeEnvVar = "CLUSTER_TYPE"
@@ -77,8 +77,8 @@ func GetInstascaleOcmSecret() (string, string) {
7777
return res[0], res[1]
7878
}
7979

80-
func GetOsdClusterId() (string, bool) {
81-
return os.LookupEnv(OsdClusterID)
80+
func GetClusterId() (string, bool) {
81+
return os.LookupEnv(ClusterID)
8282
}
8383

8484
func GetClusterType(t Test) ClusterType {

Diff for: support/ocm.go

+21-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func buildOCMConnection(secret string) (*ocmsdk.Connection, error) {
5454
}
5555

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

6060
return func(g gomega.Gomega) []*cmv1.MachinePool {
@@ -76,3 +76,23 @@ func MachinePoolId(machinePool *cmv1.MachinePool) string {
7676
func MachinePoolLabels(machinePool *cmv1.MachinePool) map[string]string {
7777
return machinePool.Labels()
7878
}
79+
80+
func NodePools(t Test, connection *ocmsdk.Connection) func(g gomega.Gomega) []*cmv1.NodePool {
81+
clusterId, found := GetClusterId()
82+
t.Expect(found).To(gomega.BeTrue(), "Cluster id not found, please configure environment properly")
83+
84+
return func(g gomega.Gomega) []*cmv1.NodePool {
85+
nodePoolsListResponse, err := connection.ClustersMgmt().V1().Clusters().Cluster(clusterId).NodePools().List().Send()
86+
g.Expect(err).NotTo(gomega.HaveOccurred())
87+
return nodePoolsListResponse.Items().Slice()
88+
}
89+
}
90+
91+
func GetNodePools(t Test, connection *ocmsdk.Connection) []*cmv1.NodePool {
92+
t.T().Helper()
93+
return NodePools(t, connection)(t)
94+
}
95+
96+
func NodePoolLabels(nodePool *cmv1.NodePool) map[string]string {
97+
return nodePool.Labels()
98+
}

0 commit comments

Comments
 (0)