Skip to content

Commit 016e8e0

Browse files
committed
updating machine sets functionality
1 parent a3d4eab commit 016e8e0

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

test/e2e/instascale_test.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,18 @@ func TestInstascale(t *testing.T) {
6565

6666
if machinePoolsExist {
6767
// look for machine pool with aw name - expect not to find it
68-
foundMachinePool, err := CheckMachinePools(connection, "test-instascale")
68+
foundMachinePool, err := CheckMachinePools(connection, TestName)
6969
test.Expect(err).NotTo(HaveOccurred())
7070
test.Expect(foundMachinePool).To(BeFalse())
7171
} else if nodePoolsExist {
7272
// look for node pool with aw name - expect not to find it
73-
foundNodePool, err := CheckNodePools(connection, "test-instascale")
73+
foundNodePool, err := CheckNodePools(connection, TestName)
7474
test.Expect(err).NotTo(HaveOccurred())
7575
test.Expect(foundNodePool).To(BeFalse())
7676
} else {
77-
// TODO update to foundMachineSet
78-
77+
foundMachineSet, err := CheckMachineSets(TestName)
78+
test.Expect(err).NotTo(HaveOccurred())
79+
test.Expect(foundMachineSet).To(BeFalse())
7980
}
8081

8182
// Batch Job
@@ -197,17 +198,18 @@ func TestInstascale(t *testing.T) {
197198

198199
if machinePoolsExist {
199200
// look for machine pool with aw name - expect to find it
200-
foundMachinePool, err := CheckMachinePools(connection, "test-instascale")
201+
foundMachinePool, err := CheckMachinePools(connection, TestName)
201202
test.Expect(err).NotTo(HaveOccurred())
202203
test.Expect(foundMachinePool).To(BeTrue())
203204
} else if nodePoolsExist {
204205
// look for node pool with aw name - expect to find it
205-
foundNodePool, err := CheckNodePools(connection, "test-instascale")
206+
foundNodePool, err := CheckNodePools(connection, TestName)
206207
test.Expect(err).NotTo(HaveOccurred())
207208
test.Expect(foundNodePool).To(BeTrue())
208209
} else {
209-
// TODO update to foundMachineSet
210-
210+
foundMachineSet, err := CheckMachineSets(TestName)
211+
test.Expect(err).NotTo(HaveOccurred())
212+
test.Expect(foundMachineSet).To(BeTrue())
211213
}
212214

213215
// Assert that the job has completed
@@ -230,16 +232,17 @@ func TestInstascale(t *testing.T) {
230232

231233
if machinePoolsExist {
232234
// look for machine pool with aw name - expect to find it
233-
foundMachinePool, err := CheckMachinePools(connection, "test-instascale")
235+
foundMachinePool, err := CheckMachinePools(connection, TestName)
234236
test.Expect(err).NotTo(HaveOccurred())
235237
test.Expect(foundMachinePool).To(BeFalse())
236238
} else if nodePoolsExist {
237239
// look for node pool with aw name - expect to find it
238-
foundNodePool, err := CheckNodePools(connection, "test-instascale")
240+
foundNodePool, err := CheckNodePools(connection, TestName)
239241
test.Expect(err).NotTo(HaveOccurred())
240242
test.Expect(foundNodePool).To(BeFalse())
241243
} else {
242-
// TODO update to foundMachineSet
243-
244+
foundMachineSet, err := CheckMachineSets(TestName)
245+
test.Expect(err).NotTo(HaveOccurred())
246+
test.Expect(foundMachineSet).To(BeFalse())
244247
}
245248
}

test/support/clusterpools.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ import (
99
ocmsdk "github.com/openshift-online/ocm-sdk-go"
1010
cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
1111
mapiclientset "github.com/openshift/client-go/machine/clientset/versioned"
12+
"github.com/openshift/client-go/machine/listers/machine/v1beta1"
1213
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14+
"k8s.io/apimachinery/pkg/labels"
1315
)
1416

1517
var (
1618
ClusterID string = os.Getenv("CLUSTERID")
1719
machineClient mapiclientset.Interface
20+
msLister v1beta1.MachineSetLister
21+
TestName string = "test-instascale"
1822
)
1923

2024
const (
@@ -96,3 +100,16 @@ func MachineSetsCount() (numMachineSets int, err error) {
96100

97101
return machineSetsSize, nil
98102
}
103+
104+
func CheckMachineSets(awName string) (foundMachineSet bool, err error) {
105+
machineSets, err := msLister.MachineSets("").List(labels.Everything())
106+
if err != nil {
107+
return false, fmt.Errorf("error listing machine sets, error: %v", err)
108+
}
109+
for _, machineSet := range machineSets {
110+
if strings.Contains(machineSet.Name, awName) {
111+
foundMachineSet = true
112+
}
113+
}
114+
return foundMachineSet, err
115+
}

0 commit comments

Comments
 (0)