[https://nvbugs/5814203][fix] Fix port 8000 being used issue in stress test.#10756
Conversation
📝 WalkthroughWalkthroughAdds port availability validation and CI-aware default port resolution to the stress test configuration. Introduces Changes
Sequence DiagramsequenceDiagram
participant ST as Stress Test
participant DP as Default Port Resolver
participant CI as CI Environment
participant PA as Port Availability
participant Server
participant HC as Health Check
ST->>DP: Get default port
DP->>CI: Request free port from CI
alt CI provides port
CI-->>DP: Return CI port
else CI unavailable
DP-->>DP: Use fallback (8000)
end
DP-->>ST: Return port
ST->>PA: Check if port available
PA-->>PA: Attempt to bind port
alt Port is free
PA-->>ST: (True, None)
ST->>Server: Start server on port
Server-->>ST: Server started
ST->>HC: Perform health check
alt Server is healthy
HC-->>ST: Healthy
ST->>ST: Continue test
else Server unhealthy
HC-->>ST: Unhealthy
ST->>ST: Raise error
end
else Port in use
PA-->>ST: (False, error)
ST->>ST: Raise descriptive error
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
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)
tests/integration/defs/stress_test/stress_test.py (2)
1-2: Update the copyright year to include 2026.This file was modified in 2026, so the header should reflect the latest meaningful modification year. As per coding guidelines, please update the year range accordingly.
551-566: Health-check branch is effectively bypassed when the port is in use.Since the bind check runs first, a running server will always hit the “port in use” path, so the “server already running” branch won’t execute. Consider checking health first, then falling back to the bind check for non-HTTP occupants.
🛠️ Suggested reordering
- # Check if port is available (more reliable than just health check) - is_available, port_error = is_port_available(test_server_config.port, - test_server_config.host) - if not is_available: - raise RuntimeError( - f"Cannot start server: {port_error}. " - f"Please run 'fuser -k {test_server_config.port}/tcp' to free the port, " - f"or check if another process is using this port.") - - # Also check if a healthy server is already running (different scenario) - is_healthy, _ = check_server_health(test_server_config.url, - test_server_config.health_check_timeout) - if is_healthy: - raise RuntimeError( - f"Server is already running at {test_server_config.url}. Please stop it manually before running the stress test." - ) + # Check if a healthy server is already running + is_healthy, _ = check_server_health(test_server_config.url, + test_server_config.health_check_timeout) + if is_healthy: + raise RuntimeError( + f"Server is already running at {test_server_config.url}. Please stop it manually before running the stress test." + ) + + # Then ensure the port is actually free (e.g., non-HTTP process) + is_available, port_error = is_port_available(test_server_config.port, + test_server_config.host) + if not is_available: + raise RuntimeError( + f"Cannot start server: {port_error}. " + f"Please run 'fuser -k {test_server_config.port}/tcp' to free the port, " + f"or check if another process is using this port.")
🧹 Nitpick comments (3)
tests/integration/defs/stress_test/stress_test.py (3)
35-48: Keepdefs.commonimports namespaced.Project guidelines require preserving the module namespace. Please replace the
from defs.common import ...usage with a module import and update call sites.♻️ Suggested refactor
-from defs.common import get_free_port_in_ci, parse_gsm8k_output +import defs.common as common- return get_free_port_in_ci() + return common.get_free_port_in_ci()- accuracy_value = parse_gsm8k_output(output_text) + accuracy_value = common.parse_gsm8k_output(output_text)As per coding guidelines, please maintain module namespaces for imports.
76-81: Avoid catching a broadExceptionin_get_default_port.Catching all exceptions can mask unexpected failures. Please narrow the exception type (or update
get_free_port_in_ci()to raise a specific exception and catch that here). As per coding guidelines, narrow exception handling to the smallest set of errors possible.
571-573: Log message can be misleading on fallback paths.The message says “allocated via CI port mechanism” even when falling back to 8000. Consider logging a neutral message or tracking the allocation source.
✏️ Minimal change
- print_info( - f"Server port: {test_server_config.port} (allocated via CI port mechanism)" - ) + print_info(f"Server port: {test_server_config.port}")
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/integration/defs/stress_test/stress_test.py
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
**/*.py: The code developed for TensorRT-LLM should conform to Python 3.8+
Indent Python code with 4 spaces. Do not use tabs
Always maintain the namespace when importing Python modules, even if only one class or function from a module is used
Python filenames should use snake_case (e.g.,some_file.py)
Python classes should use PascalCase (e.g.,class SomeClass)
Python functions and methods should use snake_case (e.g.,def my_awesome_function():)
Python local variables should use snake_case, with prefixkfor variable names that start with a number (e.g.,k_99th_percentile)
Python global variables should use upper snake_case with prefixG(e.g.,G_MY_GLOBAL)
Python constants should use upper snake_case (e.g.,MY_CONSTANT)
Avoid shadowing variables declared in an outer scope in Python
Initialize all externally visible members of a Python class in the constructor
For Python interfaces that may be used outside a file, prefer docstrings over comments
Use comments in Python for code within a function, or interfaces that are local to a file
Use Google-style docstrings for Python classes and functions, which can be parsed by Sphinx
Python attributes and variables can be documented inline with the format"""<type>: Description"""
Avoid using reflection in Python when functionality can be easily achieved without reflection
When using try-except blocks in Python, limit the except clause to the smallest set of errors possible
When using try-except blocks in Python to handle multiple possible variable types (duck-typing), keep the body of the try as small as possible and use the else block for the main logic
Files:
tests/integration/defs/stress_test/stress_test.py
**/*.{cpp,cc,cxx,h,hpp,hxx,cu,cuh,py}
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
All TensorRT-LLM source files (.cpp, .h, .cu, .py, and other source files) should contain an NVIDIA copyright header with the year of latest meaningful modification
Files:
tests/integration/defs/stress_test/stress_test.py
🧠 Learnings (2)
📓 Common learnings
Learnt from: Shixiaowei02
Repo: NVIDIA/TensorRT-LLM PR: 9582
File: tests/integration/defs/accuracy/test_disaggregated_serving.py:73-83
Timestamp: 2025-12-02T03:40:40.572Z
Learning: In the disaggregated serving tests (tests/integration/defs/accuracy/test_disaggregated_serving.py), calling get_free_port() multiple times in succession is acceptable because the tests run in a controlled single-process environment where race conditions for port allocation are not a concern.
📚 Learning: 2025-12-02T03:40:40.572Z
Learnt from: Shixiaowei02
Repo: NVIDIA/TensorRT-LLM PR: 9582
File: tests/integration/defs/accuracy/test_disaggregated_serving.py:73-83
Timestamp: 2025-12-02T03:40:40.572Z
Learning: In the disaggregated serving tests (tests/integration/defs/accuracy/test_disaggregated_serving.py), calling get_free_port() multiple times in succession is acceptable because the tests run in a controlled single-process environment where race conditions for port allocation are not a concern.
Applied to files:
tests/integration/defs/stress_test/stress_test.py
🧬 Code graph analysis (1)
tests/integration/defs/stress_test/stress_test.py (2)
tests/integration/defs/common.py (2)
get_free_port_in_ci(1161-1200)parse_gsm8k_output(1241-1267)tests/integration/defs/trt_test_alternative.py (1)
print_info(300-306)
🪛 Ruff (0.14.11)
tests/integration/defs/stress_test/stress_test.py
80-80: Do not catch blind exception: Exception
(BLE001)
368-368: Consider moving this statement to an else block
(TRY300)
555-558: Avoid specifying long messages outside the exception class
(TRY003)
⏰ 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 (2)
tests/integration/defs/stress_test/stress_test.py (2)
87-88: Nice upgrade to a dynamic port default.Using
default_factoryavoids a shared fixed port and fits the new allocation logic well.
353-370: Port availability helper looks solid.Simple bind check with a clear error message is sufficient here.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
|
/bot run --stage-list "A10-PyTorch-Post-Merge-1" |
|
PR_Github #32279 [ run ] triggered by Bot. Commit: |
|
PR_Github #32279 [ run ] completed with state
|
Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
…ION scheduler on CI. Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
5ef14e5 to
0ea02e9
Compare
|
/bot run --stage-list "A10-PyTorch-Post-Merge-1" |
|
PR_Github #32506 [ run ] triggered by Bot. Commit: |
|
PR_Github #32506 [ run ] completed with state
|
Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
|
/bot run --stage-list "A10-PyTorch-Post-Merge-1" |
|
PR_Github #32530 [ run ] triggered by Bot. Commit: |
|
PR_Github #32530 [ run ] completed with state |
|
/bot run |
|
PR_Github #32550 [ run ] triggered by Bot. Commit: |
|
PR_Github #32550 [ run ] completed with state
|
|
/bot run |
|
PR_Github #32557 [ run ] triggered by Bot. Commit: |
|
PR_Github #32557 [ run ] completed with state
|
|
/bot run |
|
PR_Github #32633 [ run ] triggered by Bot. Commit: |
|
PR_Github #32633 [ run ] completed with state |
|
/bot run --stage-list "A10-PyTorch-Post-Merge-1" |
|
PR_Github #32651 [ run ] triggered by Bot. Commit: |
|
PR_Github #32666 [ run ] triggered by Bot. Commit: |
Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
|
/bot kill |
|
PR_Github #32674 [ kill ] triggered by Bot. Commit: |
|
PR_Github #32666 [ run ] completed with state |
|
PR_Github #32674 [ kill ] completed with state |
|
/bot run --stage-list "A10-PyTorch-Post-Merge-1" |
|
PR_Github #32683 [ run ] triggered by Bot. Commit: |
|
PR_Github #32683 [ run ] completed with state |
|
/bot run |
|
PR_Github #32707 [ run ] triggered by Bot. Commit: |
|
PR_Github #32707 [ run ] completed with state
|
|
/bot run |
|
PR_Github #32753 [ run ] triggered by Bot. Commit: |
|
PR_Github #32753 [ run ] completed with state
|
|
/bot run |
|
PR_Github #32834 [ run ] triggered by Bot. Commit: |
|
PR_Github #32834 [ run ] completed with state |
…s test. (NVIDIA#10756) Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
…s test. (NVIDIA#10756) Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
…s test. (NVIDIA#10756) Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
…s test. (NVIDIA#10756) Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
…s test. (NVIDIA#10756) Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
…s test. (NVIDIA#10756) Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
…s test. (NVIDIA#10756) Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
…s test. (NVIDIA#10756) Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
…s test. (NVIDIA#10756) Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
…s test. (#10756) Signed-off-by: Wangshanshan <30051912+dominicshanshan@users.noreply.github.com>
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.
Description
Test Coverage
PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
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.
Details
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 thestage-listparameter 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.mdand the
scripts/test_to_stage_mapping.pyhelper.kill
killKill all running builds associated with pull request.
skip
skip --comment COMMENTSkip 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-pipelineReuse 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.