Files
compose/pkg/e2e/multiplatform_test.go
Nicolas De Loof 7af58e3626 test(e2e): gate the e2e suite behind the build tag the docs already promise
AGENTS.md documents 'Test unit: go test ./pkg/...' and 'E2E tests:
go test -tags e2e ./pkg/e2e/'. Both statements were false: no file in
pkg/e2e carried an e2e build constraint, so the -tags flag was a no-op
and the 'unit' command actually launched the full e2e suite — requiring
a Docker daemon and the locally built binary, creating and destroying
containers, for up to 20 minutes. CI only avoided this by grepping e2e
out of the package list (Dockerfile).

Every *_test.go in pkg/e2e now carries //go:build e2e (merged with the
existing !windows constraints), and the Makefile e2e targets pass the
tag. The documented commands become true:
- go test ./pkg/...          -> pkg/e2e reports [no test files]
- go test -tags e2e ./pkg/e2e -> runs the suite

AGENTS.md now also states the daemon/binary prerequisites explicitly.

Part of #14074 (A: the code misdescribes its own structure).

Signed-off-by: Nicolas De Loof <[email protected]>
2026-08-27 11:02:07 +02:00

55 lines
2.2 KiB
Go

//go:build e2e
/*
Copyright 2026 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package e2e
import (
"testing"
)
func TestCreateLocalMultiPlatformImage(t *testing.T) {
// Regression test for https://github.com/docker/compose/issues/14007
// With the containerd image store, a local multi-platform image holding the
// requested non-native variant satisfies the default "missing" pull policy:
// compose must use it and not try to pull the (unpublished) tag.
s := NewScenario(t, "a local multi-platform image must satisfy the default missing pull policy for a non-native platform").
Requires(ContainerdImageStore)
// request the non-native platform, so the requested variant can't be the
// one a platform-less image inspect reports; the tag deliberately doesn't
// exist on any registry: resolving the requested platform from the local
// image is the only way to succeed
requested := s.NonNativePlatform()
const image = "compose-e2e-multiplatform-local-only:v1"
// `create` exercises the same image-resolution/pull-policy path as `up`,
// without requiring emulation to actually run the non-native binary
s.Env("REQUESTED_PLATFORM="+requested).
Defer(DockerCmd("image", "rm", image)).
Step("store the amd64 variant in the local store",
DockerCmd("pull", "-q", "--platform", "linux/amd64", "alpine:3.22")).
Step("store the arm64 variant in the local store",
DockerCmd("pull", "-q", "--platform", "linux/arm64", "alpine:3.22")).
Step("tag both variants under a tag that exists on no registry",
DockerCmd("tag", "alpine:3.22", image)).
Step("create uses the local variant for the requested platform without pulling",
ComposeCmd("create"),
OutputNotContains("Pulling"),
RunsOnPlatform("repro", requested))
}