Skip to content

Commit f024ff5

Browse files
committed
Adding nodepool funcs, updating machine pool funcs
1 parent 988ba1d commit f024ff5

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

support/environment.go

Lines changed: 3 additions & 3 deletions
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 {

support/ocm.go

Lines changed: 21 additions & 5 deletions
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 {
@@ -69,10 +69,26 @@ func GetMachinePools(t Test, connection *ocmsdk.Connection) []*cmv1.MachinePool
6969
return MachinePools(t, connection)(t)
7070
}
7171

72-
func MachinePoolId(machinePool *cmv1.MachinePool) string {
73-
return machinePool.ID()
74-
}
75-
7672
func MachinePoolLabels(machinePool *cmv1.MachinePool) map[string]string {
7773
return machinePool.Labels()
7874
}
75+
76+
func NodePools(t Test, connection *ocmsdk.Connection) func(g gomega.Gomega) []*cmv1.NodePool {
77+
clusterId, found := GetClusterId()
78+
t.Expect(found).To(gomega.BeTrue(), "Cluster id not found, please configure environment properly")
79+
80+
return func(g gomega.Gomega) []*cmv1.NodePool {
81+
nodePoolsListResponse, err := connection.ClustersMgmt().V1().Clusters().Cluster(clusterId).NodePools().List().Send()
82+
g.Expect(err).NotTo(gomega.HaveOccurred())
83+
return nodePoolsListResponse.Items().Slice()
84+
}
85+
}
86+
87+
func GetNodePools(t Test, connection *ocmsdk.Connection) []*cmv1.NodePool {
88+
t.T().Helper()
89+
return NodePools(t, connection)(t)
90+
}
91+
92+
func NodePoolLabels(nodePool *cmv1.NodePool) map[string]string {
93+
return nodePool.Labels()
94+
}

0 commit comments

Comments
 (0)