Skip to content

test(status): add unit tests for the version and config_dump handlers - #1851

Open
Dreamstick9 wants to merge 1 commit into
kmesh-net:mainfrom
Dreamstick9:test/status-server-handler-tests
Open

Dreamstick9 wants to merge 1 commit into
kmesh-net:mainfrom
Dreamstick9:test/status-server-handler-tests

Conversation

@Dreamstick9

Copy link
Copy Markdown

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Adds unit tests for two handlers of the admin status server (localhost:15200) that currently have no test coverage at all:

  • version (pkg/status/status_server.go:117): serves the daemon build info, used by kmeshctl version. New test TestServer_version asserts a 200 response whose JSON body round-trips to exactly version.Get().
  • configDumpAds (pkg/status/status_server.go:446): serves /debug/config_dump/kernel-native, used by kmeshctl dump. New test TestServer_configDumpAds covers three behaviors:
    • a daemon without an ads controller (nil xdsClient, or dual-engine mode) returns 400 with the exact Invalid Client Mode body;
    • an ads-mode daemon with an empty cache returns 200 with an empty, protojson-parseable ConfigDump;
    • a populated ads cache returns 200 with all seeded cluster/listener/route names and versionInfo: v2.

The ads-mode cases build the controller via ads.NewController(nil) (the same construction pkg/controller/ads tests already use), so they exercise the real in-memory AdsCache without needing any bpf map — mirroring how TestServer_configDumpWorkload tests the dual-engine analogue.

Only pkg/status/status_server_test.go is changed; no production code is touched. The new tests are inserted next to the related existing tests (rather than appended at the end of the file) to keep the file grouped by handler and avoid conflicting with other in-flight test PRs.

Which issue(s) this PR fixes:

None

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@kmesh-bot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign hzxuzhonghu for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@codecov

codecov Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.75%. Comparing base (63e0279) to head (c6e1534).
⚠️ Report is 1 commits behind head on main.
see 2 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c88ef30...c6e1534. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The version and configDumpAds handlers of the admin status server had no
unit test coverage. Add tests asserting that the version endpoint serves
the build info as JSON, and that the kernel-native config_dump endpoint
rejects non-ads clients with 400 and correctly dumps clusters, listeners
and routes seeded into the in-memory ads cache.

Signed-off-by: Kushagar Garg <dreamstick909@gmail.com>
@Dreamstick9
Dreamstick9 force-pushed the test/status-server-handler-tests branch from 5d57da7 to c6e1534 Compare August 3, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants