Skip to content

Commit f8b086a

Browse files
authored
e2e: tuned degraded test fix (#1282)
* Addressed a corner case where nodes based on VMs would always log a warning without verifying if the profile was degraded. This incorrect behavior has been fixed to properly check the profile state before logging warnings. * Modified isVM func to execute "systemd-detect-virt" command after chroot to rootfs. This will ensures accurate virtualization detection by running the command in the host's context instead of the container.
1 parent 698aa3b commit f8b086a

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,16 @@ var _ = Describe("[rfe_id:27368][performance]", Ordered, func() {
129129
Expect(err).ToNot(HaveOccurred(), "Failed to get the Tuned profile for node %s", node.Name)
130130
degradedCondition := findCondition(tunedProfile.Status.Conditions, "Degraded")
131131
Expect(degradedCondition).ToNot(BeNil(), "Degraded condition not found in Tuned profile status")
132-
isNodeBasedOnVM, err := infrastructure.IsVM(&node)
132+
isNodeBasedOnVM, err := infrastructure.IsVM(context.TODO(), &node)
133133
Expect(err).ToNot(HaveOccurred(), "Failed to detect if the node is based on VM")
134-
if isNodeBasedOnVM {
135-
testlog.Warning(fmt.Sprintf("Tuned profile is degraded. A warning raised as the node is based on a VM. Error message: %s", degradedCondition.Message))
136-
} else {
137-
Expect(degradedCondition.Status).To(Equal(corev1.ConditionFalse), "Tuned profile is degraded. Error message: %s", degradedCondition.Message)
134+
135+
if degradedCondition.Status == corev1.ConditionTrue {
136+
message := fmt.Sprintf("Tuned profile is degraded. Error message: %s", degradedCondition.Message)
137+
if isNodeBasedOnVM {
138+
testlog.Warning(fmt.Sprintf("A warning raised as the node is based on a VM. %s", message))
139+
} else {
140+
Fail(message)
141+
}
138142
}
139143
}
140144
})

test/e2e/performanceprofile/functests/utils/infrastructure/vm.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ import (
1010
)
1111

1212
// IsVM checks if a given node's underlying infrastructure is a VM
13-
func IsVM(node *corev1.Node) (bool, error) {
13+
func IsVM(ctx context.Context, node *corev1.Node) (bool, error) {
1414
cmd := []string{
15-
"/bin/bash",
16-
"-c",
17-
"systemd-detect-virt > /dev/null ; echo $?",
15+
"/usr/sbin/chroot",
16+
"/rootfs",
17+
"/bin/bash", "-c",
18+
"systemd-detect-virt > /dev/null; echo $?",
1819
}
19-
output, err := nodes.ExecCommandOnMachineConfigDaemon(context.TODO(), node, cmd)
20+
output, err := nodes.ExecCommandOnMachineConfigDaemon(ctx, node, cmd)
2021
if err != nil {
2122
return false, err
2223
}

0 commit comments

Comments
 (0)