Skip to content

Commit

Permalink
WIP: update sched domains test
Browse files Browse the repository at this point in the history
WIP TBD

Signed-off-by: Francesco Romani <fromani@redhat.com>
  • Loading branch information
ffromani committed Sep 13, 2023
1 parent 853b8c0 commit 8d92f8a
Showing 1 changed file with 32 additions and 17 deletions.
Expand Up @@ -21,6 +21,7 @@ import (

performancev2 "github.com/openshift/cluster-node-tuning-operator/pkg/apis/performanceprofile/v2"
"github.com/openshift/cluster-node-tuning-operator/pkg/performanceprofile/controller/performanceprofile/components"
"github.com/openshift/cluster-node-tuning-operator/pkg/performanceprofile/utils/schedstat"
testutils "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils"
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"
Expand Down Expand Up @@ -235,26 +236,25 @@ var _ = Describe("[rfe_id:27363][performance] CPU Management", Ordered, func() {
// getCPUswithLoadBalanceDisabled Return cpus which are not in any scheduling domain
getCPUswithLoadBalanceDisabled := func() ([]string, error) {
cmd := []string{"/bin/bash", "-c", "cat /proc/schedstat"}
schedstat, err := nodes.ExecCommandOnNode(cmd, workerRTNode)
schedstatData, err := nodes.ExecCommandOnNode(cmd, workerRTNode)
if err != nil {
return nil, err
}
lines := strings.Split(schedstat, "\n")
cpusWithoutDomainLines := []string{}

// In the following loop, we iterate through each line that starts with "cpu".
// we examine the next line to determine if it starts with "domain".
// If there are no lines that start with "domain", it means cpu is not associated
// with any scheduling domain.These are collected in
for i := 0; i < len(lines); i++ {
line := lines[i]
if strings.HasPrefix(line, "cpu") {
if i+1 >= len(lines) || !strings.HasPrefix(lines[i+1], "domain") {
cpusWithoutDomainLines = append(cpusWithoutDomainLines, line)
}

info, err := schedstat.ParseData(strings.NewReader(schedstatData))
if err != nil {
return nil, err
}

cpusWithoutDomain := []string{}
for _, cpu := range info.GetCPUs() {
if len(info.GetDomains(cpu)) > 0 {
continue
}
cpusWithoutDomain = append(cpusWithoutDomain, cpu)
}
return cpusWithoutDomainLines, err

return cpusWithoutDomain, nil
}

BeforeEach(func() {
Expand All @@ -263,7 +263,23 @@ var _ = Describe("[rfe_id:27363][performance] CPU Management", Ordered, func() {
// defaultCpuNotInSchedulingDomains is empty if no gu pods are running
defaultCpuNotInSchedulingDomains, err := getCPUswithLoadBalanceDisabled()
Expect(err).ToNot(HaveOccurred(), "Unable to fetch scheduling domains")
testlog.Infof("Default scheduling Domains are: %s", defaultCpuNotInSchedulingDomains)

if len(defaultCpuNotInSchedulingDomains) > 0 {
pods, err := pods.GetPodsOnNode(workrtRTNode.Name)
if err != nil {
testlog.Warningf("cannot list pods on %q: %v", workerRTNode.Name, err)
} else {
testlog.Infof("pods on %q BEGIN", workerRTNode.Name)
for _, pod := range pods {
testlog.Infof("- %s/%s %s annotations=%#v", pod.Namespace, pod.Name, pod.UID, pod.Annotations)
}
testlog.Infof("pods on %q END", workerRTNode.Name)
}

// TODO: should this be a skip?
Fail(fmt.Sprintf("the test expects all CPUs within a scheduling domain, got %v instead", defaultCpuNotInSchedulingDomain))
}

annotations := map[string]string{
"cpu-load-balancing.crio.io": "disable",
}
Expand Down Expand Up @@ -352,7 +368,6 @@ var _ = Describe("[rfe_id:27363][performance] CPU Management", Ordered, func() {
}
return false
}, 15*time.Minute, 10*time.Second).Should(BeTrue())

})
})

Expand Down

0 comments on commit 8d92f8a

Please sign in to comment.