Skip to content

Conversation

@yiqingy0
Copy link
Collaborator

@yiqingy0 yiqingy0 commented Aug 25, 2025

Summary by CodeRabbit

  • Refactor

    • Tightened local scoping in CI rerun logic, using per-iteration test lists and isolated variables.
    • Avoids mutating shared command configurations by building a fresh command per rerun iteration.
    • Separates input files for report generation and merging to prevent overlap.
  • Bug Fixes

    • Ensures each rerun iteration uses the correct test list and produces the correct reports, improving rerun accuracy and predictability in CI.

Description

Test Coverage

GitHub Bot Help

/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...

Provide a user friendly way for developers to interact with a Jenkins server.

Run /bot [-h|--help] to print this help message.

See details below for each supported subcommand.

run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]

Launch build/test pipelines. All previously running jobs will be killed.

--reuse-test (optional)pipeline-id (OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.

--disable-reuse-test (OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.

--disable-fail-fast (OPTIONAL) : Disable fail fast on build/tests/infra failures.

--skip-test (OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.

--stage-list "A10-PyTorch-1, xxx" (OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.

--gpu-type "A30, H100_PCIe" (OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.

--test-backend "pytorch, cpp" (OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.

--only-multi-gpu-test (OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.

--disable-multi-gpu-test (OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.

--add-multi-gpu-test (OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.

--post-merge (OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.

--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" (OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".

--detailed-log (OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.

--debug (OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in the stage-list parameter to access the appropriate container environment. Note: Does NOT update GitHub check status.

For guidance on mapping tests to stage names, see docs/source/reference/ci-overview.md
and the scripts/test_to_stage_mapping.py helper.

kill

kill

Kill all running builds associated with pull request.

skip

skip --comment COMMENT

Skip testing for latest commit on pull request. --comment "Reason for skipping build/test" is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

reuse-pipeline

reuse-pipeline

Reuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.

Signed-off-by: Yiqing Yan <[email protected]>
@yiqingy0 yiqingy0 requested a review from chzblych August 25, 2025 03:29
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 25, 2025

📝 Walkthrough

Walkthrough

Refactors rerun logic in jenkins/L0_Test.groovy to use explicit local scoping and per-iteration variables/files. Introduces local variables for rerun test lists, command line construction, flags, XML output, and input file aggregation, avoiding mutation of shared command structures. Control flow and error handling remain unchanged.

Changes

Cohort / File(s) Summary
Jenkins rerun scoping and per-iteration handling
jenkins/L0_Test.groovy
Localizes rerun variables (rerunTestList, currentRerunTestList, isRerunFailed, xmlFile, inputFiles). Builds newTestCmdLine per iteration, updates file existence/line-count checks, and injects --test-list per iteration. Avoids mutating original command; uses localized inputs for report merging. No public API changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant J as Jenkins Pipeline
  participant R as rerunFailedTests()
  participant FS as Filesystem
  participant TR as Test Runner
  participant RM as Result Merger

  J->>R: Invoke rerunFailedTests
  R->>FS: Check exists rerun_0.txt
  alt rerun file exists
    loop times (per-iteration)
      R->>FS: Define currentRerunTestList (iteration file)
      R->>R: Build newTestCmdLine (filtered + --test-list + --csv + --junit-xml + --reruns)
      R->>TR: Execute tests with newTestCmdLine
      TR-->>R: JUnit XML, CSV outputs
      R->>FS: Collect inputFiles (per-iteration)
    end
    R->>RM: Merge inputFiles into reports
    RM-->>R: Merged results
  else no rerun file
    R-->>J: Skip reruns
  end
  R-->>J: Return status (unchanged control flow)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • chzblych
  • ruodil
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@yiqingy0 yiqingy0 marked this pull request as ready for review August 25, 2025 03:29
@yiqingy0 yiqingy0 requested review from a team as code owners August 25, 2025 03:29
@yiqingy0 yiqingy0 requested a review from zeroepoch August 25, 2025 03:29
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
jenkins/L0_Test.groovy (2)

1181-1189: Declare count locally to avoid Groovy CPS/global leakage and potential MissingPropertyException.

Inside methods, assigning to an undeclared identifier can resolve to a script/global property under CPS. In parallel stages, this risks cross-stage contamination. Also, depending on compilation context, it may raise a MissingPropertyException.

Recommend declaring count as a local int.

Apply this diff:

-            count = sh(
+            int count = sh(
                 script: "grep -v '^[[:space:]]*\\$' ${currentRerunTestList} | wc -l",
                 returnStdout: true
             ).trim().toInteger()

If you prefer a slightly simpler/robust non-empty line count, awk 'NF' file | wc -l avoids some locale pitfalls with POSIX classes.


1240-1248: Declare inputFiles locally to avoid CPS binding bleed and improve readability.

inputFiles is assigned without def, which can become a script-level property under CPS. Make it local.

Apply this diff:

-    inputFiles = ["${WORKSPACE}/${stageName}/results.xml",
+    def inputFiles = ["${WORKSPACE}/${stageName}/results.xml",
                   "${WORKSPACE}/${stageName}/rerun_results_1.xml",
                   "${WORKSPACE}/${stageName}/rerun_results_2.xml"]
🧹 Nitpick comments (1)
jenkins/L0_Test.groovy (1)

1209-1219: Avoid mutating the incoming testCmdLine parameter across iterations. Build a fresh rerun command per attempt.

You rebuild testCmdLine each loop, but mutating a method parameter is brittle and easy to regress. Construct a new rerunCmd list instead, then execute it. This isolates rerun customization and keeps the baseline intact.

Apply this diff:

-        testCmdLine = testCmdLine.findAll { cmd ->
+        def rerunCmd = testCmdLine.findAll { cmd ->
             !noNeedLine.any { line -> cmd.contains(line) } && !needToChangeLine.any { line -> cmd.contains(line) }
         }
-        testCmdLine += [
+        rerunCmd += [
             "--test-list=${currentRerunTestList}",
             "--csv=${WORKSPACE}/${stageName}/rerun_report_${times}.csv",
             "--junit-xml ${xmlFile}",
             "--reruns ${times - 1}"
         ]
@@
-                ${testCmdLine.join(" ")}
+                ${rerunCmd.join(" ")}
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9c5b464 and faee5a5.

📒 Files selected for processing (1)
  • jenkins/L0_Test.groovy (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Pre-commit Check
🔇 Additional comments (1)
jenkins/L0_Test.groovy (1)

1170-1176: Good change: scope rerun_0 path locally.

Using a local def rerunTestList for rerun_0.txt reduces accidental leakage into broader scope and keeps the intent clear. Behavior is preserved.

Signed-off-by: Yiqing Yan <[email protected]>
Signed-off-by: Yiqing Yan <[email protected]>
@yiqingy0
Copy link
Collaborator Author

/bot run --stage-list "A10-TensorRT-1"

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5a27a24 and 117679a.

📒 Files selected for processing (1)
  • tests/integration/defs/accuracy/test_cli_flow.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

**/*.py: Python code must target Python 3.8+
Python indentation: 4 spaces, no tabs
Maintain module namespace in imports (from package.subpackage import foo; then use foo.SomeClass())
Python file names use snake_case
Python class names use PascalCase
Python functions/methods and local variables use snake_case; variables starting with a number get k_ prefix (e.g., k_99th_percentile)
Global variables use G_ prefixed UPPER_SNAKE_CASE (e.g., G_MY_GLOBAL)
Constants use UPPER_SNAKE_CASE in Python
Avoid shadowing variables from outer scopes in Python
Initialize all externally visible members of a Python class in init
Prefer docstrings for interfaces used outside a file; comments for local code
Use Google-style docstrings for classes and functions (Sphinx-parsable)
Document attributes/variables inline with short docstrings
Avoid reflection when simple alternatives exist (e.g., prefer explicit parameters over dict(**locals()))
In try/except, catch the narrowest exceptions possible
For duck-typing with try/except, keep try body minimal and put logic in else

Files:

  • tests/integration/defs/accuracy/test_cli_flow.py
**/*.{cpp,cxx,cc,cu,h,hpp,hxx,hh,cuh,py}

📄 CodeRabbit inference engine (CODING_GUIDELINES.md)

Prepend NVIDIA copyright header (current year) to all source files

Files:

  • tests/integration/defs/accuracy/test_cli_flow.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Pre-commit Check

@tensorrt-cicd
Copy link
Collaborator

PR_Github #16365 [ run ] triggered by Bot

Signed-off-by: Yiqing Yan <[email protected]>
@yiqingy0
Copy link
Collaborator Author

/bot run --stage-list "A10-TensorRT-1"

@tensorrt-cicd
Copy link
Collaborator

PR_Github #16365 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #12295 (Partly Tested) completed with status: 'FAILURE'

@tensorrt-cicd
Copy link
Collaborator

PR_Github #16387 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #16387 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #12313 (Partly Tested) completed with status: 'FAILURE'

Signed-off-by: Yiqing Yan <[email protected]>
@yiqingy0
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #16415 [ run ] triggered by Bot

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
jenkins/L0_Test.groovy (2)

1181-1189: Declare loop-local variable ‘count’ to avoid CPS binding leakage and potential compilation issues

Inside methods, assigning to an undeclared variable can leak into the script binding under CPS or even fail compilation. Declare it as a local with def (or a type).

Apply this diff:

-            count = sh(
+            def int count = sh(
                 script: "grep -v '^[[:space:]]*\\$' ${currentRerunTestList} | wc -l",
                 returnStdout: true
             ).trim().toInteger()

1240-1248: Ensure only existing XML files are passed to test_rerun.py

test_rerun.py’s generate_rerun_report and merge_junit_xmls both call ET.parse(...) on every path in --input-files. If a rerun didn’t occur, its rerun_results_{n}.xml won’t exist and Python will raise FileNotFoundError, causing the Jenkins step to fail. Defensively build inputFiles using fileExists(...) in the pipeline.

Affected locations:

  • jenkins/L0_Test.groovy, lines 1240–1248 (generate_rerun_report)
  • jenkins/L0_Test.groovy, lines 1250–1256 (merge_junit_xmls)

Suggested refactor:

-    def inputFiles = ["${WORKSPACE}/${stageName}/results.xml",
-                      "${WORKSPACE}/${stageName}/rerun_results_1.xml",
-                      "${WORKSPACE}/${stageName}/rerun_results_2.xml"]
+    // Always include the original results, then add any existing rerun files
+    def inputFiles = ["${WORKSPACE}/${stageName}/results.xml"]
+    ["1","2"].each { t ->
+        def p = "${WORKSPACE}/${stageName}/rerun_results_${t}.xml"
+        if (fileExists(p)) {
+            inputFiles += [p]
+        } else {
+            echo "Skipping missing rerun results file: ${p}"
+        }
+    }

Apply the same pattern before both the generate_rerun_report and merge_junit_xmls invocations so that only existing XMLs are merged.

🧹 Nitpick comments (3)
jenkins/L0_Test.groovy (3)

1172-1176: Early-exit on non-rerunnable failures is correct; minor naming nit

The logic to abort reruns when rerun_0.txt exists matches the comment and avoids wasted cycles. Consider renaming the local variable to clarify its purpose (e.g., cannotRerunList) to make future maintenance clearer.


1200-1219: Rerun command reconstruction: non-mutating, per-iteration scoping LGTM; two optional tweaks

  • You correctly avoid mutating testCmdLine and strip conflicting flags — nice.
  • Optional: include "--reruns" in noNeedLine to future-proof against upstream changes that might add it to the base command.
  • Optional: if you want identical junit output verbosity between first run and reruns, keep "-o junit_logging=out-err".

Apply this diff to future-proof the filter:

-        def noNeedLine = ["--splitting-algorithm", "--splits", "--group", "--waives-file", "--cov"]
+        def noNeedLine = ["--splitting-algorithm", "--splits", "--group", "--waives-file", "--cov", "--reruns"]

1220-1223: Minor: consider quoting arguments with spaces in join() (optional)

You’re already joining a list of args; a few entries have embedded spaces (e.g., "--junit-xml ${xmlFile}"). Groovy won’t fix quoting for you. It works now, but if a path ever contains spaces, this would break. Optional improvement: quote items with spaces before join.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between abe0ed9 and bc2f623.

📒 Files selected for processing (1)
  • jenkins/L0_Test.groovy (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Pre-commit Check
🔇 Additional comments (3)
jenkins/L0_Test.groovy (3)

1198-1199: Good: localize isRerunFailed

Declaring isRerunFailed with def confines it to the function scope and eliminates parallel-stage races.


1206-1207: Good: per-attempt xmlFile is locally scoped

Local xmlFile avoids cross-attempt clobbering/races.


1523-1527: Call site wiring looks correct

Capturing the boolean from rerunFailedTests and surfacing failure preserves existing control flow while enabling the improved rerun behavior.

@tensorrt-cicd
Copy link
Collaborator

PR_Github #16415 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #12337 completed with status: 'FAILURE'

@yiqingy0
Copy link
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Collaborator

PR_Github #16506 [ run ] triggered by Bot

@tensorrt-cicd
Copy link
Collaborator

PR_Github #16506 [ run ] completed with state SUCCESS
/LLM/main/L0_MergeRequest_PR pipeline #12399 completed with status: 'SUCCESS'
Pipeline passed with automatic retried tests. Check the rerun report for details.

@yiqingy0 yiqingy0 changed the title [None][infra] Fix rerun step [None][infra] Using local variables in rerun function Aug 26, 2025
@yiqingy0 yiqingy0 merged commit ff2439f into NVIDIA:main Sep 2, 2025
6 checks passed
@yiqingy0 yiqingy0 deleted the fix_rerun_step branch September 2, 2025 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants