mirror of
https://github.com/docker/compose.git
synced 2026-11-16 21:22:56 +00:00
Introduce a small declarative layer over the e2e framework so a test reads as its intent: an inline compose.yaml, a sequence of steps (command + expected observables), and nothing else. The framework owns project naming (derived from the test name), cleanup, and failure reporting: on the first unmet expectation the test fails with a step transcript, the failing command output, the project's container state, the engine events since the scenario started and the container logs. Checks observe real state (container IDs across steps, labels, image manifest platform) instead of grepping the progress writer output, which stays available as an explicit last-resort check. The e2e tests introduced by #14041 are converted as a demonstrator; their dedicated fixture files are inlined in the scenarios and removed. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
59 lines
2.4 KiB
Go
59 lines
2.4 KiB
Go
/*
|
|
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).
|
|
Compose(`
|
|
services:
|
|
repro:
|
|
image: compose-e2e-multiplatform-local-only:v1
|
|
platform: ${REQUESTED_PLATFORM}
|
|
command: ["uname", "-m"]
|
|
`).
|
|
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))
|
|
}
|