Skip to content

Commit 44873fa

Browse files
Merge pull request #29626 from djoshy/add-wait
NO-ISSUE: Clean up MachineConfiguration fixture apply
2 parents f2ef580 + 00b71b2 commit 44873fa

File tree

4 files changed

+16
-27
lines changed

4 files changed

+16
-27
lines changed

test/extended/machine_config/boot_image_update_agnostic.go

+4-17
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import (
1818

1919
func AllMachineSetTest(oc *exutil.CLI, fixture string) {
2020
// This fixture applies a boot image update configuration that opts in all machinesets
21-
err := oc.Run("apply").Args("-f", fixture).Execute()
22-
o.Expect(err).NotTo(o.HaveOccurred())
21+
ApplyBootImageFixture(oc, fixture)
2322

2423
// Step through all machinesets and verify boot images are reconciled correctly.
2524
machineClient, err := machineclient.NewForConfig(oc.KubeFramework().ClientConfig())
@@ -35,11 +34,7 @@ func AllMachineSetTest(oc *exutil.CLI, fixture string) {
3534
func PartialMachineSetTest(oc *exutil.CLI, fixture string) {
3635

3736
// This fixture applies a boot image update configuration that opts in any machineset with the label test=boot
38-
err := oc.Run("apply").Args("-f", fixture).Execute()
39-
o.Expect(err).NotTo(o.HaveOccurred())
40-
41-
// Ensure status accounts for the fixture that was applied
42-
WaitForMachineConfigurationStatusUpdate(oc)
37+
ApplyBootImageFixture(oc, fixture)
4338

4439
// Pick a random machineset to test
4540
machineClient, err := machineclient.NewForConfig(oc.KubeFramework().ClientConfig())
@@ -66,11 +61,7 @@ func PartialMachineSetTest(oc *exutil.CLI, fixture string) {
6661

6762
func NoneMachineSetTest(oc *exutil.CLI, fixture string) {
6863
// This fixture applies a boot image update configuration that opts in no machinesets, i.e. feature is disabled.
69-
err := oc.Run("apply").Args("-f", fixture).Execute()
70-
o.Expect(err).NotTo(o.HaveOccurred())
71-
72-
// Ensure status accounts for the fixture that was applied
73-
WaitForMachineConfigurationStatusUpdate(oc)
64+
ApplyBootImageFixture(oc, fixture)
7465

7566
// Step through all machinesets and verify boot images are reconciled correctly.
7667
machineClient, err := machineclient.NewForConfig(oc.KubeFramework().ClientConfig())
@@ -86,11 +77,7 @@ func NoneMachineSetTest(oc *exutil.CLI, fixture string) {
8677
func DegradeOnOwnerRefTest(oc *exutil.CLI, fixture string) {
8778
e2eskipper.Skipf("This test is temporarily disabled until boot image skew enforcement is implemented")
8879
// This fixture applies a boot image update configuration that opts in all machinesets
89-
err := oc.Run("apply").Args("-f", fixture).Execute()
90-
o.Expect(err).NotTo(o.HaveOccurred())
91-
92-
// Ensure status accounts for the fixture that was applied
93-
WaitForMachineConfigurationStatusUpdate(oc)
80+
ApplyBootImageFixture(oc, fixture)
9481

9582
// Pick a random machineset to test
9683
machineClient, err := machineclient.NewForConfig(oc.KubeFramework().ClientConfig())

test/extended/machine_config/boot_image_update_aws.go

+1-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
osconfigv1 "github.com/openshift/api/config/v1"
88

99
g "github.com/onsi/ginkgo/v2"
10-
o "github.com/onsi/gomega"
1110
exutil "github.com/openshift/origin/test/extended/util"
1211
)
1312

@@ -33,12 +32,7 @@ var _ = g.Describe("[sig-mco][OCPFeatureGate:ManagedBootImagesAWS][Serial]", fun
3332
})
3433

3534
g.AfterEach(func() {
36-
// Clear out boot image configuration between tests
37-
err := oc.Run("apply").Args("-f", emptyMachineSetFixture).Execute()
38-
o.Expect(err).NotTo(o.HaveOccurred())
39-
40-
// Ensure status accounts for the fixture that was applied
41-
WaitForMachineConfigurationStatusUpdate(oc)
35+
ApplyBootImageFixture(oc, emptyMachineSetFixture)
4236
})
4337

4438
g.It("Should update boot images only on MachineSets that are opted in [apigroup:machineconfiguration.openshift.io]", func() {

test/extended/machine_config/boot_image_update_gcp.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
osconfigv1 "github.com/openshift/api/config/v1"
88

99
g "github.com/onsi/ginkgo/v2"
10-
o "github.com/onsi/gomega"
1110
exutil "github.com/openshift/origin/test/extended/util"
1211
)
1312

@@ -34,8 +33,7 @@ var _ = g.Describe("[sig-mco][OCPFeatureGate:ManagedBootImages][Serial]", func()
3433

3534
g.AfterEach(func() {
3635
// Clear out boot image configuration between tests
37-
err := oc.Run("apply").Args("-f", emptyMachineSetFixture).Execute()
38-
o.Expect(err).NotTo(o.HaveOccurred())
36+
ApplyBootImageFixture(oc, emptyMachineSetFixture)
3937
})
4038

4139
g.It("Should update boot images only on MachineSets that are opted in [apigroup:machineconfiguration.openshift.io]", func() {

test/extended/machine_config/helpers.go

+10
Original file line numberDiff line numberDiff line change
@@ -307,3 +307,13 @@ func WaitForOneMasterNodeToBeReady(oc *exutil.CLI) error {
307307
}, 5*time.Minute, 10*time.Second).Should(o.BeTrue())
308308
return nil
309309
}
310+
311+
// Applies a boot image fixture and waits for the MCO to reconcile the status
312+
func ApplyBootImageFixture(oc *exutil.CLI, fixture string) {
313+
err := oc.Run("apply").Args("-f", fixture).Execute()
314+
o.Expect(err).NotTo(o.HaveOccurred())
315+
316+
// Ensure status accounts for the fixture that was applied
317+
WaitForMachineConfigurationStatusUpdate(oc)
318+
319+
}

0 commit comments

Comments
 (0)