fix :DumpTestContextIfFailed never captures context because defer CleanupTestContext fires first#5054
fix :DumpTestContextIfFailed never captures context because defer CleanupTestContext fires first#5054katara-Jayprakash wants to merge 3 commits intovolcano-sh:masterfrom
Conversation
Signed-off-by: katara-Jayprakash <katarajayprakash@icloud.com>
Signed-off-by: katara-Jayprakash <katarajayprakash@icloud.com>
Signed-off-by: katara-Jayprakash <katarajayprakash@icloud.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary of ChangesHello @katara-Jayprakash, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug in the e2e test infrastructure where test context dumps were failing to provide useful information upon test failure. The problem stemmed from the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly addresses a bug where DumpTestContextIfFailed would not capture the test context on failure. This was due to defer CleanupTestContext executing before the JustAfterEach block in Ginkgo tests. The fix, which involves moving test context initialization to BeforeEach blocks and using DeferCleanup, has been applied consistently across numerous E2E test files.
While the overall approach is sound, I've identified a significant issue in test/e2e/jobseq/job_error_handling.go that introduces a resource leak. One test case re-initializes the test context within an It block, which orphans the context created in BeforeEach. I've provided a detailed comment with a recommended refactoring to resolve this. Apart from this concern, the changes effectively fix the intended bug.
There was a problem hiding this comment.
Pull request overview
This PR fixes Bug #6 from issue #5048, where DumpTestContextIfFailed never captured test context because CleanupTestContext was firing first due to Go's defer mechanism executing in LIFO order before Ginkgo's JustAfterEach hooks.
Changes:
- Replaced
defer e2eutil.CleanupTestContext(testCtx)withDeferCleanup(e2eutil.CleanupTestContext, testCtx)in test lifecycle setup - Moved test context initialization from inside
Itblocks toBeforeEachblocks where applicable - Ensured proper execution order: BeforeEach → It → JustAfterEach → DeferCleanup
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/e2e/jobseq/tensorflow_plugin.go | Moved testCtx init to BeforeEach with DeferCleanup |
| test/e2e/jobseq/tensorflow.go | Moved testCtx init to BeforeEach with DeferCleanup |
| test/e2e/jobseq/ray_plugin.go | Moved testCtx init to BeforeEach with DeferCleanup |
| test/e2e/jobseq/queue_job_status.go | Moved testCtx init to BeforeEach with DeferCleanup, removed duplicate inits from It blocks |
| test/e2e/jobseq/queue.go | Replaced defer with DeferCleanup in It blocks (special case with per-test options) |
| test/e2e/jobseq/pytorch_plugin.go | Moved testCtx init to BeforeEach with DeferCleanup |
| test/e2e/jobseq/mpi_plugin.go | Moved testCtx init to BeforeEach with DeferCleanup |
| test/e2e/jobseq/mpi.go | Moved testCtx init to BeforeEach with DeferCleanup |
| test/e2e/jobseq/job_plugins.go | Moved testCtx init to BeforeEach with DeferCleanup, removed duplicate inits from It blocks |
| test/e2e/jobseq/job_error_handling.go | Moved testCtx init to BeforeEach with DeferCleanup, removed duplicate inits from most It blocks, kept one special case with custom options |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/cc @hajnalmt fixed sir |
|
@katara-Jayprakash: GitHub didn't allow me to request PR reviews from the following users: fixed, sir. Note that only volcano-sh members and repo collaborators can review this PR, and authors cannot review their own PRs. DetailsIn 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/test-infra repository. |
What type of PR is this?
i'm calling it bug fixing prWhat this PR does / why we need it:
this pr try to fixed the bug where DumpTestContextIfFailed never captured context because CleanupTestContext was firing first due to Go's defer mechanism.Which issue(s) this PR fixes:
the pr is part of #5048 and fixes the bug-6Fixes #
#5048
Special notes for your reviewer:
@hajnalmt thanx for giving the so much brief about issue in descriptionDoes this PR introduce a user-facing change?
none