66 "fmt"
77 "os/exec"
88 "path/filepath"
9+ "slices"
910 "time"
1011
1112 mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
@@ -63,10 +64,19 @@ var _ = g.Describe("[Suite:openshift/machine-config-operator/disruptive][sig-mco
6364 })
6465
6566 g .It ("[Suite:openshift/conformance/serial][Serial]Should properly transition through MCN conditions on rebootless node update [apigroup:machineconfiguration.openshift.io]" , func () {
66- if IsSingleNode (oc ) {
67- ValidateMCNConditionTransitionsOnRebootlessUpdateSNO (oc , nodeDisruptionFixture , nodeDisruptionEmptyFixture , masterMCFixture )
68- } else {
69- ValidateMCNConditionTransitionsOnRebootlessUpdate (oc , nodeDisruptionFixture , nodeDisruptionEmptyFixture , customMCFixture , infraMCPFixture )
67+ // Create client set for test
68+ clientSet , clientErr := machineconfigclient .NewForConfig (oc .KubeFramework ().ClientConfig ())
69+ o .Expect (clientErr ).NotTo (o .HaveOccurred (), "Error creating client set for test." )
70+
71+ // Get MCPs to test for cluster
72+ poolNames := GetRolesToTest (oc , clientSet )
73+ framework .Logf ("Validating MCN properties for node(s) in pool(s) '%v'." , poolNames )
74+
75+ // When the cluster has machines in the "worker" MCP, use a custom MCP to test the update
76+ if slices .Contains (poolNames , worker ) {
77+ ValidateMCNConditionTransitionsOnRebootlessUpdate (oc , clientSet , nodeDisruptionFixture , nodeDisruptionEmptyFixture , customMCFixture , infraMCPFixture )
78+ } else { // When there are no machines in the "worker" MCP, test the update by applying a MC targeting the "master" MCP
79+ ValidateMCNConditionTransitionsOnRebootlessUpdateMaster (oc , clientSet , nodeDisruptionFixture , nodeDisruptionEmptyFixture , masterMCFixture )
7080 }
7181 })
7282
@@ -159,17 +169,17 @@ func ValidateMCNPropertiesCustomMCP(oc *exutil.CLI, fixture string) {
159169 o .Expect (mcnErr ).NotTo (o .HaveOccurred (), fmt .Sprintf ("Error validating MCN properties node in custom pool '%v'." , custom ))
160170}
161171
162- // `ValidateMCNConditionTransitions` checks that Conditions properly update on a node update
163- // Note that a custom MCP is created for this test to limit the number of upgrading nodes &
164- // decrease cleanup time.
165- func ValidateMCNConditionTransitionsOnRebootlessUpdate (oc * exutil.CLI , nodeDisruptionFixture string , nodeDisruptionEmptyFixture string , mcFixture string , mcpFixture string ) {
172+ // `ValidateMCNConditionTransitionsOnRebootlessUpdate` checks that the `Conditions` in an MCN
173+ // properly update on a node update in a custom MCP. The steps of this function are:
174+ // 1. Apply a node disruption policy
175+ // 2. Create a custom MCP with one node
176+ // 3. Apply a MC
177+ // 4. Validate the MCN conditions transition as expected throughout the update
178+ // 5. Clean up the test resources
179+ func ValidateMCNConditionTransitionsOnRebootlessUpdate (oc * exutil.CLI , clientSet * machineconfigclient.Clientset , nodeDisruptionFixture string , nodeDisruptionEmptyFixture string , mcFixture string , mcpFixture string ) {
166180 poolName := custom
167181 mcName := fmt .Sprintf ("90-%v-testfile" , poolName )
168182
169- // Create client set for test
170- clientSet , clientErr := machineconfigclient .NewForConfig (oc .KubeFramework ().ClientConfig ())
171- o .Expect (clientErr ).NotTo (o .HaveOccurred (), "Error creating client set for test." )
172-
173183 // Grab a random worker node
174184 workerNode := GetRandomNode (oc , worker )
175185 o .Expect (workerNode .Name ).NotTo (o .Equal ("" ), "Could not get a worker node." )
@@ -209,16 +219,17 @@ func ValidateMCNConditionTransitionsOnRebootlessUpdate(oc *exutil.CLI, nodeDisru
209219 o .Expect (ConfirmUpdatedMCNStatus (clientSet , updatingNodeName )).Should (o .BeTrue (), "Error, all conditions must be 'False' when Updated=True." )
210220}
211221
212- // `ValidateMCNConditionTransitionsSNO` checks that Conditions properly update on a node update
213- // in Single Node Openshift
214- func ValidateMCNConditionTransitionsOnRebootlessUpdateSNO (oc * exutil.CLI , nodeDisruptionFixture string , nodeDisruptionEmptyFixture string , mcFixture string ) {
222+ // `ValidateMCNConditionTransitionsOnRebootlessUpdateMaster` checks that the `Conditions` in an MCN
223+ // properly update on a node update in the master MCP. The steps of this function are:
224+ // 1. Apply a node disruption policy
225+ // 2. Apply a MC
226+ // 3. Get the updating node
227+ // 4. Validate the MCN conditions transition as expected throughout the update
228+ // 5. Clean up the test resources
229+ func ValidateMCNConditionTransitionsOnRebootlessUpdateMaster (oc * exutil.CLI , clientSet * machineconfigclient.Clientset , nodeDisruptionFixture string , nodeDisruptionEmptyFixture string , mcFixture string ) {
215230 poolName := master
216231 mcName := fmt .Sprintf ("90-%v-testfile" , poolName )
217232
218- // Create client set for test
219- clientSet , clientErr := machineconfigclient .NewForConfig (oc .KubeFramework ().ClientConfig ())
220- o .Expect (clientErr ).NotTo (o .HaveOccurred (), "Error creating client set for test." )
221-
222233 // Remove node disruption policy on test completion or failure
223234 defer func () {
224235 // Apply empty MachineConfiguration fixture to remove previously set NodeDisruptionPolicy
@@ -242,12 +253,13 @@ func ValidateMCNConditionTransitionsOnRebootlessUpdateSNO(oc *exutil.CLI, nodeDi
242253 WaitForMCPToBeReady (oc , clientSet , poolName , 1 )
243254 }()
244255
245- // Apply MC targeting worker node
256+ // Apply MC targeting master MCP
246257 mcErr := oc .Run ("apply" ).Args ("-f" , mcFixture ).Execute ()
247258 o .Expect (mcErr ).NotTo (o .HaveOccurred (), "Could not apply MachineConfig." )
248259
249260 // Get the updating node
250- updatingNode := GetUpdatingNodeSNO (oc , poolName )
261+ updatingNode := GetCordonedNode (oc , poolName )
262+ o .Expect (updatingNode ).NotTo (o .BeNil (), "Could not get updating node." )
251263 framework .Logf ("Node '%v' is updating." , updatingNode .Name )
252264
253265 // Validate transition through conditions for MCN
0 commit comments