Skip to content

[Refactor][Test] Extract ApplyRayJobAndWaitForTerminal helper#4772

Open
1fanwang wants to merge 1 commit intoray-project:masterfrom
1fanwang:kuberay-4373-rayjob-test-helper
Open

[Refactor][Test] Extract ApplyRayJobAndWaitForTerminal helper#4772
1fanwang wants to merge 1 commit intoray-project:masterfrom
1fanwang:kuberay-4373-rayjob-test-helper

Conversation

@1fanwang
Copy link
Copy Markdown

Problem

The Apply RayJob -> wait for IsJobTerminal block is duplicated across 8 e2e test sites in ray-operator/test/. As @seanlaii noted in #4363 (review), the pattern belongs in ray-operator/test/support/.

Direction

Extract ApplyRayJobAndWaitForTerminal into support/ray.go, alongside the existing RayJob/GetRayJob accessors and VerifyContainerAuthTokenEnvVars. Promote only the tight Apply-immediately-followed-by-IsJobTerminal pattern; leave alone sites that wait on a different deployment status (Running, Failed, ValidationFailed, ...) or interleave other logic between Apply and the terminal wait.

Scope

  • 8 call sites refactored across:
    • e2erayjob/rayjob_test.go
    • e2erayjob/rayjob_sidecar_mode_test.go (x2)
    • e2erayjob/rayjob_lightweight_test.go (x2)
    • e2erayjob/rayjob_cluster_selector_test.go (x2)
    • e2erayjobsubmitter/rayjob_submitter_test.go
  • Net: 6 files, +30 / -56 (-26 LoC).
  • The file-private applyRayJobAndWaitForCompletion and applyRayJobAndWaitForJobDeploymentStatusFailed in rayjob_deletion_strategy_test.go are intentionally untouched -- they assert stricter completion states (JobStatusSucceeded only, JobDeploymentStatusFailed + DeadlineExceeded) than the new shared helper, which matches the looser IsJobTerminal.

Validation

  • go build ./test/... clean
  • go vet ./test/... clean
  • gofmt -l ray-operator/test/ clean
  • E2E tests not run locally (require kind cluster + Ray operator); covered by CI.

Closes #4373.

@1fanwang 1fanwang force-pushed the kuberay-4373-rayjob-test-helper branch from 8507e64 to 5c1bc73 Compare April 27, 2026 09:02
The 5-line "Apply RayJob -> wait for IsJobTerminal" pattern was duplicated
at 8 e2e test sites across rayjob_{test,sidecar_mode,lightweight,
cluster_selector,submitter}_test.go. Promote it to support/ray.go so
callers drop the boilerplate and stay consistent on logging and timeout.

Refactors only the tight Apply-immediately-followed-by-IsJobTerminal
pattern; sites that wait on a different deployment status (Running, Failed,
ValidationFailed, ...) or interleave other logic between Apply and the
terminal wait are left untouched. The file-private helpers in
rayjob_deletion_strategy_test.go also stay where they are -- they assert
stricter completion states (Succeeded only / Failed-with-DeadlineExceeded)
than the new shared helper, which intentionally matches IsJobTerminal.

Closes ray-project#4373.

Signed-off-by: 1fanwang <1fannnw@gmail.com>
@1fanwang 1fanwang force-pushed the kuberay-4373-rayjob-test-helper branch from 5c1bc73 to 4084dc7 Compare April 27, 2026 09:22
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.

[Refactor] [Test] Extract a shared helper for applying a RayJob and waiting for completion in e2e tests

1 participant