test(image): cover ACR referrer discovery at the regctl boundary - #84
Open
johnsonshi wants to merge 3 commits into
Open
test(image): cover ACR referrer discovery at the regctl boundary#84johnsonshi wants to merge 3 commits into
johnsonshi wants to merge 3 commits into
Conversation
Follow-up to the review on kvcache-ai#58, which noted that coverage started at `parse_overlaybd_referrer`, leaving the referrer *query* unverified: reintroducing `--filter-artifact-type` to `regctl artifact list` would pin discovery to a single artifactType and silently drop ACR streaming referrers while every parse-level test stayed green. Add a fake `regctl` that records its argv and replays a canned response, then assert `discover_overlaybd_referrer` lists referrers unfiltered and returns the ACR referrer. Confirmed by mutation: reintroducing the filter flag leaves all seven `parse_overlaybd_referrer` tests green and fails only the new test. Also cover the regctl failure path, which had no test: a registry error must surface as an error rather than `Ok(None)`, which would silently downgrade to a local pull-and-convert. Use literal artifactType wire values in the fixtures instead of the implementation constants, so an unintended edit to a constant is caught instead of being mirrored into the fixture, and pin both constants and their preference order in a dedicated test. Add a multi-arch case taken from a real ACR response: ACR attaches one streaming referrer per platform, all sharing the same artifactType, so several matches is the normal case for a multi-arch subject rather than an oddity.
Contributor
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). |
…viour The per-platform fixture comment claimed the multi-referrer path is the normal case. Verifying against a live ACR registry shows otherwise: referrers queried on a multi-arch tag return one per platform, but `resolve_fetched_manifest` never passes a tag or index. It hands `FetchedManifest::selected_image_ref` to discovery, which oci_image pins to the platform-resolved manifest digest, and that subject carries exactly one referrer. Reword the comment so it documents the fixture as a defensive lock on first-match selection rather than the common path. No behaviour or assertion changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 78ecb58e-c794-4a64-acd3-e00d8e81cbea
johnsonshi
marked this pull request as draft
July 30, 2026 04:42
The fake regctl script interpolated absolute fixture paths into single-quoted shell literals. TempDir is created beneath TMPDIR, so a TMPDIR containing an apostrophe or newline would break the generated script rather than fail cleanly. Derive the fixture directory from $0 inside the script and access argv, stdout and stderr through a quoted shell variable, so no filesystem path is embedded in shell source. This matches the fully static fake-helper script already used in the ACR client tests. Verified by running the resolver tests under TMPDIR="/tmp/it's a dir". Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 78ecb58e-c794-4a64-acd3-e00d8e81cbea
johnsonshi
marked this pull request as ready for review
July 30, 2026 05:51
johnsonshi
marked this pull request as draft
July 30, 2026 09:07
johnsonshi
marked this pull request as ready for review
August 13, 2026 02:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up for code quality on the review feedback in
#58 (review).
Both non-blocking suggestions from that review are addressed here. This PR changes no
production code — it is test-only.
1. Coverage now starts at the regctl boundary, not at the parser
The review noted that coverage started at
parse_overlaybd_referrer, so reintroducing--filter-artifact-typeto theregctl artifact listcommand would leave tests green whilebreaking ACR discovery.
discover_overlaybd_referrer_lists_referrers_unfiltered_and_finds_acr_streaminginstalls a fakeregctlthat records its argv and replays a canned referrers index, then asserts the listing isunfiltered and that the ACR referrer is returned.
I verified the test actually closes the gap by mutation — reintroducing the flag:
.arg("list") + .arg("--filter-artifact-type") + .arg(OVERLAYBD_NATIVE_ARTIFACT_TYPE) .arg("--format")All seven parse-level tests stay green; only the new test fails. That is exactly the regression
the review described.
The same fake-regctl harness also covers the failure path, which previously had no test: a
registry error must surface as an error rather than
Ok(None), sinceOk(None)would silentlydowngrade to a local pull-and-convert.
2. Fixtures use literal wire values
Fixtures now use the literal artifactType strings rather than the implementation constants, so an
unintended edit to a constant is caught instead of being mirrored into the fixture.
overlaybd_referrer_artifact_types_match_published_wire_valuesadditionally pins both constantsand their preference order, so a typo fails with a readable diff rather than only surfacing as a
missed referrer.
3. Fake regctl fixtures are located relative to
$0The fake
regctlscript originally interpolated absolute fixture paths into single-quoted shellliterals.
TempDiris created beneathTMPDIR, so aTMPDIRcontaining an apostrophe or newlinewould break the generated script rather than fail cleanly.
The script now derives its own directory from
$0and reachesargv,stdoutandstderrthrough a quoted shell variable, so no filesystem path is embedded in shell source. This matches
the fully static fake-helper script already used in the ACR client tests
(
snapshot::repository::backends::common::acr::client). Verified by running the resolver testsunder
TMPDIR="/tmp/it's a dir".Wire format verified against a real registry
Rather than trusting the fixture, I re-derived it from a live ACR registry with the same command
the code issues:
{ "schemaVersion": 2, "mediaType": "application/vnd.oci.image.index.v1+json", "manifests": [ { "digest": "sha256:1bdbcce5...", "artifactType": "application/vnd.azure.artifact.streaming.v1", "annotations": { "streaming.format": "overlaybd", "streaming.version": "v1", "streaming.platform.os": "linux", "streaming.platform.arch": "amd64" } }, { "digest": "sha256:3a5ae954...", "artifactType": "application/vnd.azure.artifact.streaming.v1", "annotations": { "streaming.format": "overlaybd", "streaming.version": "v1", "streaming.platform.os": "linux", "streaming.platform.arch": "arm64" } } ] }The artifactType literal matches byte-for-byte, so the fixture is faithful.
On platform selection, measured against the same registry:
regctl artifact liststreamtest:v1— multi-arch tag, resolves to an indexamd64+arm64streamtest@sha256:c4116d4d…— thelinux/amd64childamd64onlyresolve_fetched_manifestpassesfetched.selected_image_refinto discovery, andoci_imagepins that to the platform-resolved manifest digest via
image_ref_with_digest(¤t_ref, &manifest_digest). Discovery therefore never receives anindex, and the subject it does receive carries exactly one referrer, for the right architecture.
parse_overlaybd_referrer_selects_first_of_acr_per_platform_referrerskeeps the two-referrerpayload as a defensive lock on first-match selection.
The discovery path these tests cover was also exercised end to end against a live Premium ACR
registry and an AKS cluster, where a sandbox booted from an ACR artifact-streaming image — though
that exercises the production change from #58 rather than anything in this test-only PR.
Test results
cargo fmt --checkclean,cargo clippy --all-targets -- -D warningsclean.origin/main(8174bd9)The 3 failures are pre-existing and identical on unmodified
main(snapshot::p2p::tests::local_overlaybd_layers_*and
…::acr::source_image::tests::plans_descriptorless_sparse_overlaybd_delta_for_dense_export);they appear environment-specific to my aarch64 container and are unrelated to this change. Net
+4tests, no regressions.