Skip to content

Commit 561f034

Browse files
Merge pull request #30002 from eggfoobar/fix-arbiter-test
NO-JIRA: fix: nil pointer reference in pod count
2 parents 0a8ad12 + b4c2658 commit 561f034

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

test/extended/two_node/arbiter_topology.go

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,18 @@ import (
2222
)
2323

2424
var (
25-
defaultExpectedMaxPodCount = 30
26-
expectedMaxPodCountsPerPlatform = map[v1.PlatformType]int{
27-
v1.BareMetalPlatformType: 30,
28-
// Add more platforms as needed
25+
expectedPods = map[string]int{
26+
"openshift-cluster-node-tuning-operator": 1,
27+
"openshift-dns": 1,
28+
"openshift-etcd": 2,
29+
"openshift-image-registry": 1,
30+
"openshift-kni-infra": 3,
31+
"openshift-machine-config-operator": 2,
32+
"openshift-monitoring": 1,
33+
"openshift-multus": 3,
34+
"openshift-network-diagnostics": 1,
35+
"openshift-network-operator": 1,
36+
"openshift-ovn-kubernetes": 1,
2937
}
3038
)
3139

@@ -63,40 +71,34 @@ var _ = g.Describe("[sig-node][apigroup:config.openshift.io][OCPFeatureGate:High
6371
defer g.GinkgoRecover()
6472

6573
var (
66-
oc = exutil.NewCLIWithoutNamespace("")
67-
infraStatus v1.InfrastructureStatus
74+
oc = exutil.NewCLIWithoutNamespace("")
6875
)
6976

7077
g.BeforeEach(func() {
7178
skipIfNotTopology(oc, v1.HighlyAvailableArbiterMode)
7279
})
7380
g.It("Should verify that the correct number of pods are running on the Arbiter node", func() {
74-
g.By("inferring platform type")
7581

76-
// Default to baremetal count of 17 expected Pods, if platform type does not exist in map
77-
if expectedCount, exists := expectedMaxPodCountsPerPlatform[infraStatus.PlatformStatus.Type]; exists {
78-
defaultExpectedMaxPodCount = expectedCount
79-
}
8082
g.By("Retrieving the Arbiter node name")
8183
nodes, err := oc.AdminKubeClient().CoreV1().Nodes().List(context.Background(), metav1.ListOptions{
8284
LabelSelector: labelNodeRoleArbiter,
8385
})
8486
o.Expect(err).To(o.BeNil(), "Expected to retrieve nodes without error")
8587
o.Expect(len(nodes.Items)).To(o.Equal(1))
8688
g.By("by comparing pod counts")
87-
podCount := 0
89+
countedPods := map[string]int{}
8890
for _, node := range nodes.Items {
8991
pods, err := oc.AdminKubeClient().CoreV1().Pods("").List(context.Background(), metav1.ListOptions{
90-
FieldSelector: "spec.nodeName=" + node.Name + ",status.phase=Running",
92+
FieldSelector: fmt.Sprintf("spec.nodeName=%s,status.phase=Running", node.Name),
9193
})
9294
o.Expect(err).To(o.BeNil(), "Expected to retrieve pods without error")
9395
for _, pod := range pods.Items {
94-
if !strings.HasPrefix(pod.Namespace, "openshift-e2e-") {
95-
podCount += 1
96+
if !strings.HasPrefix(pod.Namespace, "e2e-") {
97+
countedPods[pod.Namespace] += 1
9698
}
9799
}
98100
}
99-
o.Expect(podCount).To(o.BeNumerically("<=", defaultExpectedMaxPodCount), "Expected the max number of running pods on the Arbiter node")
101+
o.Expect(countedPods).To(o.Equal(expectedPods), "Expected the max number of running pods on the Arbiter node")
100102
})
101103
})
102104

0 commit comments

Comments
 (0)