Skip to content

Commit

Permalink
e2e:rps: print device path with wrong mask
Browse files Browse the repository at this point in the history
In case the test failed, we asserts only the desired and actual mask,
but we are not specifing the device on which the RPS mask was bad.

This patch adds the full device path as part of the error message.

Signed-off-by: Talor Itzhak <titzhak@redhat.com>
  • Loading branch information
Tal-or committed Sep 7, 2023
1 parent 370cb8b commit 1e37c03
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions test/e2e/performanceprofile/functests/1_performance/performance.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,15 +375,17 @@ var _ = Describe("[rfe_id:27368][performance]", Ordered, func() {
"-prune", "-o",
"-type", "f",
"-name", "rps_cpus",
"-printf", "%p ",
"-exec", "cat", "{}", ";",
}
devsRPS, err := nodes.ExecCommandOnNode(cmd, &node)
devsRPSContent, err := nodes.ExecCommandOnNode(cmd, &node)
Expect(err).ToNot(HaveOccurred(), "failed to exec command %q on node %q", cmd, node.Name)
for _, devRPS := range strings.Split(devsRPS, "\n") {
rpsCPUs, err = components.CPUMaskToCPUSet(devRPS)
devsRPSMap := makeDevRPSMap(devsRPSContent)
for path, mask := range devsRPSMap {
rpsCPUs, err = components.CPUMaskToCPUSet(mask)
Expect(err).ToNot(HaveOccurred())
Expect(rpsCPUs.Equals(expectedRPSCPUs)).To(BeTrue(),
"a host device rps mask is different from the reserved CPUs; have %q want %q", devRPS, expectedRPSCPUsMask)
"a host virtual device: %q rps mask is different from the reserved CPUs; have %q want %q", path, mask, expectedRPSCPUsMask)
}

By("verify RPS mask on physical network devices")
Expand All @@ -392,15 +394,17 @@ var _ = Describe("[rfe_id:27368][performance]", Ordered, func() {
"-regex", "/rootfs/sys/devices/pci.*",
"-type", "f",
"-name", "rps_cpus",
"-printf", "%p ",
"-exec", "cat", "{}", ";",
}
devsRPS, err = nodes.ExecCommandOnNode(cmd, &node)
devsRPSContent, err = nodes.ExecCommandOnNode(cmd, &node)
Expect(err).ToNot(HaveOccurred(), "failed to exec command %q on node %q", cmd, node.Name)

for _, devRPS := range strings.Split(devsRPS, "\n") {
rpsCPUs, err = components.CPUMaskToCPUSet(devRPS)
devsRPSMap = makeDevRPSMap(devsRPSContent)
for path, mask := range devsRPSMap {
rpsCPUs, err = components.CPUMaskToCPUSet(mask)
Expect(err).ToNot(HaveOccurred())
Expect(rpsCPUs.Equals(expectedPhysRPSCPUs)).To(BeTrue(), "a host device rps mask is different than expected; have %q want %q", devRPS, expectedPhyRPSCPUsMask)
Expect(rpsCPUs.Equals(expectedPhysRPSCPUs)).To(BeTrue(), "a host physical device: %q rps mask is different than expected; have %q want %q", path, mask, expectedPhyRPSCPUsMask)
}
}
})
Expand Down Expand Up @@ -1424,3 +1428,16 @@ func validateTunedActiveProfile(wrknodes []corev1.Node) {
fmt.Sprintf("active_profile is not set to %s. %v", activeProfileName, err))
}
}

// makeDevRPSMap converts the find command output where each line has the following pattern:
// '/rootfs/sys/devices/virtual/net/<dev-id>/queues/rx-<queue-number>/rps_cpus <rps-mask>'
// into a map of devices with their corresponding rps mask
func makeDevRPSMap(content string) map[string]string {
devRPSMap := make(map[string]string)
for _, line := range strings.Split(content, "\n") {
s := strings.Split(line, " ")
path, mask := s[0], s[1]
devRPSMap[path] = mask
}
return devRPSMap
}

0 comments on commit 1e37c03

Please sign in to comment.