Skip to content

test: remove environment-specific e2e defaults - #262

Merged
typhoonzero merged 2 commits into
masterfrom
codex/e2e-env-cleanup
Jun 11, 2026
Merged

typhoonzero merged 2 commits into
masterfrom
codex/e2e-env-cleanup

Conversation

@typhoonzero

@typhoonzero typhoonzero commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • remove hard-coded e2e kube context, kubeconfig, namespace, Docker Hub mirror, and private registry defaults
  • make optional pull secrets, node selectors, RWX storage classes, Volcano queue, runtime class, and NPU resource names env-driven
  • keep unconfigured GPU/NPU cases as skips via the shared e2e skip code instead of failing on local environment assumptions

Validation

  • bash -n e2e/lib.sh e2e/run_all.sh e2e/cases/*.sh
  • git diff --check
  • rg -n "docker-mirrors|docker\.1ms|mlops-demo|g1-c1|npu-env|build-harbor|harbor-mlops|cephfs|152-231|my_dev_env|dev cluster|dev GPU|dev NPU|192\.168|queue: default|kubeflow-admin-cpaas-io|alauda\.cn" e2e (no matches)
  • bash e2e/run_all.sh C1 (skips cleanly without GPU_NAMESPACE)
  • env NPU_NAMESPACE=test bash e2e/run_all.sh C8 (skips cleanly without NPU_RESOURCE_NAME)
  • yarn lint

Summary by CodeRabbit

  • Chores

    • E2E tests now use environment-driven configuration for namespaces, contexts, runtimes, images, pull secrets, storage classes, node selectors, and resource names/values instead of hardcoded values.
    • Centralized helpers added for mirroring images, namespace injection, conditional YAML fields, and kubectl context selection.
  • Tests

    • All GPU/NPU e2e cases support optional DockerHub mirroring and configurable runtime/image/resource wiring for flexible test environments.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR centralizes e2e configuration in e2e/lib.sh (env defaults, skip-code, kubectl wrapper, mirror and YAML-templating helpers) and adapts GPU and NPU test cases to require their target namespaces and use those helpers to parameterize images, pull secrets, storage classes, node selectors, runtimeClassName, and resource limits.

Changes

E2E Test Infrastructure Parametrization

Layer / File(s) Summary
Library helpers and environment setup
e2e/lib.sh
Introduces E2E_SKIP_RC with validation, empties cluster-specific defaults for GPU/NPU targeting and mirrors, and adds helpers: mirror_dockerhub, set_metadata_namespace, require_env, _kubectl_with_env, plus YAML helpers yaml_scalar_field, yaml_image_pull_secrets, yaml_node_selector, yaml_storage_class, yaml_resource_limit.
GPU e2e test cases parametrization
e2e/cases/c1_smoke_gpu.sh, e2e/cases/c2_kubeflow_trainer_mnist.sh, e2e/cases/c3_traininghub_sft.sh, e2e/cases/c4_traininghub_osft.sh, e2e/cases/c5_trainer_v2_llamafactory.sh, e2e/cases/c6_volcanojob_llamafactory.sh, e2e/cases/c12_kueue_preemption.sh
Each case now calls require_env GPU_NAMESPACE, derives NS, parameterizes image, imagePullSecrets, RWX storage class, and nodeSelector via env vars with fallbacks, routes generated YAML through mirror_dockerhub when configured, and injects pod spec fields using yaml_* helpers instead of hardcoded values.
NPU e2e test cases parametrization
e2e/cases/c7_smoke_npu.sh, e2e/cases/c8_trainer_v2_mindspeed_npu.sh, e2e/cases/c9_qwen3_finetune_verify.sh, e2e/cases/c11_qwen3_06b_mindspore.sh
Each NPU case now calls require_env for NPU namespace/resource names, supports configurable NPU_RUNTIME_CLASS, IMAGE_PULL_SECRET, and NPU/memory resource names/values, injects runtimeClassName, imagePullSecrets, and resource limits via yaml_* helpers, and mirrors referenced images when requested.
Exit code harmonization for test runner
e2e/run_all.sh
Detects skipped cases by comparing case exit code to ${E2E_SKIP_RC} instead of a hardcoded 77.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • alauda/aml-docs#260: Overlaps with Kueue preemption case changes and checkpoint PVC handling that this PR parameterizes.
  • alauda/aml-docs#259: Related e2e harness updates touching mirror_dockerhub, kubectl wrappers, and skip handling in the e2e scripts.

Poem

🐰 A rabbit in the CI glade, I hopped with nimble cheer,

I freed the tests from hardcoded nests and made configs appear.
With tiny YAML helpers tucked beneath my paw,
Images, secrets, runtimes dance — no more hacks to thaw.
Hop, mirror, run — the e2e forest sings, compact and clear.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.88% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'test: remove environment-specific e2e defaults' directly summarizes the main change: removing hardcoded environment-specific defaults from e2e test scripts and making them environment-driven instead.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/e2e-env-cleanup

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 10, 2026

Copy link
Copy Markdown

Deploying alauda-ai with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6c3a8cb
Status: ✅  Deploy successful!
Preview URL: https://cc0dcee8.alauda-ai.pages.dev
Branch Preview URL: https://codex-e2e-env-cleanup.alauda-ai.pages.dev

View logs

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
e2e/run_all.sh (1)

29-30: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update stale inline comment about skip return code.

The comment still says rc=77, but skip rc is now configurable via E2E_SKIP_RC. Please align the comment with current behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/run_all.sh` around lines 29 - 30, Update the outdated inline comment that
references a hardcoded skip return code "rc=77": change the comment to mention
that the skip return code is configurable via the E2E_SKIP_RC environment
variable (used by the script) and that tests may skip with the value of
E2E_SKIP_RC rather than a fixed 77; locate the comment near the C12/Kueue note
in run_all.sh and update its wording to reference E2E_SKIP_RC and current
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e/lib.sh`:
- Line 11: Validate and normalize E2E_SKIP_RC immediately after it’s set: check
that the variable E2E_SKIP_RC is a numeric string (digits only) and that its
integer value falls within 0..255; if either check fails, reset E2E_SKIP_RC to
the default 77 and export it so subsequent uses (exit and -eq comparisons) are
safe. Implement this by first using a digit-only pattern match on E2E_SKIP_RC
(e.g., case or regex) to reject non-numeric values, then perform numeric range
checks (using [ "$E2E_SKIP_RC" -lt 0 ] and [ "$E2E_SKIP_RC" -gt 255 ] guarded
behind the numeric check); if invalid, assign and export E2E_SKIP_RC=77.

---

Outside diff comments:
In `@e2e/run_all.sh`:
- Around line 29-30: Update the outdated inline comment that references a
hardcoded skip return code "rc=77": change the comment to mention that the skip
return code is configurable via the E2E_SKIP_RC environment variable (used by
the script) and that tests may skip with the value of E2E_SKIP_RC rather than a
fixed 77; locate the comment near the C12/Kueue note in run_all.sh and update
its wording to reference E2E_SKIP_RC and current behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 35eb3411-22a7-49ba-9573-99056968fbff

📥 Commits

Reviewing files that changed from the base of the PR and between fddd5d1 and a88d38b.

📒 Files selected for processing (13)
  • e2e/cases/c11_qwen3_06b_mindspore.sh
  • e2e/cases/c12_kueue_preemption.sh
  • e2e/cases/c1_smoke_gpu.sh
  • e2e/cases/c2_kubeflow_trainer_mnist.sh
  • e2e/cases/c3_traininghub_sft.sh
  • e2e/cases/c4_traininghub_osft.sh
  • e2e/cases/c5_trainer_v2_llamafactory.sh
  • e2e/cases/c6_volcanojob_llamafactory.sh
  • e2e/cases/c7_smoke_npu.sh
  • e2e/cases/c8_trainer_v2_mindspeed_npu.sh
  • e2e/cases/c9_qwen3_finetune_verify.sh
  • e2e/lib.sh
  • e2e/run_all.sh

Comment thread e2e/lib.sh
E2E_SKIP_RC is overridable via env in this harness, but was used both as a
process exit status (truncated mod 256) and as the RHS of a numeric `-eq`
compare in run_all.sh. A non-numeric or out-of-range override makes the two
diverge, so a skipped case is misreported as FAIL (e.g. 300 -> exit 44, then
`[ 44 -eq 300 ]` is false). Coerce any invalid override back to the 77 default
right after assignment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
e2e/lib.sh (1)

140-153: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Initialize got before the polling loop to avoid nounset crashes.

If timeout is 0 (or negative), the loop never executes and ${got} at Line 152 is unbound under set -u, causing a hard script error instead of a clean timeout return.

Proposed fix
 wait_for_status() {
   local kfn="$1" kind="$2" name="$3" ns="$4" path="$5"
   shift 5
   local timeout="${!#}"
   local n=$(( $# - 1 ))
   local expected=( "${@:1:$n}" )
+  local got=""
   local deadline=$(( SECONDS + timeout ))
   while [ "$SECONDS" -lt "$deadline" ]; do
-    local got
     got="$($kfn get "${kind}" "${name}" -n "${ns}" -o jsonpath="${path}" 2>/dev/null || true)"
     for e in "${expected[@]}"; do
       if [ "${got}" = "${e}" ]; then
         echo "${got}"
         return 0

As per coding guidelines, runtime-order pitfalls and unbound-variable crash paths should be fixed before release.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/lib.sh` around lines 140 - 153, The variable 'got' may be unbound if the
while-loop never runs (e.g., timeout ≤ 0), causing set -u failures; initialize
it before the loop by declaring local got="" (or local got='' ) right before the
while that uses 'got' so the echo on timeout (the message referencing ${got}) is
safe; update the existing local got declaration in the polling block to assign
an empty string to avoid nounset crashes while keeping the current polling logic
(references: variable 'got', 'timeout', and the while loop that checks SECONDS
vs deadline).

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@e2e/lib.sh`:
- Around line 140-153: The variable 'got' may be unbound if the while-loop never
runs (e.g., timeout ≤ 0), causing set -u failures; initialize it before the loop
by declaring local got="" (or local got='' ) right before the while that uses
'got' so the echo on timeout (the message referencing ${got}) is safe; update
the existing local got declaration in the polling block to assign an empty
string to avoid nounset crashes while keeping the current polling logic
(references: variable 'got', 'timeout', and the while loop that checks SECONDS
vs deadline).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 69c855c9-efc3-4871-96ae-97351c4d82a6

📥 Commits

Reviewing files that changed from the base of the PR and between a88d38b and 6c3a8cb.

📒 Files selected for processing (1)
  • e2e/lib.sh

@typhoonzero
typhoonzero merged commit 61b6850 into master Jun 11, 2026
3 checks passed
@typhoonzero
typhoonzero deleted the codex/e2e-env-cleanup branch June 11, 2026 03:23
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.

1 participant