From deffc0cc13675c8a82f3894316c32c26c8130b25 Mon Sep 17 00:00:00 2001 From: Ronny Baturov Date: Wed, 20 Mar 2024 18:33:24 +0200 Subject: [PATCH] Added a test to verify system processes are in the correct cgroup When we are using cgroups v1 we are counting on the cpuset-configure.service to move all the system services to the custom system.slice. This test ensures the service indeed moved them. It is also a good practice to check for similar errors on cgroup v2 systems. Signed-off-by: Ronny Baturov --- .../functests/1_performance/performance.go | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/e2e/performanceprofile/functests/1_performance/performance.go b/test/e2e/performanceprofile/functests/1_performance/performance.go index 7bb35f8f69..29ef553e77 100644 --- a/test/e2e/performanceprofile/functests/1_performance/performance.go +++ b/test/e2e/performanceprofile/functests/1_performance/performance.go @@ -32,6 +32,7 @@ import ( componentprofile "github.com/openshift/cluster-node-tuning-operator/pkg/performanceprofile/controller/performanceprofile/components/profile" profileutil "github.com/openshift/cluster-node-tuning-operator/pkg/performanceprofile/controller/performanceprofile/components/profile" testutils "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils" + "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/cgroup" testclient "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/client" "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/cluster" "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/discovery" @@ -282,6 +283,29 @@ var _ = Describe("[rfe_id:27368][performance]", Ordered, func() { }) }) + Context("Using performance profile", func() { + It("Should have system services running on the system.slice cgroup", func() { + for _, node := range workerRTNodes { + processesFound := make([]string, 0) + rootCgroupPath := "/rootfs/sys/fs/cgroup/cpuset/cgroup.procs" + isV2, err := cgroup.IsVersion2(context.TODO(), testclient.Client) + if err != nil { + Expect(err).ToNot(HaveOccurred()) + } + if isV2 { + rootCgroupPath = "/rootfs/sys/fs/cgroup/cgroup.procs" + } + // Getting the list of processes that are running on the root cgroup, filtering out the kernel threads (are presented in [square brackets]). + command := fmt.Sprintf("cat %s | xargs ps -o cmd | grep -v \"\\[\"", rootCgroupPath) + output, err := nodes.ExecCommandOnNode(context.TODO(), []string{"/bin/bash", "-c", command}, &node) + Expect(err).ToNot(HaveOccurred()) + cmds := strings.Split(output, "\n") + processesFound = append(processesFound, cmds[1:]...) + Expect(processesFound).To(BeEmpty(), "The node %s has the following processes on the root cgroup: %v", node.Name, processesFound) + } + }) + }) + Context("Tuned kernel parameters", func() { It("[test_id:28466][crit:high][vendor:cnf-qe@redhat.com][level:acceptance] Should contain configuration injected through openshift-node-performance profile", func() { sysctlMap := map[string]string{