Skip to content

test: migrate runtime coverage toward ginkgo e2e#3

Open
guoqqqi wants to merge 5 commits intomasterfrom
codex/local-stability-ginkgo-migration
Open

test: migrate runtime coverage toward ginkgo e2e#3
guoqqqi wants to merge 5 commits intomasterfrom
codex/local-stability-ginkgo-migration

Conversation

@guoqqqi
Copy link
Copy Markdown

@guoqqqi guoqqqi commented Apr 14, 2026

Summary

  • migrate the E2E entrypoint to Ginkgo and add a local-stability spec that exercises the current route/service, debug trace, secret, and stream-route workflows against a real environment
  • enforce the new testing policy by removing command-level Admin API mock tests and replacing the remaining coverage with pure logic unit tests only
  • fix two CLI mismatches surfaced by issue Follow-up: a7 test / skills / docs review findings #1: secret create now accepts the documented positional ID form, and stream-route update -f no longer incorrectly requires --upstream-id
  • update docs/testing-strategy.md, Makefile, and the E2E workflow so local and CI execution use the same Ginkgo-based path

Validation

  • go test ./...
  • go test -c -tags=e2e ./test/e2e

Notes

  • Live E2E execution was not possible in this shell because A7_ADMIN_URL, A7_TOKEN, A7_GATEWAY_URL, and HTTPBIN_URL are not set here.
  • This PR builds the migration rail for the remaining test/e2e/*.go cases while making new and modified E2E coverage Ginkgo-based immediately.

Refs #1

Summary by CodeRabbit

Release Notes

  • New Features

    • Secret provider creation now accepts optional positional arguments for provider/ID.
  • Tests

    • Modernized E2E test suite with updated testing framework and infrastructure.
    • Adjusted command execution timeouts for improved test reliability.
  • Documentation

    • Updated testing strategy guidelines with refined best practices.
  • Chores

    • Updated Go toolchain and added testing framework dependencies.

Copilot AI review requested due to automatic review settings April 14, 2026 14:11
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2026

Warning

Rate limit exceeded

@guoqqqi has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 33 minutes and 21 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 33 minutes and 21 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 78573c00-73ad-4c37-9b45-78d3864c165b

📥 Commits

Reviewing files that changed from the base of the PR and between 0069781 and 14a17fb.

📒 Files selected for processing (8)
  • .github/workflows/e2e.yml
  • pkg/cmd/secret/create/create.go
  • test/e2e/config_sync_test.go
  • test/e2e/consumer_test.go
  • test/e2e/local_stability_ginkgo_test.go
  • test/e2e/route_test.go
  • test/e2e/secret_test.go
  • test/e2e/stream_route_test.go
📝 Walkthrough

Walkthrough

This PR migrates the test suite from mocked HTTP-based unit tests to an E2E framework using Ginkgo v2. Changes include updating Go dependencies, rewriting testing documentation to mandate E2E coverage for API-dependent features, adding Ginkgo test infrastructure, deleting numerous command-level mocked tests, implementing new E2E test cases with real gateway interactions, and updating Makefile and CI workflows to execute E2E tests.

Changes

Cohort / File(s) Summary
Build and Toolchain
go.mod, .github/workflows/e2e.yml, Makefile
Updated Go toolchain to 1.23.0, added Ginkgo v2 and Gomega dependencies, increased E2E job timeout from 30 to 50 minutes, and switched test runner from go test to Ginkgo with increased timeout and parallel-execution restrictions.
Testing Documentation
docs/testing-strategy.md
Removed legacy coverage/fixture requirements; introduced Principles section restricting unit tests to self-contained logic, requiring E2E for API-dependent features, and standardizing on Ginkgo for new E2E coverage. Added Test Pyramid specification and environment variable requirements (A7_ADMIN_URL, A7_TOKEN, etc.).
Test Infrastructure Setup
test/e2e/setup_test.go, test/e2e/e2e_suite_test.go
Introduced testTB interface abstracting test handle methods; added Ginkgo suite entry point (TestE2E) with RegisterFailHandler and RunSpecs.
Core E2E Test Suite
test/e2e/local_stability_ginkgo_test.go
New Ginkgo v2-based E2E suite covering a7 version verification, route forwarding via services, debug tracing, secret provider management, and stream route file-based updates with real gateway interaction.
Updated E2E Helpers
test/e2e/consumer_test.go, test/e2e/debug_test.go, test/e2e/route_test.go, test/e2e/service_test.go, test/e2e/stream_route_test.go, test/e2e/secret_test.go
Updated helper signatures to accept testTB interface; added service lifecycle management and polling-based gateway status verification; replaced upstream JSON with service-backed routes; added waitForGatewayStatus helper.
E2E Support
test/e2e/config_sync_test.go
Added helpers (sanitizeDumpForSync, trimDumpForRoundtrip, filterResourcesByID) to preprocess dumped config before sync operations.
Unit Test Refactoring
internal/update/github_test.go, pkg/api/client_test.go
Replaced httptest.NewServer with custom roundTripFunc implementing http.RoundTripper; reduced test scope from integration-style to focused unit tests on helper functions and transport behavior.
Deleted Mocked Command Tests
pkg/cmd/config/diff/diff_test.go, pkg/cmd/config/dump/dump_test.go, pkg/cmd/config/sync/sync_test.go, and 50+ similar files across consumer, consumer-group, credential, debug, gateway-group, global-rule, plugin-config, plugin-metadata, plugin, proto, route, secret, service, ssl, stream-route, upstream packages
Removed entire test suites that used httpmock.Registry to mock APISIX admin API responses; tests exercised command-level control flow with mocked HTTP clients and verified both output formatting and HTTP interaction patterns.
Production Code Adjustments
pkg/cmd/secret/create/create.go, pkg/cmd/stream-route/update/update.go
Enhanced secret create to accept optional positional provider/id argument; deferred httpClient initialization in stream-route update to allow file-based updates without --upstream-id requirement.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
E2e Test Quality Review ⚠️ Warning The PR contains critical E2E test quality issues: secret create accepts conflicting --id and positional arguments without validation, error handling silently swallows API failures or converts them to test skips, config_sync_test lacks fail-fast validation for missing resources, and .github/workflows/e2e.yml uses Go 1.22 while go.mod requires 1.23.0. Add mutual exclusivity validation in secret create, fix error handling to report real API failures instead of silently ignoring them, add assertions in config_sync_test for missing resources, update workflow to use Go 1.23 or later to match go.mod requirements.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: migrate runtime coverage toward ginkgo e2e' clearly summarizes the main change: migrating test infrastructure from the current testing approach to a Ginkgo-based E2E framework.
Security Check ✅ Passed PR refactors E2E test infrastructure without introducing sensitive data logging, authorization bypasses, or cryptographic configuration errors.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/local-stability-ginkgo-migration

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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Migrates the E2E test entrypoint to a Ginkgo-based suite, adds a local-stability spec that exercises real EE/gateway workflows, and enforces the updated testing strategy by removing Admin-API-mocking command tests while fixing CLI behavior mismatches.

Changes:

  • Add Ginkgo/Gomega E2E suite + “local stability” specs and supporting E2E helpers/cleanup improvements.
  • Remove command-level httpmock/httptest-based CLI tests per updated testing policy and shift remaining verification to E2E + pure logic tests.
  • Fix CLI behavior: secret create supports positional provider/id, and stream-route update -f doesn’t require --upstream-id.

Reviewed changes

Copilot reviewed 88 out of 89 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/e2e/stream_route_test.go Align stream-route E2E CRUD with service-backed model and stronger cleanup.
test/e2e/setup_test.go Introduce testTB interface + update helpers to accept both *testing.T and Ginkgo GinkgoT().
test/e2e/service_test.go Improve Admin API cleanup semantics and error surfacing for service deletion.
test/e2e/secret_test.go Generalize secret cleanup helper to accept testTB.
test/e2e/local_stability_ginkgo_test.go Add new Ginkgo Ordered E2E “local stability” spec covering route/service, trace, secret, stream-route flows.
test/e2e/e2e_suite_test.go Add Ginkgo suite entrypoint (RunSpecs).
test/e2e/consumer_test.go Add gateway poll helper and adjust key-auth E2E to use service-backed routes and propagation polling.
test/e2e/config_sync_test.go Add dump sanitization/trim helpers to reduce shared-env flakiness and focus roundtrip on owned resources.
pkg/cmd/upstream/update/update_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/upstream/list/list_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/upstream/get/get_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/upstream/export/export_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/upstream/delete/delete_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/upstream/create/create_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/stream-route/update/update_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/stream-route/update/update.go Allow stream-route update -f without requiring --upstream-id.
pkg/cmd/stream-route/list/list_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/stream-route/get/get_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/stream-route/export/export_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/stream-route/delete/delete_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/stream-route/create/create_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/ssl/export/export_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/service/update/update_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/service/list/list_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/service/get/get_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/service/export/export_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/service/delete/delete_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/service/create/create_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/secret/update/update_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/secret/list/list_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/secret/get/get_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/secret/delete/delete_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/secret/create/create_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/secret/create/create.go Update secret create to accept positional [provider/id].
pkg/cmd/route/update/update_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/route/get/get_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/route/export/export_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/route/delete/delete_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/route/create/create_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/proto/update/update_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/proto/list/list_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/proto/get/get_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/proto/export/export_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/proto/delete/delete_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/proto/create/create_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/plugin/get/get_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/plugin-metadata/update/update_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/plugin-metadata/get/get_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/plugin-metadata/delete/delete_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/plugin-metadata/create/create_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/plugin-config/update/update_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/plugin-config/list/list_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/plugin-config/get/get_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/plugin-config/export/export_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/plugin-config/delete/delete_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/plugin-config/create/create_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/global-rule/list/list_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/global-rule/get/get_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/global-rule/export/export_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/gateway-group/list/list_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/credential/update/update_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/credential/list/list_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/credential/get/get_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/credential/delete/delete_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/credential/create/create_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/context/create/create_test.go Remove httptest-based command coverage per new testing policy.
pkg/cmd/consumer/list/list_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/consumer/export/export_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/consumer/create/create_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/consumer-group/update/update_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/consumer-group/list/list_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/consumer-group/get/get_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/consumer-group/export/export_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/consumer-group/delete/delete_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/consumer-group/create/create_test.go Remove httpmock-based command tests per new testing policy.
pkg/cmd/config/sync/sync_test.go Remove httpmock-based config sync command tests per new testing policy.
pkg/cmd/config/diff/diff_test.go Remove httpmock-based config diff command tests per new testing policy.
internal/update/github_test.go Replace httptest server with stub RoundTripper-based tests.
go.mod Bump Go version and add Ginkgo/Gomega dependencies for E2E.
docs/testing-strategy.md Update testing strategy (Ginkgo E2E, avoid Admin API mocks).
Makefile Run E2E via Ginkgo CLI for consistent local/CI behavior.
.github/workflows/e2e.yml Adjust E2E workflow timeout and module download step.
Comments suppressed due to low confidence (4)

test/e2e/consumer_test.go:1

  • In waitForGatewayStatus, the response body is closed without draining. In tight polling loops this can prevent connection reuse and cause resource/FD churn, especially in CI. Consider draining to io.Discard (up to a reasonable cap) before closing, and optionally handling the Close() error.
    test/e2e/stream_route_test.go:1
  • deleteStreamRouteViaAdmin silently ignores non-nil errors and does not check for non-2xx status codes, which can hide cleanup failures and lead to resource collisions across E2E runs. It would be more robust to mirror deleteServiceViaAdmin: fail (or at least Errorf) on request errors and unexpected status codes, while allowing 404 as a no-op, and always closing the body.
    test/e2e/setup_test.go:1
  • This custom testTB duplicates a subset of testing.TB and can drift over time (e.g., missing methods that helpers/libraries may start relying on). Prefer taking a testing.TB directly where possible; it already includes Helper, TempDir, Cleanup, and skip/fail methods, and improves interoperability with both *testing.T and Ginkgo's GinkgoT().
    pkg/cmd/secret/create/create.go:1
  • With cobra.MaximumNArgs(1), secret create accepts zero args even though the Use string documents a positional [provider/id]. If the command also supports --id, consider adding an Args validator that enforces 'exactly one of positional arg or --id' and produces a clear, up-to-date error message; otherwise, consider cobra.ExactArgs(1) to match the documented usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -18,6 +18,9 @@ jobs:
with:
go-version: '1.22'
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow pins Go 1.22, but go.mod now requires Go 1.23.0. This will fail in CI with a 'go.mod requires go >= 1.23' style error. Update actions/setup-go to use Go 1.23.x (or align go.mod back to 1.22) so CI can build and run E2E.

Suggested change
go-version: '1.22'
go-version: '1.23'

Copilot uses AI. Check for mistakes.
module github.com/api7/a7

go 1.22.3
go 1.23.0
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module now requires Go 1.23.0, which needs to be consistently reflected across CI (and any pinned local dev tooling). Ensure all workflows and release/build pipelines that use go-version or pinned toolchains are updated to Go 1.23.x to avoid build failures.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

Caution

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

⚠️ Outside diff range comments (2)
.github/workflows/e2e.yml (1)

21-29: ⚠️ Potential issue | 🟠 Major

Wire A7_GATEWAY_URL and HTTPBIN_URL into the E2E workflow.

The make test-e2e step (lines 26-28) only provides A7_ADMIN_URL, A7_TOKEN, and A7_GATEWAY_GROUP. However, test/e2e/setup_test.go references A7_GATEWAY_URL and HTTPBIN_URL and skips gateway traffic and httpbin-dependent tests when these are absent. Add these to the env block to ensure full test coverage in CI.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/e2e.yml around lines 21 - 29, Add the missing environment
variables A7_GATEWAY_URL and HTTPBIN_URL to the "Run E2E tests" step so make
test-e2e runs with the same inputs expected by test/e2e/setup_test.go; update
the env block that currently sets A7_ADMIN_URL, A7_TOKEN, and A7_GATEWAY_GROUP
to also set A7_GATEWAY_URL: ${{ secrets.A7_GATEWAY_URL }} and HTTPBIN_URL: ${{
secrets.HTTPBIN_URL }} (or appropriate secret names) so tests that check
A7_GATEWAY_URL and HTTPBIN_URL are not skipped.
test/e2e/consumer_test.go (1)

59-64: ⚠️ Potential issue | 🟠 Major

Keep consumer cleanup idempotent, not silent.

This makes the second delete in TestConsumer_CRUD harmless, but it also hides real cleanup failures and leaked consumers. Please special-case not-found only and surface the rest.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/e2e/consumer_test.go` around lines 59 - 64, The deleteConsumerViaAdmin
helper currently swallows errors and only closes resp.Body when err==nil, hiding
real failures; update it to always close resp.Body when resp is non-nil, and
treat HTTP 404 (not found) as a no-op but surface any other non-success status
or err via t.Fatalf/t.Errorf; reference the deleteConsumerViaAdmin function and
the runtimeAdminAPI call to locate where to check resp.StatusCode and err, close
the response body, and fail the test on unexpected errors.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@go.mod`:
- Line 3: The project declares Go 1.23.0 in go.mod but the E2E workflow still
uses Go 1.22; update the GitHub Actions e2e workflow's setup step (the action
that uses the go-version/go-version matrix entry) to use 1.23.0 (or 1.23) so the
runner's Go matches the module's required version and avoids failing on go mod
download/run; also check any other workflow steps or matrix entries that pin Go
versions and align them to 1.23.0.

In `@pkg/cmd/secret/create/create.go`:
- Around line 39-42: The RunE handler currently unconditionally overwrites
opts.ID with the positional arg (in the RunE func for the cobra.Command),
allowing conflicting sources like `a7 secret create foo --id bar`; change the
logic to detect both sources and reject or require them to match: if args length
> 0 and opts.ID is non-empty, return an error unless args[0] == opts.ID;
otherwise set opts.ID = args[0] only when opts.ID is empty; ensure this
validation happens early in the RunE before proceeding with creation.

In `@test/e2e/config_sync_test.go`:
- Around line 43-48: The test currently replaces cfg["services"] and
cfg["routes"] with filtered slices that may be empty, masking a roundtrip dump
regression; update the test in config_sync_test.go to check the results of
filterResourcesByID (for the variables/services identified by serviceID and
routeID) and fail fast (use t.Fatalf or t.Fatalf-style failure) if the filtered
slice is empty so the test fails when the target service or route is dropped
rather than silently proceeding with an empty collection; keep using the
existing filterResourcesByID helper and the cfg map keys "services" and "routes"
to locate the values.

In `@test/e2e/consumer_test.go`:
- Around line 21-49: The polling helper waitForGatewayStatus currently returns
lastErr on timeout even if an HTTP response was observed earlier, which lets a
transient transport error override a valid lastStatus; change the final return
logic so that a transport error (lastErr) is only returned when no HTTP status
was ever observed (lastStatus == 0). In practice, update the tail of
waitForGatewayStatus to check lastStatus == 0 && lastErr != nil and return the
transport error only in that case, otherwise return the lastStatus with a nil
error so callers like route_test.go and debug_test.go get the last observed HTTP
code.

In `@test/e2e/local_stability_ginkgo_test.go`:
- Around line 101-104: The test currently treats any error from runA7WithEnv
when creating the secret as a skip, which can hide real regressions; change the
logic in the secret creation call (the stdout, stderr, err := runA7WithEnv(env,
"secret", "create", secretID, "-f", tmpFile, "-g", gatewayGroup) block) so you
only call Skip for known environment-capability failures (e.g., detect specific
error strings or a sentinel error returned by runA7WithEnv) and for all other
errors fail the test (use t.Fatalf or t.Error/t.FailNow) with the captured
stdout/stderr to surface regressions; apply the same change to the analogous
runA7WithEnv error handling in the later secret-update/assertion block.

In `@test/e2e/route_test.go`:
- Around line 26-31: deleteRouteViaAdmin currently swallows all errors from
runtimeAdminAPI which hides real failures; change it to call runtimeAdminAPI and
if it returns an error or a non-2xx response, inspect the response (resp != nil)
and only ignore the expected "not found" case (HTTP 404) — for any other error
or status code, report the failure via the test helper (t.Fatalf or t.Errorf) so
leaked routes fail the test; ensure you always close resp.Body when resp is
non-nil. Reference: function deleteRouteViaAdmin and runtimeAdminAPI.

---

Outside diff comments:
In @.github/workflows/e2e.yml:
- Around line 21-29: Add the missing environment variables A7_GATEWAY_URL and
HTTPBIN_URL to the "Run E2E tests" step so make test-e2e runs with the same
inputs expected by test/e2e/setup_test.go; update the env block that currently
sets A7_ADMIN_URL, A7_TOKEN, and A7_GATEWAY_GROUP to also set A7_GATEWAY_URL:
${{ secrets.A7_GATEWAY_URL }} and HTTPBIN_URL: ${{ secrets.HTTPBIN_URL }} (or
appropriate secret names) so tests that check A7_GATEWAY_URL and HTTPBIN_URL are
not skipped.

In `@test/e2e/consumer_test.go`:
- Around line 59-64: The deleteConsumerViaAdmin helper currently swallows errors
and only closes resp.Body when err==nil, hiding real failures; update it to
always close resp.Body when resp is non-nil, and treat HTTP 404 (not found) as a
no-op but surface any other non-success status or err via t.Fatalf/t.Errorf;
reference the deleteConsumerViaAdmin function and the runtimeAdminAPI call to
locate where to check resp.StatusCode and err, close the response body, and fail
the test on unexpected errors.
🪄 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: 3476bfe5-185e-4b9b-9cf0-13ed5291e5e5

📥 Commits

Reviewing files that changed from the base of the PR and between 69c5178 and 0069781.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (88)
  • .github/workflows/e2e.yml
  • Makefile
  • docs/testing-strategy.md
  • go.mod
  • internal/update/github_test.go
  • pkg/api/client_test.go
  • pkg/cmd/config/diff/diff_test.go
  • pkg/cmd/config/dump/dump_test.go
  • pkg/cmd/config/sync/sync_test.go
  • pkg/cmd/consumer-group/create/create_test.go
  • pkg/cmd/consumer-group/delete/delete_test.go
  • pkg/cmd/consumer-group/export/export_test.go
  • pkg/cmd/consumer-group/get/get_test.go
  • pkg/cmd/consumer-group/list/list_test.go
  • pkg/cmd/consumer-group/update/update_test.go
  • pkg/cmd/consumer/create/create_test.go
  • pkg/cmd/consumer/export/export_test.go
  • pkg/cmd/consumer/list/list_test.go
  • pkg/cmd/context/create/create_test.go
  • pkg/cmd/credential/create/create_test.go
  • pkg/cmd/credential/delete/delete_test.go
  • pkg/cmd/credential/get/get_test.go
  • pkg/cmd/credential/list/list_test.go
  • pkg/cmd/credential/update/update_test.go
  • pkg/cmd/debug/trace/trace_test.go
  • pkg/cmd/gateway-group/list/list_test.go
  • pkg/cmd/global-rule/export/export_test.go
  • pkg/cmd/global-rule/get/get_test.go
  • pkg/cmd/global-rule/list/list_test.go
  • pkg/cmd/plugin-config/create/create_test.go
  • pkg/cmd/plugin-config/delete/delete_test.go
  • pkg/cmd/plugin-config/export/export_test.go
  • pkg/cmd/plugin-config/get/get_test.go
  • pkg/cmd/plugin-config/list/list_test.go
  • pkg/cmd/plugin-config/update/update_test.go
  • pkg/cmd/plugin-metadata/create/create_test.go
  • pkg/cmd/plugin-metadata/delete/delete_test.go
  • pkg/cmd/plugin-metadata/get/get_test.go
  • pkg/cmd/plugin-metadata/update/update_test.go
  • pkg/cmd/plugin/get/get_test.go
  • pkg/cmd/proto/create/create_test.go
  • pkg/cmd/proto/delete/delete_test.go
  • pkg/cmd/proto/export/export_test.go
  • pkg/cmd/proto/get/get_test.go
  • pkg/cmd/proto/list/list_test.go
  • pkg/cmd/proto/update/update_test.go
  • pkg/cmd/route/create/create_test.go
  • pkg/cmd/route/delete/delete_test.go
  • pkg/cmd/route/export/export_test.go
  • pkg/cmd/route/get/get_test.go
  • pkg/cmd/route/list/list_test.go
  • pkg/cmd/route/update/update_test.go
  • pkg/cmd/secret/create/create.go
  • pkg/cmd/secret/create/create_test.go
  • pkg/cmd/secret/delete/delete_test.go
  • pkg/cmd/secret/get/get_test.go
  • pkg/cmd/secret/list/list_test.go
  • pkg/cmd/secret/update/update_test.go
  • pkg/cmd/service/create/create_test.go
  • pkg/cmd/service/delete/delete_test.go
  • pkg/cmd/service/export/export_test.go
  • pkg/cmd/service/get/get_test.go
  • pkg/cmd/service/list/list_test.go
  • pkg/cmd/service/update/update_test.go
  • pkg/cmd/ssl/export/export_test.go
  • pkg/cmd/stream-route/create/create_test.go
  • pkg/cmd/stream-route/delete/delete_test.go
  • pkg/cmd/stream-route/export/export_test.go
  • pkg/cmd/stream-route/get/get_test.go
  • pkg/cmd/stream-route/list/list_test.go
  • pkg/cmd/stream-route/update/update.go
  • pkg/cmd/stream-route/update/update_test.go
  • pkg/cmd/upstream/create/create_test.go
  • pkg/cmd/upstream/delete/delete_test.go
  • pkg/cmd/upstream/export/export_test.go
  • pkg/cmd/upstream/get/get_test.go
  • pkg/cmd/upstream/list/list_test.go
  • pkg/cmd/upstream/update/update_test.go
  • test/e2e/config_sync_test.go
  • test/e2e/consumer_test.go
  • test/e2e/debug_test.go
  • test/e2e/e2e_suite_test.go
  • test/e2e/local_stability_ginkgo_test.go
  • test/e2e/route_test.go
  • test/e2e/secret_test.go
  • test/e2e/service_test.go
  • test/e2e/setup_test.go
  • test/e2e/stream_route_test.go
💤 Files with no reviewable changes (69)
  • pkg/cmd/consumer-group/delete/delete_test.go
  • pkg/cmd/credential/list/list_test.go
  • pkg/cmd/credential/delete/delete_test.go
  • pkg/cmd/secret/get/get_test.go
  • pkg/cmd/consumer/export/export_test.go
  • pkg/cmd/consumer/create/create_test.go
  • pkg/cmd/plugin/get/get_test.go
  • pkg/cmd/plugin-metadata/get/get_test.go
  • pkg/cmd/upstream/get/get_test.go
  • pkg/cmd/upstream/export/export_test.go
  • pkg/cmd/route/export/export_test.go
  • pkg/cmd/plugin-config/update/update_test.go
  • pkg/cmd/upstream/create/create_test.go
  • pkg/cmd/secret/update/update_test.go
  • pkg/cmd/plugin-metadata/update/update_test.go
  • pkg/cmd/global-rule/get/get_test.go
  • pkg/cmd/credential/create/create_test.go
  • pkg/cmd/route/delete/delete_test.go
  • pkg/cmd/proto/update/update_test.go
  • pkg/cmd/consumer/list/list_test.go
  • pkg/cmd/route/list/list_test.go
  • pkg/cmd/service/delete/delete_test.go
  • pkg/cmd/credential/update/update_test.go
  • pkg/cmd/route/update/update_test.go
  • pkg/cmd/config/dump/dump_test.go
  • pkg/cmd/secret/create/create_test.go
  • pkg/cmd/config/sync/sync_test.go
  • pkg/cmd/consumer-group/create/create_test.go
  • pkg/cmd/route/create/create_test.go
  • pkg/cmd/context/create/create_test.go
  • pkg/cmd/plugin-config/export/export_test.go
  • pkg/cmd/secret/delete/delete_test.go
  • pkg/cmd/consumer-group/export/export_test.go
  • pkg/cmd/plugin-config/list/list_test.go
  • pkg/cmd/proto/create/create_test.go
  • pkg/cmd/secret/list/list_test.go
  • pkg/cmd/upstream/delete/delete_test.go
  • pkg/cmd/proto/get/get_test.go
  • pkg/cmd/consumer-group/get/get_test.go
  • pkg/cmd/service/create/create_test.go
  • pkg/cmd/stream-route/export/export_test.go
  • pkg/cmd/service/get/get_test.go
  • pkg/cmd/stream-route/delete/delete_test.go
  • pkg/cmd/service/list/list_test.go
  • pkg/cmd/proto/export/export_test.go
  • pkg/cmd/global-rule/export/export_test.go
  • pkg/cmd/gateway-group/list/list_test.go
  • pkg/cmd/plugin-config/create/create_test.go
  • pkg/cmd/consumer-group/list/list_test.go
  • pkg/cmd/upstream/list/list_test.go
  • pkg/cmd/plugin-config/delete/delete_test.go
  • pkg/cmd/service/export/export_test.go
  • pkg/cmd/plugin-metadata/create/create_test.go
  • pkg/cmd/proto/list/list_test.go
  • pkg/cmd/credential/get/get_test.go
  • pkg/cmd/stream-route/create/create_test.go
  • pkg/cmd/global-rule/list/list_test.go
  • pkg/cmd/upstream/update/update_test.go
  • pkg/cmd/ssl/export/export_test.go
  • pkg/cmd/stream-route/get/get_test.go
  • pkg/cmd/plugin-metadata/delete/delete_test.go
  • pkg/cmd/stream-route/update/update_test.go
  • pkg/cmd/route/get/get_test.go
  • pkg/cmd/service/update/update_test.go
  • pkg/cmd/config/diff/diff_test.go
  • pkg/cmd/stream-route/list/list_test.go
  • pkg/cmd/proto/delete/delete_test.go
  • pkg/cmd/plugin-config/get/get_test.go
  • pkg/cmd/consumer-group/update/update_test.go

Comment on lines +101 to +104
stdout, stderr, err := runA7WithEnv(env, "secret", "create", secretID, "-f", tmpFile, "-g", gatewayGroup)
if err != nil {
Skip(fmt.Sprintf("secret create failed in this environment: stdout=%s stderr=%s", stdout, stderr))
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Don't turn CLI regressions into skips.

Both branches currently skip on any runA7WithEnv error. That means the positional secret create flow this PR is trying to lock in can regress without failing, and a broken stream-route setup will hide the update assertion entirely. Please skip only on known environment-capability errors and fail everything else.

Also applies to: 131-134

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/e2e/local_stability_ginkgo_test.go` around lines 101 - 104, The test
currently treats any error from runA7WithEnv when creating the secret as a skip,
which can hide real regressions; change the logic in the secret creation call
(the stdout, stderr, err := runA7WithEnv(env, "secret", "create", secretID,
"-f", tmpFile, "-g", gatewayGroup) block) so you only call Skip for known
environment-capability failures (e.g., detect specific error strings or a
sentinel error returned by runA7WithEnv) and for all other errors fail the test
(use t.Fatalf or t.Error/t.FailNow) with the captured stdout/stderr to surface
regressions; apply the same change to the analogous runA7WithEnv error handling
in the later secret-update/assertion block.

@guoqqqi
Copy link
Copy Markdown
Author

guoqqqi commented Apr 14, 2026

Addressed the valid review items in 14a17fb:

  • aligned .github/workflows/e2e.yml with go 1.23.0 and passed A7_GATEWAY_URL / HTTPBIN_URL
  • tightened secret create so positional ID and --id cannot silently conflict
  • made config_sync roundtrip fail fast when the dumped service/route disappears
  • fixed waitForGatewayStatus so a transient transport error does not override an observed HTTP status, and drained response bodies during polling
  • made route / consumer / secret / stream-route cleanup helpers idempotent without swallowing unexpected failures
  • narrowed the Ginkgo secret test so it only Skips on known environment capability gaps and fails on unexpected regressions

I did not apply the low-confidence suggestion to replace the custom testTB with testing.TB. GinkgoT() does not satisfy testing.TB on current Go because of the extra methods on testing.TB (for example ArtifactDir), so keeping a smaller helper interface here is intentional.

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.

2 participants