test(npm): end-to-end remote conformance harness (S15 npm remote format plan: 16/16)

Summary

Step 16 of the S15 npm remote plan: an end-to-end conformance harness for a kind=2 npm repository. It drives an npm install through the production remote handlers behind the real dispatcher, over a real database and a loopback upstream registry. For both the full and the abbreviated packument:

  • The packument relays the upstream's dist-tags and re-points every dist.tarball at the remote repository. dist.shasum and dist.integrity arrive unchanged, and no upstream address appears in the body.
  • The upstream packument fetch carries the variant's media type as its Accept, which is what asks a real registry for the abbreviated document. A tarball fetch carries no Accept.
  • A tag install reads the tag off the relayed dist-tags and pulls only that version, so the upstream is asked for no tag document. This is S15 Packument proxy AC 10.
  • The first pull relays the upstream body with no ETag. A repeat install is a cache serve carrying the blob digest as its ETag, with no upstream request.
  • A conditional packument read with the cached validator answers 304, and a stale validator answers 200 from the cache.

The virtual harness (virtual_conformance_integration_test.go) now shares its pieces with the remote journey. Its loopback upstream takes the package, versions and dist-tags as parameters and serves each version's dist.integrity. The request drivers serveTarget, getPackument and pull sit on a vcClient both fixtures embed. vcRunValidatorSubtests takes the client, the upstream and the packument path, so both journeys run one copy of the conditional reads.

Size: 418 reviewable LOC (added plus removed) at ad5647e8e, of which 398 are the two test files.

Plan and spec amendments

Corrections to the S15 plan that this step's review proved:

  • The Step 16 Files entry names the virtual harness change, including the shared validator subtests.
  • The Testing Strategy places remote_conformance_integration_test.go in the end-to-end tier. It matches the integration glob but is no single proxy handler's suite.
  • The Open Questions record that the legacy GET /{package}/{tag} question does not gate Step 16. The harness installs by tag the way an npm client does, which never requests that route. #1127 criterion 12 asks the S15 owner the same question.
  • The Status table records this MR in row 16.

No spec change.

Merge order

!2944 (closed) (10io/retire-s06) also edits docs/plans/2026-07-15-npm-remote.md, in other sections. git merge-tree merges the two cleanly, so either can land first.

Governing ADRs

None governs this test-only change, and that was checked rather than assumed. ./scripts/adr-freshness.sh reports the mirror stale on ADR-007 only (database schema), which this change does not touch, and 2 internal ADRs it cannot read.

  • ADR-009 says client URLs are the same for every repository kind and the registry resolves the kind internally. The harness reaches the remote repository through the ordinary /:slug/npm/:repository_name/:package_name path and the real dispatcher.
  • ADR-023 names a conformance test suite as the check on a format's behavioral contracts. This harness is that check for the npm remote proxy, kept in-package beside the virtual one.

Testing

  • go test -tags=integration -race -count=3 -run 'TestNpm(Remote|Virtual)Conformance_InstallJourney' ./internal/format/npm/ against PostgreSQL 16 with the CI GUCs: every subtest passes in all three runs (75 results), with no data race.
  • Run alone, the tag install, the repeat install and both validator subtests pass (one variant each).
  • Each new check was broken in a scratch copy and the run went red: the relay's empty ETag, the warm validator, and the 304 expectation. Deleting the repeat-install warm-up fails that subtest alone and leaves the suite green, and the validator's warm-up read behaves the same way, which is the reason each one's comment gives.
  • Changing acceptFor to ask for the full document on the abbreviated target fails the three abbreviated subtests that compare the upstream request log, and the full run stays green.
  • golangci-lint run --build-tags=integration --max-same-issues=0 --max-issues-per-linter=0 --uniq-by-line=false ./internal/format/npm/ (2.14.0) reports no finding in the two changed files. CI lint does not compile integration-tagged files.
  • The test:integration job runs ./internal/format/npm/... on PostgreSQL 16, 17 and 18.

No e2e catalog row is added or changed. The rows under ## Remote repositories in docs/testing/e2e/npm.md, such as e2e.npm.remote.install-from-upstream, e2e.npm.remote.packument-conditional and e2e.npm.remote.tarball-cache-hit, already state what a client can observe of this journey, and this harness is the in-package conformance test behind them. No customer-visible surface changes, so docs/user/ is unaffected.

Closes #351 (closed)

Edited by Dzmitry (Dima) Meshcharakou

Merge request reports

Loading
Loading