-
Notifications
You must be signed in to change notification settings - Fork 135
e2e: Fix broken assertions #1571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,7 +12,6 @@ import ( | |||||||||||||||||||||||
| performancev2 "github.com/openshift/cluster-node-tuning-operator/pkg/apis/performanceprofile/v2" | ||||||||||||||||||||||||
| 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/label" | ||||||||||||||||||||||||
| testlog "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/log" | ||||||||||||||||||||||||
| "k8s.io/utils/cpuset" | ||||||||||||||||||||||||
| "sigs.k8s.io/yaml" | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
@@ -120,9 +119,7 @@ var _ = Describe("[rfe_id: 38968] PerformanceProfile setup helper and platform a | |||||||||||||||||||||||
| errString := "Error: failed to obtain data from flags not appropriate to split reserved CPUs in case of topology-manager-policy: single-numa-node" | ||||||||||||||||||||||||
| ok, err := regexp.MatchString(errString, string(output)) | ||||||||||||||||||||||||
| Expect(err).ToNot(HaveOccurred()) | ||||||||||||||||||||||||
| if ok { | ||||||||||||||||||||||||
| testlog.Info(errString) | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| Expect(ok).To(BeTrue(), "expected error %q not found in output: %s", errString, output) | ||||||||||||||||||||||||
| Eventually(session).Should(gexec.Exit(1)) | ||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -144,9 +141,7 @@ var _ = Describe("[rfe_id: 38968] PerformanceProfile setup helper and platform a | |||||||||||||||||||||||
| errString := "Error: failed to compute the reserved and isolated CPUs: can't allocate odd number of CPUs from a NUMA Node" | ||||||||||||||||||||||||
| ok, err := regexp.MatchString(errString, string(output)) | ||||||||||||||||||||||||
| Expect(err).ToNot(HaveOccurred(), "did not fail with Expected:%s failure", errString) | ||||||||||||||||||||||||
| if ok { | ||||||||||||||||||||||||
| testlog.Info(errString) | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| Expect(ok).To(BeTrue(), "expected error %q not found in output: %s", errString, output) | ||||||||||||||||||||||||
| Eventually(session).Should(gexec.Exit(1)) | ||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -169,9 +164,7 @@ var _ = Describe("[rfe_id: 38968] PerformanceProfile setup helper and platform a | |||||||||||||||||||||||
| errString := "Error: failed to compute the reserved and isolated CPUs: please specify the reserved CPU count in the range [1,3]" | ||||||||||||||||||||||||
| ok, err := regexp.MatchString(errString, string(output)) | ||||||||||||||||||||||||
| Expect(err).ToNot(HaveOccurred(), "did not fail with Expected:%s failure", errString) | ||||||||||||||||||||||||
| if ok { | ||||||||||||||||||||||||
| testlog.Info(errString) | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| Expect(ok).To(BeTrue(), "expected error %q not found in output: %s", errString, output) | ||||||||||||||||||||||||
|
Comment on lines
164
to
+167
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== locate file =="
git ls-files | grep -F 'test/e2e/performanceprofile/functests/10_performance_ppc/ppc.go' || true
echo "== relevant source =="
if [ -f test/e2e/performanceprofile/functests/10_performance_ppc/ppc.go ]; then
sed -n '130,190p' test/e2e/performanceprofile/functests/10_performance_ppc/ppc.go
fi
echo "== deterministic regex behavior probe =="
python3 - <<'PY'
import re
errString = "Error: failed to compute the reserved and isolated CPUs: please specify the reserved CPU count in the range [1,3]"
output_same = errString
output_differed = "Error: failed to compute the reserved and isolated CPUs: please specify the reserved CPU count in the range [4,5]"
quoted = re.escape(errString)
for name, pat in [("errString", errString), ("regexp.QuoteMeta(errString)", quoted)]:
print(name)
try:
print(" same matches:", bool(re.search(pat, output_same)))
print(" differed matches:", bool(re.search(pat, output_differed)))
except Exception as e:
print(" regex error:", repr(e))
PYRepository: openshift/cluster-node-tuning-operator Length of output: 3438 Escape the literal CPU range before regex matching.
Proposed fix- ok, err := regexp.MatchString(errString, string(output))
+ ok, err := regexp.MatchString(regexp.QuoteMeta(errString), string(output))📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. interesting catch @oblau worth looking into that
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the intention that the output will contain explicitly [1,3]? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @oblau sounds good. if you're running it locally, it's worth printing |
||||||||||||||||||||||||
| Eventually(session).Should(gexec.Exit(1)) | ||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -217,9 +210,7 @@ var _ = Describe("[rfe_id: 38968] PerformanceProfile setup helper and platform a | |||||||||||||||||||||||
| errString := `please use one of \[default low-latency\] power consumption modes together with the perPodPowerManagement` | ||||||||||||||||||||||||
| ok, err := regexp.MatchString(errString, string(output)) | ||||||||||||||||||||||||
| Expect(err).ToNot(HaveOccurred(), "did not fail with Expected:%s failure", errString) | ||||||||||||||||||||||||
| if ok { | ||||||||||||||||||||||||
| testlog.Info(errString) | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| Expect(ok).To(BeTrue(), "expected error %q not found in output: %s", errString, output) | ||||||||||||||||||||||||
| Eventually(session).Should(gexec.Exit(1)) | ||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a change in the behavior. it makes the test more restrict. is that what we want here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is changing behavior - but isn't this the intention here?
If we are not asserting on
okthen i fail to see why we need theerrStringand
regexp.MatchString(errString, string(output))to begin with.Maybe im missing something here.
Is the goal to make sure the correct error message appears, or that PPC script fails in general?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After reevaluation I think this change is ok.
the only change I would add is in the message to make it more clear: