Skip to content

test(e2e): default the harness to admin-off; held-back tests opt in#800

Merged
moonming merged 3 commits into
mainfrom
feat/e2e-admin-off-default
Jul 22, 2026
Merged

test(e2e): default the harness to admin-off; held-back tests opt in#800
moonming merged 3 commits into
mainfrom
feat/e2e-admin-off-default

Conversation

@moonming

@moonming moonming commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

What

Flip the e2e harness default to admin: false, so the whole suite runs with no admin listener bound by default. The only tests that keep the admin listener are the ones whose subject is the Admin API surface — they now opt in explicitly with admin: true.

This is the last step of the e2e "de-admin-API" work (after #791 added the admin.enabled switch and #792 migrated the seed-tail tests). It proves the acceptance for retiring the Admin API: the suite is green with the admin listener off by default, so when the Admin API is removed, only the explicitly-admin: true files need deletion — everything else already runs admin-off.

Changes

  • tests/e2e/src/harness/app.ts: AppOverrides.admin now defaults to false (overrides.admin ?? false). Doc updated: admin-off is the norm; only held-back admin-surface tests opt in with admin: true.
  • 9 held-back files get an explicit admin: true on every spawnApp site — a no-op behaviorally (this was the previous default), just making the dependency explicit now that the default flipped: apikey-budget, apikey-lifecycle (admin key rotate / removed-field validation), auth-baseline (admin bearer 401), file-resource-source (file-mode admin write 409 + path-leak), health-minimal / prometheus-metrics (admin /admin/v1/health), openai-sdk-compat (RFC 9745 deprecation-header contract), seed-vs-admin-characterization (seed≡admin equivalence), status-models (/status/models vs /admin/v1/models/status equivalence).

Everything else — the large majority of the suite, which already seeds via SeedClient/etcd and never touches the admin listener — now runs admin-off with no per-file change (the default carries it).

Scoping method

Swept every case file for real admin-listener usage (app.adminUrl in a request / new AdminClient calling anything other than listModelStatuses, which reads the metrics listener). The result was exactly the 9 held-back files above. admin-disabled-e2e and the 9 files migrated in #792 already pass admin: false explicitly; status-config seeds via etcd and only references /admin/v1/health in a comment, so it runs admin-off unchanged.

Verification

npx tsc --noEmit clean on the changed files. The 9 held-back files pass unchanged (admin:true = their prior behavior); allowed-models and status-config confirm previously-default-admin-on files now run admin-off. Full e2e suite green with the admin-off default — the definitive check that no admin-dependent file was missed (a miss would fail now that the listener is off by default).

Follow-up

With this merged, the remaining Admin-API-removal work (AISIX-Cloud#1007 Phase 4) is: /readyz relocation + read-surface decision, a v0.4.0 coexistence release, then the removal PR itself (which deletes the admin listener + the 9 admin: true held-back tests).

Summary by CodeRabbit

  • Tests
    • Updated end-to-end test setup to explicitly enable the Admin API where required.
    • Continued validating API key budgets, authentication failures, health checks, metrics, model status, and resource behavior.
  • Refactor
    • Test applications now start with the Admin API disabled by default, matching the updated configuration.
    • Readiness checks no longer require the Admin API unless it is explicitly enabled.

Flip AppOverrides.admin to default false, so the whole suite runs with
no admin listener bound — the shape once the Admin API is removed. Only
the tests whose subject IS the Admin API surface keep it, opting in with
admin: true (a no-op behaviorally — this was the previous default):
apikey-budget/-lifecycle, auth-baseline, file-resource-source,
health-minimal, prometheus-metrics, openai-sdk-compat,
seed-vs-admin-characterization, status-models.

Everything else — the majority, already seeding via SeedClient/etcd —
now runs admin-off with no per-file change. Scoped by sweeping every case
for real admin-listener use (app.adminUrl in a request / AdminClient
calls other than listModelStatuses, which reads the metrics listener);
the result was exactly those 9 files.

Last step of the e2e de-admin-API work (after #791 switch, #792 seed
migration): full suite green admin-off proves the Admin API isn't needed
to run it, so removal deletes only the admin listener + these 9 tests.
@moonming

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.


Your plan includes PR reviews subject to rate limits. More reviews will be available in 59 minutes.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@moonming, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 43 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bd999af3-8cc7-47a6-9d4d-a15a38fa2309

📥 Commits

Reviewing files that changed from the base of the PR and between 5f84ea9 and a087c7b.

📒 Files selected for processing (2)
  • tests/e2e/src/cases/prometheus-metrics-e2e.test.ts
  • tests/e2e/src/harness/app.ts
📝 Walkthrough

Walkthrough

The E2E harness now disables the Admin listener by default. Tests that exercise Admin APIs or related endpoints explicitly start applications with admin: true.

Changes

Admin listener transition

Layer / File(s) Summary
Harness default configuration
tests/e2e/src/harness/app.ts
Admin listener startup and readiness checks now default to disabled unless explicitly overridden.
Admin-dependent E2E setup
tests/e2e/src/cases/*apikey*-e2e.test.ts, tests/e2e/src/cases/auth-baseline-e2e.test.ts, tests/e2e/src/cases/file-resource-source-e2e.test.ts, tests/e2e/src/cases/health-minimal-e2e.test.ts, tests/e2e/src/cases/openai-sdk-compat.test.ts, tests/e2e/src/cases/prometheus-metrics-e2e.test.ts, tests/e2e/src/cases/seed-vs-admin-characterization-e2e.test.ts, tests/e2e/src/cases/status-models-e2e.test.ts
Affected suites explicitly pass admin: true while preserving their existing assertions and scenarios.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • api7/aisix#791: Introduces the Admin listener enablement and readiness gating used by this harness change.
  • api7/aisix#792: Updates other E2E suites around the same spawnApp({ admin: ... }) switch.

Suggested reviewers: jarvis9443

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
E2e Test Quality Review ⚠️ Warning spawnApp still lets extra.admin.enabled override the generated admin block while readiness is gated off adminEnabled, so it can return before the admin listener is ready. Derive readiness from the final effective admin config (or reject extra.admin) so /admin/v1/health is awaited whenever the listener is actually bound.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: the e2e harness now defaults to admin-off, and affected tests opt in.
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.
Security Check ✅ Passed Changes are limited to e2e harness/admin opt-ins and comments; no new secret logging, auth bypass, persistence, TLS, or ownership issues found.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/e2e-admin-off-default

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.

@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

🧹 Nitpick comments (1)
tests/e2e/src/harness/app.ts (1)

156-156: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add regression coverage for the default-off contract.

The changed callers now opt into admin: true, so add a real-backend harness test that calls spawnApp() without overrides and verifies proxy/metrics readiness while the admin health endpoint remains unavailable. As per coding guidelines, define verifiable success criteria and write validation tests for changed 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 `@tests/e2e/src/harness/app.ts` at line 156, Add regression coverage for the
default-off behavior around spawnApp(), using the real-backend harness without
overrides. Verify proxy and metrics become ready while the admin health endpoint
remains unavailable, with explicit assertions for each outcome and success
criteria covering the default adminEnabled value.

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.

Inline comments:
In `@tests/e2e/src/harness/app.ts`:
- Line 156: Update spawnApp’s admin readiness flow so adminEnabled reflects the
effective admin configuration after overrides.extra is merged, preventing
extra.admin.enabled from enabling a listener without the corresponding health
gate. Either reject extra.admin in favor of overrides.admin or derive both
generated configuration and readiness from the same effective admin setting.

---

Nitpick comments:
In `@tests/e2e/src/harness/app.ts`:
- Line 156: Add regression coverage for the default-off behavior around
spawnApp(), using the real-backend harness without overrides. Verify proxy and
metrics become ready while the admin health endpoint remains unavailable, with
explicit assertions for each outcome and success criteria covering the default
adminEnabled value.
🪄 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: 6a88f9c8-2fba-4b23-b503-c38ede345ff8

📥 Commits

Reviewing files that changed from the base of the PR and between b3ac72c and 5f84ea9.

📒 Files selected for processing (10)
  • tests/e2e/src/cases/apikey-budget-e2e.test.ts
  • tests/e2e/src/cases/apikey-lifecycle-e2e.test.ts
  • tests/e2e/src/cases/auth-baseline-e2e.test.ts
  • tests/e2e/src/cases/file-resource-source-e2e.test.ts
  • tests/e2e/src/cases/health-minimal-e2e.test.ts
  • tests/e2e/src/cases/openai-sdk-compat.test.ts
  • tests/e2e/src/cases/prometheus-metrics-e2e.test.ts
  • tests/e2e/src/cases/seed-vs-admin-characterization-e2e.test.ts
  • tests/e2e/src/cases/status-models-e2e.test.ts
  • tests/e2e/src/harness/app.ts

Comment thread tests/e2e/src/harness/app.ts
Cold-audit LOW: keep admin:true only on the beforeAll app, whose
`fetch(${app.adminUrl}/metrics)` 404 assertion needs the admin listener
bound; the custom-path and prometheus-false spawns only probe the metrics
port, so drop their redundant admin:true and let them run admin-off. Also
correct the beforeAll comment to state the real reason admin is bound.
@moonming

Copy link
Copy Markdown
Collaborator Author

Independent cold audit (2 lenses — completeness / over-marking + default correctness). PASS, zero blocking. Both lenses converged: the admin-off default flip is correct and complete — exactly the 9 case files that make a real admin-listener request are marked admin: true (every spawnApp site within them, including the ctx.skip-gated status-models file-mode block); the 5 unmarked AdminClient files only call listModelStatuses (metrics listener); #792-migrated + admin-disabled correctly stay admin-off. No admin-dependent file or site was left on the new admin-off default — the 150/150 green full suite confirms it.

Two LOW nits, both the inverse of a break (admin over-applied in the held-back prometheus-metrics, nothing runs admin-off-where-needed), both fixed in 639a30a:

  1. The beforeAll comment misstated why admin is bound. The real coupling is the fetch(${app.adminUrl}/metrics) → 404 assertion (proving the admin listener is bound but does not serve /metrics); an unbound listener would connection-refuse, not 404. Comment corrected.
  2. The custom-path and prometheus: false auxiliary spawns carried redundant admin: true (they only probe the metrics port). Dropped — they now run admin-off, keeping admin: true only on the beforeAll app the 404 assertion needs.

Verification: prometheus-metrics 5/5 green after the change (the 2 auxiliary spawns pass admin-off); tsc clean; full suite was 150/150 green on the prior head.

…ss gate

CodeRabbit: `overrides.extra` is spread over the generated config at the
top level, so an `extra.admin` would replace the generated admin block and
could bind the listener while readiness still keys off `adminEnabled` and
skips the admin health gate. Reject `extra.admin` so the `admin` boolean
stays the single source of truth for the admin listener.
@moonming

Copy link
Copy Markdown
Collaborator Author

CodeRabbit (readiness vs extra.admin): fixed in the latest commit. spawnApp now throws if overrides.extra contains an admin key, so the admin boolean stays the single source of truth for the admin listener and readiness can't diverge from the effective config. Verified no existing test sets admin via extra (grep clean), and an extra-using test still passes.

@moonming
moonming merged commit 145ad54 into main Jul 22, 2026
11 checks passed
@moonming
moonming deleted the feat/e2e-admin-off-default branch July 22, 2026 04:09
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