Skip to content

Commit 883a3cf

Browse files
authored
OCPBUGS-18662: e2e:rps: improve logging (#787)
* e2e:rps: log the expected rps mask print the expected rps mask for physical and virtual network devices. This change would help with debugging the test in case of failure. Signed-off-by: Talor Itzhak <titzhak@redhat.com> * e2e:rps: print mask instead of cpuset Printing the rps masks in case of failure is more readable then printing the cpuset. this is because an empty mask i.e 0000 is interpeted as an empty cpuset i.e "" (empty quotes) Signed-off-by: Talor Itzhak <titzhak@redhat.com> * e2e:rps: print device path with wrong mask 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> --------- Signed-off-by: Talor Itzhak <titzhak@redhat.com>
1 parent 32041b0 commit 883a3cf

File tree

1 file changed

+36
-10
lines changed

1 file changed

+36
-10
lines changed

test/e2e/performanceprofile/functests/1_performance/performance.go

+36-10
Original file line numberDiff line numberDiff line change
@@ -342,22 +342,31 @@ var _ = Describe("[rfe_id:27368][performance]", Ordered, func() {
342342

343343
expectedRPSCPUs, err := cpuset.Parse(string(*profile.Spec.CPU.Reserved))
344344
Expect(err).ToNot(HaveOccurred())
345+
expectedRPSCPUsMask, err := components.CPUListToMaskList(expectedRPSCPUs.String())
346+
Expect(err).ToNot(HaveOccurred())
347+
testlog.Infof("expected RPS CPU mask for virtual network devices=%q", expectedRPSCPUsMask)
345348

346349
expectedPhysRPSCPUs := expectedRPSCPUs.Clone()
350+
expectedPhyRPSCPUsMask := expectedRPSCPUsMask
347351
if !profileutil.IsPhysicalRpsEnabled(profile) {
348352
// empty cpuset
349353
expectedPhysRPSCPUs = cpuset.New()
354+
expectedPhyRPSCPUsMask, err = components.CPUListToMaskList(expectedPhysRPSCPUs.String())
355+
Expect(err).ToNot(HaveOccurred())
356+
testlog.Infof("physical RPS disabled, expected RPS CPU mask for physical network devices is=%q", expectedPhyRPSCPUsMask)
357+
} else {
358+
testlog.Infof("physical RPS enabled, expected RPS CPU mask for physical network devices is=%q", expectedRPSCPUsMask)
350359
}
351360

352361
for _, node := range workerRTNodes {
353-
// Verify the systemd RPS service uses the correct RPS mask
362+
By("verify the systemd RPS service uses the correct RPS mask")
354363
cmd := []string{"sysctl", "-n", "net.core.rps_default_mask"}
355364
rpsMaskContent, err := nodes.ExecCommandOnNode(cmd, &node)
356365
Expect(err).ToNot(HaveOccurred(), "failed to exec command %q on node %q", cmd, node)
357366
rpsMaskContent = strings.TrimSuffix(rpsMaskContent, "\n")
358367
rpsCPUs, err := components.CPUMaskToCPUSet(rpsMaskContent)
359368
Expect(err).ToNot(HaveOccurred(), "failed to parse RPS mask %q", rpsMaskContent)
360-
Expect(rpsCPUs.Equals(expectedRPSCPUs)).To(BeTrue(), "the default rps mask is different from the reserved CPUs; have %q want %q", rpsCPUs.String(), expectedRPSCPUs.String())
369+
Expect(rpsCPUs.Equals(expectedRPSCPUs)).To(BeTrue(), "the default rps mask is different from the reserved CPUs mask; have %q want %q", rpsMaskContent, expectedRPSCPUsMask)
361370

362371
By("verify RPS mask on virtual network devices")
363372
cmd = []string{
@@ -366,15 +375,17 @@ var _ = Describe("[rfe_id:27368][performance]", Ordered, func() {
366375
"-prune", "-o",
367376
"-type", "f",
368377
"-name", "rps_cpus",
378+
"-printf", "%p ",
369379
"-exec", "cat", "{}", ";",
370380
}
371-
devsRPS, err := nodes.ExecCommandOnNode(cmd, &node)
381+
devsRPSContent, err := nodes.ExecCommandOnNode(cmd, &node)
372382
Expect(err).ToNot(HaveOccurred(), "failed to exec command %q on node %q", cmd, node.Name)
373-
for _, devRPS := range strings.Split(devsRPS, "\n") {
374-
rpsCPUs, err = components.CPUMaskToCPUSet(devRPS)
383+
devsRPSMap := makeDevRPSMap(devsRPSContent)
384+
for path, mask := range devsRPSMap {
385+
rpsCPUs, err = components.CPUMaskToCPUSet(mask)
375386
Expect(err).ToNot(HaveOccurred())
376387
Expect(rpsCPUs.Equals(expectedRPSCPUs)).To(BeTrue(),
377-
"a host device rps mask is different from the reserved CPUs; have %q want %q", rpsCPUs.String(), expectedRPSCPUs.String())
388+
"a host virtual device: %q rps mask is different from the reserved CPUs; have %q want %q", path, mask, expectedRPSCPUsMask)
378389
}
379390

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

391-
for _, devRPS := range strings.Split(devsRPS, "\n") {
392-
rpsCPUs, err = components.CPUMaskToCPUSet(devRPS)
403+
devsRPSMap = makeDevRPSMap(devsRPSContent)
404+
for path, mask := range devsRPSMap {
405+
rpsCPUs, err = components.CPUMaskToCPUSet(mask)
393406
Expect(err).ToNot(HaveOccurred())
394-
Expect(rpsCPUs.Equals(expectedPhysRPSCPUs)).To(BeTrue(), "a host device rps mask is different from the reserved CPUs; have %q want %q", rpsCPUs.String(), expectedPhysRPSCPUs.String())
407+
Expect(rpsCPUs.Equals(expectedPhysRPSCPUs)).To(BeTrue(), "a host physical device: %q rps mask is different than expected; have %q want %q", path, mask, expectedPhyRPSCPUsMask)
395408
}
396409
}
397410
})
@@ -1415,3 +1428,16 @@ func validateTunedActiveProfile(wrknodes []corev1.Node) {
14151428
fmt.Sprintf("active_profile is not set to %s. %v", activeProfileName, err))
14161429
}
14171430
}
1431+
1432+
// makeDevRPSMap converts the find command output where each line has the following pattern:
1433+
// '/rootfs/sys/devices/virtual/net/<dev-id>/queues/rx-<queue-number>/rps_cpus <rps-mask>'
1434+
// into a map of devices with their corresponding rps mask
1435+
func makeDevRPSMap(content string) map[string]string {
1436+
devRPSMap := make(map[string]string)
1437+
for _, line := range strings.Split(content, "\n") {
1438+
s := strings.Split(line, " ")
1439+
path, mask := s[0], s[1]
1440+
devRPSMap[path] = mask
1441+
}
1442+
return devRPSMap
1443+
}

0 commit comments

Comments
 (0)