Skip to content

Commit 2525941

Browse files
Merge pull request #29938 from isabella-janssen/ocpbugs-58036
OCPBUGS-58036: Fix MCN test on agent compact FIPS jobs
2 parents db0d373 + 8d03e73 commit 2525941

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

test/extended/machine_config/helpers.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,24 @@ func skipOnMetal(oc *exutil.CLI) {
149149
}
150150
}
151151

152+
// `GetRolesToTest` gets the MCPs in a cluster with nodes associated to it. This allows a more robust way to determine
153+
// the roles to use when selecting nodes and testing their MCP associations in an MCN.
154+
func GetRolesToTest(oc *exutil.CLI, machineConfigClient *machineconfigclient.Clientset) []string {
155+
// Get MCPs
156+
mcps, mcpErr := machineConfigClient.MachineconfigurationV1().MachineConfigPools().List(context.TODO(), metav1.ListOptions{})
157+
o.Expect(mcpErr).NotTo(o.HaveOccurred(), "Error getting MCPs.")
158+
159+
// For any MCP with machines, add the MCP name as a role to test.
160+
var rolesToTest []string
161+
for _, mcp := range mcps.Items {
162+
if mcp.Status.MachineCount > 0 {
163+
rolesToTest = append(rolesToTest, mcp.Name)
164+
}
165+
}
166+
167+
return rolesToTest
168+
}
169+
152170
// getRandomMachineSet picks a random machineset present on the cluster
153171
func getRandomMachineSet(machineClient *machineclient.Clientset) machinev1beta1.MachineSet {
154172
machineSets, err := machineClient.MachineV1beta1().MachineSets("openshift-machine-api").List(context.TODO(), metav1.ListOptions{})

test/extended/machine_config/machine_config_node.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,7 @@ var _ = g.Describe("[Suite:openshift/machine-config-operator/disruptive][sig-mco
5353
})
5454

5555
g.It("[Suite:openshift/conformance/parallel]Should have MCN properties matching associated node properties for nodes in default MCPs [apigroup:machineconfiguration.openshift.io]", func() {
56-
if IsSingleNode(oc) || IsTwoNode(oc) { //handle SNO & two-node clusters
57-
// In SNO and standard two-node openshift clusters, the nodes have both worker and master roles, but are a part
58-
// of the master MCP. Thus, the tests for these clusters will be limited to checking master MCP association.
59-
ValidateMCNPropertiesByMCPs(oc, []string{master})
60-
} else if IsTwoNodeArbiter(oc) { //handle two-node arbiter clusters
61-
// In two-node arbiter openshift clusters, there are two nodes have both worker and master roles, but are a part
62-
// of the master MCP. There is also a third "arbiter" node. Thus, these clusters should be tests for both master
63-
// and arbiter MCP association.
64-
ValidateMCNPropertiesByMCPs(oc, []string{master, arbiter})
65-
} else { //handle standard clusters
66-
ValidateMCNPropertiesByMCPs(oc, []string{master, worker})
67-
}
56+
ValidateMCNPropertiesByMCPs(oc)
6857
})
6958

7059
g.It("[Suite:openshift/conformance/serial][Serial]Should have MCN properties matching associated node properties for nodes in custom MCPs [apigroup:machineconfiguration.openshift.io]", func() {
@@ -108,14 +97,16 @@ var _ = g.Describe("[Suite:openshift/machine-config-operator/disruptive][sig-mco
10897
})
10998

11099
// `ValidateMCNPropertiesByMCPs` checks that MCN properties match the corresponding node properties
111-
// for a random node in each of the desired MCPs.
112-
func ValidateMCNPropertiesByMCPs(oc *exutil.CLI, poolNames []string) {
113-
framework.Logf("Validating MCN properties for node(s) in pool(s) '%v'.", poolNames)
114-
100+
// for a random node in each MCP in the cluster with nodes.
101+
func ValidateMCNPropertiesByMCPs(oc *exutil.CLI) {
115102
// Create client set for test
116103
clientSet, clientErr := machineconfigclient.NewForConfig(oc.KubeFramework().ClientConfig())
117104
o.Expect(clientErr).NotTo(o.HaveOccurred(), "Error creating client set for test.")
118105

106+
// Get MCPs to test for cluster
107+
poolNames := GetRolesToTest(oc, clientSet)
108+
framework.Logf("Validating MCN properties for node(s) in pool(s) '%v'.", poolNames)
109+
119110
// Validate MCN associated with node in each desired MCP
120111
for _, poolName := range poolNames {
121112
framework.Logf("Validating MCN properties for %v node.", poolName)

0 commit comments

Comments
 (0)