Repository navigation
[cherry-pick][2.60.0][serve] Deflake test_deploy_app_3 (#67165) - #67441
elliot-barn wants to merge 2 commits into
Conversation
…, 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]>
There was a problem hiding this comment.
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.
| ray_actor_options = deployment.get("ray_actor_options", {}) | ||
| runtime_env = ray_actor_options.get("runtime_env", {}) |
There was a problem hiding this comment.
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"] |
There was a problem hiding this comment.
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.
| running = [r.pid for r in replicas if r.state == "RUNNING"] | |
| running = [r.pid for r in replicas if r.state == ReplicaState.RUNNING] |
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]>
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:
test_deploy_app_2) and was squash-merged intoreleases/2.60.0at 20:22:44 UTC (a941e67).test_deploy_app_3) onto this branch. It merged into the branch 34 seconds later, at 20:23:18.#67439 had already merged by then, so the
test_deploy_app_3change (c4840ed) is on this branch but never reachedreleases/2.60.0. This PR brings it over.Change
python/ray/serve/tests/test_deploy_app_3.pyonly, +59/-41. That matches #67165 on master exactly. The branch's other commit (the #66492 cherry-pick) has the same content as a941e67 onreleases/2.60.0, so it contributes no diff here. A test merge of this branch intoreleases/2.60.0applies cleanly and changes only this file.From #67165:
test_deploy_app_3flakes on the HAProxy, gRPC and flaky-tests shards. The fix: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