Skip to content

tests: verify worker platform selection without QEMU#1076

Open
cpuguy83 wants to merge 1 commit into
project-dalec:mainfrom
cpuguy83:fix/cross-platform-test-no-qemu
Open

tests: verify worker platform selection without QEMU#1076
cpuguy83 wants to merge 1 commit into
project-dalec:mainfrom
cpuguy83:fix/cross-platform-test-no-qemu

Conversation

@cpuguy83

@cpuguy83 cpuguy83 commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Problem

The cross platform integration test built packages for a foreign architecture (arm64 on amd64 CI runners), which required QEMU emulation. QEMU frequently crashes in CI during this test (e.g. https://github.com/project-dalec/dalec/actions/runs/26779889971/job/78941218259?pr=1068).

Approach

Replace it with a native test that proves what the test actually cares about: the frontend selects the correct platform-specific worker image for a requested build platform — without any emulation or rebuilding the world.

  • A custom multi-platform worker image is built as an OCI layout index with one manifest per real platform the distros ship (linux/amd64 and linux/arm64). Each manifest embeds a /platform-marker file naming its own platform.
  • The index is registered with the build session (SolveOpt.OCIStores) and supplied as the distro worker context via an oci-layout: named context.
  • For each requested build platform, the test solves the worker target and asserts the returned image's /platform-marker matches the requested platform.

The distro worker target short-circuits when a worker context image is provided and returns it directly, so nothing is executed (no rpmbuild/dpkg, no emulation) — the worker image is only inspected. Requesting arm64 on an amd64 runner therefore needs no QEMU.

Real amd64/arm64 platforms are used (rather than a made-up platform) because the worker handler resolves the real distro image config at the requested platform, so the requested platform must actually exist on that image.

Copilot AI review requested due to automatic review settings June 1, 2026 23:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Linux integration “cross platform” test selection to avoid QEMU emulation on amd64 CI runners by preferring a same-arch, different-variant target (linux/amd64/v3) instead of cross-arch (e.g., arm64).

Changes:

  • Add linux/amd64/v3 to the per-distro Platforms lists used by integration tests.
  • Update testTargetPlatform selection logic to prefer same-architecture platforms (different variant) to avoid QEMU on amd64 runners.
  • Extend the platform plumbing assertion to verify both TARGETARCH and TARGETVARIANT are passed through.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/target_ubuntu_test.go Adds linux/amd64/v3 to Ubuntu test platform matrix.
test/target_rockylinux_test.go Adds linux/amd64/v3 to Rocky Linux 8/9 test platform matrices.
test/target_azlinux_test.go Adds linux/amd64/v3 to Azure Linux 3 test platform matrix.
test/target_almalinux_test.go Adds linux/amd64/v3 to AlmaLinux 8/9 test platform matrices.
test/linux_target_test.go Changes cross-platform target selection to prefer same-arch variants and asserts TARGETVARIANT plumbing.

Comment thread test/linux_target_test.go Outdated
Comment thread test/linux_target_test.go Outdated
Comment thread test/linux_target_test.go Outdated
Comment thread test/linux_target_test.go Outdated
@cpuguy83 cpuguy83 force-pushed the fix/cross-platform-test-no-qemu branch from 82a69fb to d0fd589 Compare June 2, 2026 18:39
@cpuguy83 cpuguy83 changed the title tests: use amd64/v3 variant for cross-platform test to avoid QEMU tests: verify worker platform selection without QEMU Jun 2, 2026
@cpuguy83 cpuguy83 force-pushed the fix/cross-platform-test-no-qemu branch 2 times, most recently from 1fa9493 to dfb0668 Compare June 2, 2026 19:46
@cpuguy83 cpuguy83 marked this pull request as draft June 2, 2026 22:02
@cpuguy83 cpuguy83 force-pushed the fix/cross-platform-test-no-qemu branch 2 times, most recently from 99f3305 to 58c8315 Compare June 3, 2026 01:33
The cross-platform test previously built worker images for a foreign
architecture, which required QEMU emulation and intermittently crashed in
CI. Redesign it to prove the frontend selects the correct
platform-specific worker image without emulating it.

A shared marker image is built from the real distro base for each tested
platform, with a /platform-marker file identifying the platform. It is
exposed as an OCI layout content store via a small layoutStore adapter:
an ocijoin.Layout is already a content.Provider, so the adapter embeds a
nil content.Store for the unused methods and implements only ReaderAt and
Info, which is all BuildKit's oci-layout source reads.

Two subtests then verify selection via different resolution paths:
- 'worker context' supplies the marker index as the worker build context,
  short-circuiting worker building; the returned image is inspected
  directly. Nothing executes, so no QEMU.
- 'source policy' rewrites the distro base image to the marker index via a
  BuildKit source policy, exercising the normal llb.Image worker-build
  path. Cross-arch installs run natively via dnf/apt --forcearch into a
  foreign-arch root, so the marker survives into the result rootfs without
  emulation.

Both confirm the selected worker matches the requested build platform by
reading the marker file from the result.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
@cpuguy83 cpuguy83 force-pushed the fix/cross-platform-test-no-qemu branch from 58c8315 to 52f3e65 Compare June 3, 2026 17:38
@cpuguy83 cpuguy83 marked this pull request as ready for review June 3, 2026 17:43
@cpuguy83

cpuguy83 commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator Author

Took this in a new direction.

Why: the existing cross platform test built a package/container for a foreign architecture and ran build steps inside that foreign-arch worker. On a single-arch CI runner that requires QEMU
emulation, which crashes intermittently and makes the test flaky.

What changed: instead of doing a real foreign-arch build, the test now verifies the thing that was actually at risk of regressing — that the frontend selects the correct platform-specific
worker base image for the requested build platform — without executing any foreign-arch code.

A small multi-platform "marker" image is built from the real distro worker base, injecting a /platform-marker file into each manifest that names its platform. The test then requests the
worker target for both linux/amd64 and linux/arm64 and reads the marker back to confirm the right manifest was selected. The marker is content baked into each manifest, so it proves the
actual base bytes were fetched — not just that the result was labeled with the requested platform.

Selection is checked through both resolution paths:

  • worker context — the marker index is supplied as the worker build context (short-circuits worker building); nothing executes.
  • source policy — a BuildKit source policy rewrites the distro base image to the marker index, exercising the normal llb.Image worker-build path. Cross-arch worker assembly runs natively
    via dnf/apt --forcearch into a mounted foreign-arch root, so no emulation is needed.

Both run natively regardless of the runner's architecture — no QEMU.

Coverage notes:

  • TARGETARCH/TARGETVARIANT argument passthrough is already covered without QEMU by TestPassthroughVars (via debug/resolve).
  • The previous test's end-to-end assertions on package output naming and the final container image-config platform are no longer exercised by this test. A genuinely-different-arch real
    build is only achievable without QEMU using a native sub-architecture (e.g. 386 on amd64), which is a possible future follow-up gated on per-distro 32-bit tooling availability.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.

Comment thread test/platform_worker_test.go
Comment thread test/linux_target_test.go
@cpuguy83 cpuguy83 requested a review from invidian June 3, 2026 18:12
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.

3 participants