Skip to content

[serve] Deflake test_cli by adding explicit wait timeouts and stopping tracing config leak - #65432

Merged
abrarsheikh merged 2 commits into
ray-project:masterfrom
johntaylor-cell:serve-cli-deflake
Aug 13, 2026
Merged

abrarsheikh merged 2 commits into
ray-project:masterfrom
johntaylor-cell:serve-cli-deflake

Conversation

@johntaylor-cell

Copy link
Copy Markdown
Contributor

Two independent cleanups to python/ray/serve/tests/test_cli.py.

1. Explicit wait timeouts. 17 of the file's 41 wait_for_condition calls had an
effective timeout of 10s, and 12 of those were bare calls inheriting the default rather
than stating one. Every call now carries an explicit timeout, and existing values are
doubled, matching the convention already used elsewhere in this file.

2. Stop global tracing config leaking across tests.
test_deploy_config_tracing_config_declarative_flow deploys a config with
tracing_config: {enabled: true, sampling_ratio: 1.0}. ServeController.deploy_config
only ever sets global_tracing_config — there is no reset path — and the
serve_instance fixture is session-scoped, its teardown only deleting apps. Every
subsequent test in the file therefore ran with tracing enabled at ratio 1.0, exporting a
span per request. The test now resets tracing to disabled in its teardown.

Testing

  • 114 unloaded full-file runs, all green.
  • Under induced CPU contention, the timeout change fixed 3 previously-failing tests
    (test_deploy_multi_app_basic, test_deploy_multi_app_builder_with_args,
    test_status_multi_app); tests that wait for a terminal DEPLOY_FAILED state are
    unaffected, as that duration is governed by replica retry exhaustion rather than the
    wait timeout.
  • Tracing leak fix verified directly: a probe test in the same session now observes
    enabled=False where it previously saw enabled=True.

…ing across tests

17 of 41 wait_for_condition calls in test_cli.py had an effective timeout of
10s, 12 of them bare calls inheriting the default. Give every call an explicit
timeout and double the existing values, matching the convention already used
elsewhere in this file.

Also stop test_deploy_config_tracing_config_declarative_flow from leaking
global tracing config into the rest of the file. The controller only ever sets
global_tracing_config (deploy_config never resets it) and the Serve instance is
session-scoped, so every later test ran with tracing enabled at sampling_ratio
1.0, exporting a span per request. Reset it to disabled in the teardown.

Fragility and isolation cleanup; not a fix for a specific known flake.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: John Taylor <[email protected]>
@johntaylor-cell
johntaylor-cell requested a review from a team as a code owner August 12, 2026 16:34
@johntaylor-cell johntaylor-cell self-assigned this Aug 12, 2026
@johntaylor-cell johntaylor-cell added serve Ray Serve Related Issue go add ONLY when ready to merge, run all tests labels Aug 12, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request increases the timeouts for various wait_for_condition calls in python/ray/serve/tests/test_cli.py to mitigate test flakiness. Additionally, it introduces a teardown step in a finally block to disable tracing and redeploy the configuration, ensuring subsequent tests are unaffected. The reviewer suggested wrapping the teardown subprocess.check_output call in a try...except block to prevent masking any original test exceptions if the teardown fails.

Comment thread python/ray/serve/tests/test_cli.py Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit c75ddfd. Configure here.

Comment thread python/ray/serve/tests/test_cli.py Resolved
… clean up

Address review feedback on the tracing cleanup. The reset lived in a finally
around the last wait only, so a failure in check_running, the tracing
assertions, or the HTTP check skipped it and left global tracing enabled for
the rest of the session-scoped Serve instance. Registering it with
request.addfinalizer before the enabling deploy covers every exit path, and
running it as a finalizer rather than in finally means a teardown error is
reported separately instead of masking the real failure.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: John Taylor <[email protected]>
@johntaylor-cell johntaylor-cell changed the title [serve] test_cli deflake by adding explicit wait timeouts and stopping tracing config leak [serve] Deflake test_cli by adding explicit wait timeouts and stopping tracing config leak Aug 13, 2026
@abrarsheikh
abrarsheikh merged commit 637cc94 into ray-project:master Aug 13, 2026
6 checks passed
400Ping pushed a commit to 400Ping/ray that referenced this pull request Aug 18, 2026
…g tracing config leak (ray-project#65432)

Two independent cleanups to `python/ray/serve/tests/test_cli.py`.

**1. Explicit wait timeouts.** 17 of the file's 41 `wait_for_condition`
calls had an
effective timeout of 10s, and 12 of those were bare calls inheriting the
default rather
than stating one. Every call now carries an explicit timeout, and
existing values are
doubled, matching the convention already used elsewhere in this file.

**2. Stop global tracing config leaking across tests.**
`test_deploy_config_tracing_config_declarative_flow` deploys a config
with
`tracing_config: {enabled: true, sampling_ratio: 1.0}`.
`ServeController.deploy_config`
only ever *sets* `global_tracing_config` — there is no reset path — and
the
`serve_instance` fixture is session-scoped, its teardown only deleting
apps. Every
subsequent test in the file therefore ran with tracing enabled at ratio
1.0, exporting a
span per request. The test now resets tracing to disabled in its
teardown.

## Testing

- 114 unloaded full-file runs, all green.
- Under induced CPU contention, the timeout change fixed 3
previously-failing tests
(`test_deploy_multi_app_basic`,
`test_deploy_multi_app_builder_with_args`,
`test_status_multi_app`); tests that wait for a terminal `DEPLOY_FAILED`
state are
unaffected, as that duration is governed by replica retry exhaustion
rather than the
  wait timeout.
- Tracing leak fix verified directly: a probe test in the same session
now observes
  `enabled=False` where it previously saw `enabled=True`.

---------

Signed-off-by: John Taylor <[email protected]>
Co-authored-by: Claude <[email protected]>
Signed-off-by: 400Ping <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…g tracing config leak (ray-project#65432)

Two independent cleanups to `python/ray/serve/tests/test_cli.py`.

**1. Explicit wait timeouts.** 17 of the file's 41 `wait_for_condition`
calls had an
effective timeout of 10s, and 12 of those were bare calls inheriting the
default rather
than stating one. Every call now carries an explicit timeout, and
existing values are
doubled, matching the convention already used elsewhere in this file.

**2. Stop global tracing config leaking across tests.**
`test_deploy_config_tracing_config_declarative_flow` deploys a config
with
`tracing_config: {enabled: true, sampling_ratio: 1.0}`.
`ServeController.deploy_config`
only ever *sets* `global_tracing_config` — there is no reset path — and
the
`serve_instance` fixture is session-scoped, its teardown only deleting
apps. Every
subsequent test in the file therefore ran with tracing enabled at ratio
1.0, exporting a
span per request. The test now resets tracing to disabled in its
teardown.

## Testing

- 114 unloaded full-file runs, all green.
- Under induced CPU contention, the timeout change fixed 3
previously-failing tests
(`test_deploy_multi_app_basic`,
`test_deploy_multi_app_builder_with_args`,
`test_status_multi_app`); tests that wait for a terminal `DEPLOY_FAILED`
state are
unaffected, as that duration is governed by replica retry exhaustion
rather than the
  wait timeout.
- Tracing leak fix verified directly: a probe test in the same session
now observes
  `enabled=False` where it previously saw `enabled=True`.

---------

Signed-off-by: John Taylor <[email protected]>
Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests serve Ray Serve Related Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants