Skip to content

[cherry-pick][2.60.0][serve] Deflake test_deploy_app_3 (#67165) - #67441

Closed
elliot-barn wants to merge 2 commits into
releases/2.60.0from
cherrypick/2.60.0-pr66492
Closed

elliot-barn wants to merge 2 commits into
releases/2.60.0from
cherrypick/2.60.0-pr66492

Conversation

@elliot-barn

Copy link
Copy Markdown
Collaborator

Cherry-pick of #67165 onto releases/2.60.0.

Original PR: #67165 (merged on master as b2ca380)

Why a second PR from this branch

This branch was cherry-picked in two stacked steps:

#67439 had already merged by then, so the test_deploy_app_3 change (c4840ed) is on this branch but never reached releases/2.60.0. This PR brings it over.

Change

python/ray/serve/tests/test_deploy_app_3.py only, +59/-41. That matches #67165 on master exactly. The branch's other commit (the #66492 cherry-pick) has the same content as a941e67 on releases/2.60.0, so it contributes no diff here. A test merge of this branch into releases/2.60.0 applies cleanly and changes only this file.

From #67165: test_deploy_app_3 flakes on the HAProxy, gRPC and flaky-tests shards. The fix:

  • waits read replica counts and pids from one snapshot;
  • traffic tests whose replicas stop during a rollout use the 5s HAProxy drain;
  • handles the direct-ingress request-count race.

Testing

Test-only change, verified on master in #67165. This PR's premerge runs the Serve test shards against releases/2.60.0.

🤖 Generated with Claude Code

johntaylor-cell and others added 2 commits October 26, 2026 12:53
…, a longer ingress drain for the traffic tests, and a Windows timeout (#66492)

(cherry picked from commit 09cc6ec)
Signed-off-by: qishengxhe <[email protected]>
Cherry-pick of #67165 ([serve] Deflake test_deploy_app_3) onto
`releases/2.60.0`. Master commit `b2ca380473`.

Applied cleanly with `git cherry-pick -x`. Test-only change:
`test_deploy_app_3.py`.

Depends on #67439 (cherry-pick of #66492), which adds the
`INGRESS_DRAIN_ENV` fixture constant this test imports. Stacked on that
PR so this diff shows only #67165; merge #67439 first, then retarget
this PR to `releases/2.60.0`.

No other backport PR for this change targets `releases/2.60.0`.
`pre-commit run --files` on the touched file passes. Relying on CI for
the test runs.

AI assistance was used to prepare this cherry-pick.

Signed-off-by: john.taylor <[email protected]>
Signed-off-by: qishengxhe <[email protected]>
Co-authored-by: johntaylor-cell <[email protected]>
Co-authored-by: Claude <[email protected]>
@elliot-barn
elliot-barn requested a review from a team as a code owner October 26, 2026 20:26

@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 refactors Ray Serve deployment tests to improve stability and prevent flakiness, particularly on Windows. It isolates test_deploy_app_2.py with an eternal timeout, adds explicit timeouts to several wait_for_condition calls, and introduces a code-defined draining environment (INGRESS_DRAIN_ENV) to ensure stopping replicas outlast HAProxy reloads. Feedback on these changes includes a recommendation to use safer dictionary fallbacks (or {}) in _drained to avoid potential AttributeErrors if keys are explicitly set to None, and a suggestion to compare replica states against the ReplicaState.RUNNING enum instead of a raw string for better robustness.

Comment on lines +57 to +58
ray_actor_options = deployment.get("ray_actor_options", {})
runtime_env = ray_actor_options.get("runtime_env", {})

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.

medium

If ray_actor_options or runtime_env is explicitly set to None in the input dictionary, calling .get() on them will raise an AttributeError. Using or {} provides a more robust fallback.

    ray_actor_options = deployment.get("ray_actor_options") or {}\n    runtime_env = ray_actor_options.get("runtime_env") or {}

states = Counter(r.state.value for r in replicas)
assert states.get("RUNNING", 0) >= 3, states
running = _running_replica_pids(client)
running = [r.pid for r in replicas if r.state == "RUNNING"]

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.

medium

Comparing r.state directly to the string "RUNNING" is fragile and inconsistent with the rest of the codebase where ReplicaState enum members are used. Since ReplicaState is already imported, it is safer and more robust to compare against ReplicaState.RUNNING directly.

Suggested change
running = [r.pid for r in replicas if r.state == "RUNNING"]
running = [r.pid for r in replicas if r.state == ReplicaState.RUNNING]

@elliot-barn

Copy link
Copy Markdown
Collaborator Author

Superseded by #67442, which cherry-picks only #67165 onto releases/2.60.0. This PR also showed the #66492 changes that already landed in #67439.

elliot-barn added a commit that referenced this pull request Oct 26, 2026
Cherry-pick of #67165 onto `releases/2.60.0`.

Original PR: #67165 (merged on master as b2ca380). This cherry-pick
was first made as #67438. That PR was stacked on the #66492 cherry-pick
branch and merged into it after #67439 had already landed, so it never
reached `releases/2.60.0`. This PR applies the same commit (c4840ed)
directly onto `releases/2.60.0`. It replaces #67441, which was opened
from the stacked branch and showed the already-landed #66492 changes
alongside this one.

## Change

`python/ray/serve/tests/test_deploy_app_3.py` only, +59/-41, identical
to #67165 and #67438. The cherry-pick applied cleanly.

From #67165: `test_deploy_app_3` flakes on the HAProxy, gRPC and
flaky-tests shards. The fix:
- waits read replica counts and pids from one snapshot;
- traffic tests whose replicas stop during a rollout use the 5s HAProxy
drain;
- handles the direct-ingress request-count race.

## Testing

Test-only change, verified on master in #67165. This PR's premerge runs
the Serve test shards against `releases/2.60.0`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: john.taylor <[email protected]>
Signed-off-by: qishengxhe <[email protected]>
Co-authored-by: qishengxhe <[email protected]>
Co-authored-by: johntaylor-cell <[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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants