Skip to content

Commit c2c8ffd

Browse files
committed
Migrate OCP-80983: verify cgroupv2 is default and v1 cannot be set
1 parent 2fa0e14 commit c2c8ffd

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

test/extended/node/node_e2e/node.go

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,21 @@ var _ = g.Describe("[sig-node] [Jira:Node/Kubelet] Kubelet, CRI-O, CPU manager",
1616
oc = exutil.NewCLIWithoutNamespace("node").AsAdmin()
1717
)
1818

19+
// Skip all tests on MicroShift clusters as MachineConfig resources are not available
20+
g.BeforeEach(func() {
21+
isMicroShift, err := exutil.IsMicroShiftCluster(oc.AdminKubeClient())
22+
o.Expect(err).NotTo(o.HaveOccurred())
23+
if isMicroShift {
24+
g.Skip("Skipping test on MicroShift cluster")
25+
}
26+
})
27+
1928
2029
g.It("[OTP] validate KUBELET_LOG_LEVEL", func() {
2130
var kubeservice string
2231
var kublet string
2332
var err error
2433

25-
isMicroShift, err := exutil.IsMicroShiftCluster(oc.AdminKubeClient())
26-
if err != nil {
27-
o.Expect(err).NotTo(o.HaveOccurred(), "error determining if running on MicroShift: %v", err)
28-
}
29-
if isMicroShift {
30-
g.Skip("This test case is not supported in micoshift cluster ")
31-
}
32-
3334
g.By("Polling to check kubelet log level on ready nodes")
3435
waitErr := wait.Poll(10*time.Second, 1*time.Minute, func() (bool, error) {
3536
g.By("Getting all node names in the cluster")
@@ -74,4 +75,20 @@ var _ = g.Describe("[sig-node] [Jira:Node/Kubelet] Kubelet, CRI-O, CPU manager",
7475
}
7576
o.Expect(waitErr).NotTo(o.HaveOccurred(), "KUBELET_LOG_LEVEL is not expected, timed out")
7677
})
78+
79+
80+
g.It("[OTP] validate cgroupv2 is default", func() {
81+
g.By("1) Check cgroup version")
82+
workerNode, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("nodes", "-l", "node-role.kubernetes.io/worker", "-o=jsonpath={.items[0].metadata.name}").Output()
83+
o.Expect(err).NotTo(o.HaveOccurred())
84+
cgroupV, err := oc.AsAdmin().WithoutNamespace().Run("debug").Args("node/"+workerNode, "-n", "default", "--", "chroot", "/host", "/bin/bash", "-c", "stat -c %T -f /sys/fs/cgroup").Output()
85+
o.Expect(err).NotTo(o.HaveOccurred())
86+
e2e.Logf("cgroup version info is: [%v]\n", cgroupV)
87+
o.Expect(cgroupV).To(o.ContainSubstring("cgroup2fs"))
88+
89+
g.By("2) Changing cgroup from v2 to v1 should result in error")
90+
output, err := oc.AsAdmin().WithoutNamespace().Run("patch").Args("nodes.config.openshift.io", "cluster", "-p", `{"spec": {"cgroupMode": "v1"}}`, "--type=merge").Output()
91+
o.Expect(err).Should(o.HaveOccurred())
92+
o.Expect(output).To(o.ContainSubstring("The Node \"cluster\" is invalid: spec.cgroupMode: Unsupported value: \"v1\": supported values: \"v2\", \"\""))
93+
})
7794
})

0 commit comments

Comments
 (0)