-
Notifications
You must be signed in to change notification settings - Fork 114
OCPBUGS-62605: e2e: refactor GetSMTLevel to remove Gomega assertions #1399
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
OCPBUGS-62605: e2e: refactor GetSMTLevel to remove Gomega assertions #1399
Conversation
e6b9118
to
428c027
Compare
/retest |
428c027
to
e6b9118
Compare
test/e2e/performanceprofile/functests/1_performance/cpu_management.go
Outdated
Show resolved
Hide resolved
The GetSMTLevel util function previously used gomega assertions which could cause panics when called outside of Ginkgo It blocks. This PR addresses: - Modified the GetSMTLevel signature to return (int, error) - Replaced ExpectWithOffset assertions with standard error handling - Updated all function refrences to handle the error return Signed-Off-by: Sargun Narula <snarula@redhat.com>
e6b9118
to
0be8ef3
Compare
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.
/lgtm
// GetSMTLevel returns the SMT level on the node using the given cpuID as target | ||
// Use a random cpuID from the return value of GetOnlineCPUsSet if not sure | ||
func GetSMTLevel(ctx context.Context, cpuID int, node *corev1.Node) int { | ||
func GetSMTLevel(ctx context.Context, cpuID int, node *corev1.Node) (int, error) { |
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.
GinkgoHelper() in the first line will solve exactly that without having to change the function API
https://onsi.github.io/ginkgo/#mental-model-how-ginkgo-handles-failure
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.
@Tal-or is very correct. In addition, that would allow us to remove the fragile WithOffset
expectations (mostly my fault here).
That said, changing the function signature and return an explicit error LGTM and I slightly prefer that approach for library code.
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.
@Tal-or If i understand correctly, if we used GinkgoHelper(), it would remove the panic and point the failure to Test itself, which originally is not the motive of the API change.
Considering a library function, it should work when called outside a test spec block, where it would panic. Please let me know if I’ve misunderstood anything 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.
What is considered to be panic? a go assertion? because it's expected to abort a test with an assertion in Ginkgo.
All GinkgoHelper() is doing is point to the caller of the function (in the stack trace), it's basically equal to call Fail
with offset.
Considering a library function, it should work when called outside a test spec block
this function scope is only for the NTO e2e test, it should not be imported into other projects and not even in the none-test code of this specific project, so assertion here is completely fine.
Bottom line, I don't mind whether this function return an errors or asserts, my initial comment was mainly for the sake of discussion and broadening the knowledge and expertise as part of the reviewing process.
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 function scope is only for the NTO e2e test, it should not be imported into other projects and not even in the none-test code of this specific project, so assertion here is completely fine.
I fully agree with this sentence
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.
I guess the remaining open point boils down to: where is this function planned to be used?
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.
/retest |
4 similar comments
/retest |
/retest |
/retest |
/retest |
considering the proposed usage, which is still within the test code, I'm inclined to approve. @Tal-or any concern or comment? |
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.
/approve
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ffromani, SargunNarula The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@SargunNarula: This pull request references CNF-19657 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target either version "4.21." or "openshift-4.21.", but it targets "openshift-4.20" instead. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
/retest |
/label verified |
@SargunNarula: The label(s) In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/verified by @mrniranjan |
@mrniranjan: This PR has been marked as verified by In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
@SargunNarula: This pull request references Jira Issue OCPBUGS-62605, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
/jira refresh |
@SargunNarula: This pull request references Jira Issue OCPBUGS-62605, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
No GitHub users were found matching the public email listed for the QA contact in Jira (liqcui@redhat.com), skipping review request. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
@SargunNarula: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
ccb071f
into
openshift:main
@SargunNarula: Jira Issue Verification Checks: Jira Issue OCPBUGS-62605 Jira Issue OCPBUGS-62605 has been moved to the MODIFIED state and will move to the VERIFIED state when the change is available in an accepted nightly payload. 🕓 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
Fix included in accepted release 4.21.0-0.nightly-2025-10-02-002727 |
The GetSMTLevel util function previously used gomega assertions which could cause panics when called outside of Ginkgo It blocks.
This PR addresses: