Merge pull request #4045 from vvoland/test-e2e-arm64-fixes

test/e2e: Fix running `test-e2e` on non-amd64 platforms
This commit is contained in:
Sebastiaan van Stijn 2023-04-27 11:41:43 +02:00 committed by GitHub
commit 59b07b7253
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 61 additions and 29 deletions

View File

@ -34,7 +34,7 @@ func TestRunBuildDockerfileFromStdinWithCompress(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{imageBuildFunc: fakeImageBuild}) cli := test.NewFakeCli(&fakeClient{imageBuildFunc: fakeImageBuild})
dockerfile := bytes.NewBufferString(` dockerfile := bytes.NewBufferString(`
FROM alpine:3.6 FROM alpine:frozen
COPY foo / COPY foo /
`) `)
cli.SetIn(streams.NewIn(io.NopCloser(dockerfile))) cli.SetIn(streams.NewIn(io.NopCloser(dockerfile)))
@ -66,7 +66,7 @@ func TestRunBuildResetsUidAndGidInContext(t *testing.T) {
dir := fs.NewDir(t, "test-build-context", dir := fs.NewDir(t, "test-build-context",
fs.WithFile("foo", "some content", fs.AsUser(65534, 65534)), fs.WithFile("foo", "some content", fs.AsUser(65534, 65534)),
fs.WithFile("Dockerfile", ` fs.WithFile("Dockerfile", `
FROM alpine:3.6 FROM alpine:frozen
COPY foo bar / COPY foo bar /
`), `),
) )
@ -155,7 +155,7 @@ func TestRunBuildFromLocalGitHubDir(t *testing.T) {
func TestRunBuildWithSymlinkedContext(t *testing.T) { func TestRunBuildWithSymlinkedContext(t *testing.T) {
t.Setenv("DOCKER_BUILDKIT", "0") t.Setenv("DOCKER_BUILDKIT", "0")
dockerfile := ` dockerfile := `
FROM alpine:3.6 FROM alpine:frozen
RUN echo hello world RUN echo hello world
` `

View File

@ -18,6 +18,10 @@ const registryPrefix = "registry:5000"
func TestRunAttachedFromRemoteImageAndRemove(t *testing.T) { func TestRunAttachedFromRemoteImageAndRemove(t *testing.T) {
skip.If(t, environment.RemoteDaemon()) skip.If(t, environment.RemoteDaemon())
// Digests in golden file are linux/amd64 specific.
// TODO: Fix this test and make it work on all platforms.
environment.SkipIfNotPlatform(t, "linux/amd64")
image := createRemoteImage(t) image := createRemoteImage(t)
result := icmd.RunCommand("docker", "run", "--rm", image, result := icmd.RunCommand("docker", "run", "--rm", image,

View File

@ -1,4 +1,4 @@
Unable to find image 'registry:5000/alpine:test-run-pulls' locally Unable to find image 'registry:5000/alpine:test-run-pulls' locally
test-run-pulls: Pulling from alpine test-run-pulls: Pulling from alpine
Digest: sha256:641b95ddb2ea9dc2af1a0113b6b348ebc20872ba615204fbe12148e98fd6f23d Digest: sha256:e2e16842c9b54d985bf1ef9242a313f36b856181f188de21313820e177002501
Status: Downloaded newer image for registry:5000/alpine:test-run-pulls Status: Downloaded newer image for registry:5000/alpine:test-run-pulls

View File

@ -44,7 +44,7 @@ func TestBuildFromContextDirectoryWithTag(t *testing.T) {
result.Assert(t, icmd.Expected{Err: buildkitDisabledWarning}) result.Assert(t, icmd.Expected{Err: buildkitDisabledWarning})
output.Assert(t, result.Stdout(), map[int]func(string) error{ output.Assert(t, result.Stdout(), map[int]func(string) error{
0: output.Prefix("Sending build context to Docker daemon"), 0: output.Prefix("Sending build context to Docker daemon"),
1: output.Suffix("Step 1/4 : FROM registry:5000/alpine:3.6"), 1: output.Suffix("Step 1/4 : FROM registry:5000/alpine:frozen"),
3: output.Suffix("Step 2/4 : COPY run /usr/bin/run"), 3: output.Suffix("Step 2/4 : COPY run /usr/bin/run"),
5: output.Suffix("Step 3/4 : RUN run"), 5: output.Suffix("Step 3/4 : RUN run"),
7: output.Suffix("running"), 7: output.Suffix("running"),

View File

@ -17,6 +17,10 @@ const registryPrefix = "registry:5000"
func TestPullWithContentTrust(t *testing.T) { func TestPullWithContentTrust(t *testing.T) {
skip.If(t, environment.RemoteDaemon()) skip.If(t, environment.RemoteDaemon())
// Digests in golden files are linux/amd64 specific.
// TODO: Fix this test and make it work on all platforms.
environment.SkipIfNotPlatform(t, "linux/amd64")
dir := fixtures.SetupConfigFile(t) dir := fixtures.SetupConfigFile(t)
defer dir.Remove() defer dir.Remove()
image := fixtures.CreateMaskedTrustedRemoteImage(t, registryPrefix, "trust-pull", "latest") image := fixtures.CreateMaskedTrustedRemoteImage(t, registryPrefix, "trust-pull", "latest")
@ -37,7 +41,7 @@ func TestPullWithContentTrust(t *testing.T) {
func TestPullQuiet(t *testing.T) { func TestPullQuiet(t *testing.T) {
result := icmd.RunCommand("docker", "pull", "--quiet", fixtures.AlpineImage) result := icmd.RunCommand("docker", "pull", "--quiet", fixtures.AlpineImage)
result.Assert(t, icmd.Success) result.Assert(t, icmd.Success)
assert.Check(t, is.Equal(result.Stdout(), "registry:5000/alpine:3.6\n")) assert.Check(t, is.Equal(result.Stdout(), "registry:5000/alpine:frozen\n"))
assert.Check(t, is.Equal(result.Stderr(), "")) assert.Check(t, is.Equal(result.Stderr(), ""))
} }

View File

@ -33,6 +33,10 @@ const (
func TestPushAllTags(t *testing.T) { func TestPushAllTags(t *testing.T) {
skip.If(t, environment.RemoteDaemon()) skip.If(t, environment.RemoteDaemon())
// Compared digests are linux/amd64 specific.
// TODO: Fix this test and make it work on all platforms.
environment.SkipIfNotPlatform(t, "linux/amd64")
_ = createImage(t, "push-all-tags", "latest", "v1", "v1.0", "v1.0.1") _ = createImage(t, "push-all-tags", "latest", "v1", "v1.0", "v1.0.1")
result := icmd.RunCmd(icmd.Command("docker", "push", "--all-tags", registryPrefix+"/push-all-tags")) result := icmd.RunCmd(icmd.Command("docker", "push", "--all-tags", registryPrefix+"/push-all-tags"))
@ -40,17 +44,21 @@ func TestPushAllTags(t *testing.T) {
golden.Assert(t, result.Stderr(), "push-with-content-trust-err.golden") golden.Assert(t, result.Stderr(), "push-with-content-trust-err.golden")
output.Assert(t, result.Stdout(), map[int]func(string) error{ output.Assert(t, result.Stdout(), map[int]func(string) error{
0: output.Equals("The push refers to repository [registry:5000/push-all-tags]"), 0: output.Equals("The push refers to repository [registry:5000/push-all-tags]"),
1: output.Equals("5bef08742407: Preparing"), 1: output.Equals("7cd52847ad77: Preparing"),
3: output.Equals("latest: digest: sha256:641b95ddb2ea9dc2af1a0113b6b348ebc20872ba615204fbe12148e98fd6f23d size: 528"), 3: output.Equals("latest: digest: sha256:e2e16842c9b54d985bf1ef9242a313f36b856181f188de21313820e177002501 size: 528"),
6: output.Equals("v1: digest: sha256:641b95ddb2ea9dc2af1a0113b6b348ebc20872ba615204fbe12148e98fd6f23d size: 528"), 6: output.Equals("v1: digest: sha256:e2e16842c9b54d985bf1ef9242a313f36b856181f188de21313820e177002501 size: 528"),
9: output.Equals("v1.0: digest: sha256:641b95ddb2ea9dc2af1a0113b6b348ebc20872ba615204fbe12148e98fd6f23d size: 528"), 9: output.Equals("v1.0: digest: sha256:e2e16842c9b54d985bf1ef9242a313f36b856181f188de21313820e177002501 size: 528"),
12: output.Equals("v1.0.1: digest: sha256:641b95ddb2ea9dc2af1a0113b6b348ebc20872ba615204fbe12148e98fd6f23d size: 528"), 12: output.Equals("v1.0.1: digest: sha256:e2e16842c9b54d985bf1ef9242a313f36b856181f188de21313820e177002501 size: 528"),
}) })
} }
func TestPushWithContentTrust(t *testing.T) { func TestPushWithContentTrust(t *testing.T) {
skip.If(t, environment.RemoteDaemon()) skip.If(t, environment.RemoteDaemon())
// Compared digests are linux/amd64 specific.
// TODO: Fix this test and make it work on all platforms.
environment.SkipIfNotPlatform(t, "linux/amd64")
dir := fixtures.SetupConfigFile(t) dir := fixtures.SetupConfigFile(t)
defer dir.Remove() defer dir.Remove()
image := createImage(t, "trust-push", "latest") image := createImage(t, "trust-push", "latest")
@ -65,8 +73,8 @@ func TestPushWithContentTrust(t *testing.T) {
golden.Assert(t, result.Stderr(), "push-with-content-trust-err.golden") golden.Assert(t, result.Stderr(), "push-with-content-trust-err.golden")
output.Assert(t, result.Stdout(), map[int]func(string) error{ output.Assert(t, result.Stdout(), map[int]func(string) error{
0: output.Equals("The push refers to repository [registry:5000/trust-push]"), 0: output.Equals("The push refers to repository [registry:5000/trust-push]"),
1: output.Equals("5bef08742407: Preparing"), 1: output.Equals("7cd52847ad77: Preparing"),
3: output.Equals("latest: digest: sha256:641b95ddb2ea9dc2af1a0113b6b348ebc20872ba615204fbe12148e98fd6f23d size: 528"), 3: output.Equals("latest: digest: sha256:e2e16842c9b54d985bf1ef9242a313f36b856181f188de21313820e177002501 size: 528"),
4: output.Equals("Signing and pushing trust metadata"), 4: output.Equals("Signing and pushing trust metadata"),
5: output.Equals(`Finished initializing "registry:5000/trust-push"`), 5: output.Equals(`Finished initializing "registry:5000/trust-push"`),
6: output.Equals("Successfully signed registry:5000/trust-push:latest"), 6: output.Equals("Successfully signed registry:5000/trust-push:latest"),

View File

@ -1 +1 @@
Tagging registry:5000/trust-pull@sha256:641b95ddb2ea9dc2af1a0113b6b348ebc20872ba615204fbe12148e98fd6f23d as registry:5000/trust-pull:latest Tagging registry:5000/trust-pull@sha256:e2e16842c9b54d985bf1ef9242a313f36b856181f188de21313820e177002501 as registry:5000/trust-pull:latest

View File

@ -1,5 +1,5 @@
Pull (1 of 1): registry:5000/trust-pull:latest@sha256:641b95ddb2ea9dc2af1a0113b6b348ebc20872ba615204fbe12148e98fd6f23d Pull (1 of 1): registry:5000/trust-pull:latest@sha256:e2e16842c9b54d985bf1ef9242a313f36b856181f188de21313820e177002501
sha256:641b95ddb2ea9dc2af1a0113b6b348ebc20872ba615204fbe12148e98fd6f23d: Pulling from trust-pull sha256:e2e16842c9b54d985bf1ef9242a313f36b856181f188de21313820e177002501: Pulling from trust-pull
Digest: sha256:641b95ddb2ea9dc2af1a0113b6b348ebc20872ba615204fbe12148e98fd6f23d Digest: sha256:e2e16842c9b54d985bf1ef9242a313f36b856181f188de21313820e177002501
Status: Downloaded newer image for registry:5000/trust-pull@sha256:641b95ddb2ea9dc2af1a0113b6b348ebc20872ba615204fbe12148e98fd6f23d Status: Downloaded newer image for registry:5000/trust-pull@sha256:e2e16842c9b54d985bf1ef9242a313f36b856181f188de21313820e177002501
registry:5000/trust-pull:latest registry:5000/trust-pull:latest

View File

@ -15,11 +15,11 @@ const (
// EvilNotaryURL is the location of the evil notary server // EvilNotaryURL is the location of the evil notary server
EvilNotaryURL = "https://evil-notary-server:4444" EvilNotaryURL = "https://evil-notary-server:4444"
// AlpineImage is an image in the test registry // AlpineImage is an image in the test registry
AlpineImage = "registry:5000/alpine:3.6" AlpineImage = "registry:5000/alpine:frozen"
// AlpineSha is the sha of the alpine image // AlpineSha is the sha of the alpine image
AlpineSha = "641b95ddb2ea9dc2af1a0113b6b348ebc20872ba615204fbe12148e98fd6f23d" AlpineSha = "e2e16842c9b54d985bf1ef9242a313f36b856181f188de21313820e177002501"
// BusyboxImage is an image in the test registry // BusyboxImage is an image in the test registry
BusyboxImage = "registry:5000/busybox:1.27.2" BusyboxImage = "registry:5000/busybox:frozen"
// BusyboxSha is the sha of the busybox image // BusyboxSha is the sha of the busybox image
BusyboxSha = "030fcb92e1487b18c974784dcc110a93147c9fc402188370fbfd17efabffc6af" BusyboxSha = "030fcb92e1487b18c974784dcc110a93147c9fc402188370fbfd17efabffc6af"
) )

View File

@ -2,8 +2,8 @@ version: '3.3'
services: services:
one: one:
image: registry:5000/alpine:3.6 image: registry:5000/alpine:frozen
command: top command: top
two: two:
image: registry:5000/alpine:3.6 image: registry:5000/alpine:frozen
command: top command: top

View File

@ -1,7 +1,7 @@
version: '3.5' version: '3.5'
services: services:
web: web:
image: registry:5000/alpine:3.6 image: registry:5000/alpine:frozen
command: top command: top
networks: [network1, network2] networks: [network1, network2]
volumes: [volume1, volume2] volumes: [volume1, volume2]

View File

@ -1,4 +1,4 @@
ARG NOTARY_VERSION=0.5.0 ARG NOTARY_VERSION=0.6.1
FROM notary:server-${NOTARY_VERSION} FROM notary:server-${NOTARY_VERSION}
COPY ./notary-evil/ /fixtures/ COPY ./notary-evil/ /fixtures/

View File

@ -1,4 +1,4 @@
ARG NOTARY_VERSION=0.5.0 ARG NOTARY_VERSION=0.6.1
FROM notary:server-${NOTARY_VERSION} FROM notary:server-${NOTARY_VERSION}
COPY ./notary/ /fixtures/ COPY ./notary/ /fixtures/

View File

@ -20,6 +20,9 @@ const (
func TestSignLocalImage(t *testing.T) { func TestSignLocalImage(t *testing.T) {
skip.If(t, environment.RemoteDaemon()) skip.If(t, environment.RemoteDaemon())
// Digests in golden files are linux/amd64 specific.
// TODO: Fix this test and make it work on all platforms.
environment.SkipIfNotPlatform(t, "linux/amd64")
dir := fixtures.SetupConfigFile(t) dir := fixtures.SetupConfigFile(t)
defer dir.Remove() defer dir.Remove()
@ -35,6 +38,9 @@ func TestSignLocalImage(t *testing.T) {
func TestSignWithLocalFlag(t *testing.T) { func TestSignWithLocalFlag(t *testing.T) {
skip.If(t, environment.RemoteDaemon()) skip.If(t, environment.RemoteDaemon())
// Digests in golden files are linux/amd64 specific.
// TODO: Fix this test and make it work on all platforms.
environment.SkipIfNotPlatform(t, "linux/amd64")
dir := fixtures.SetupConfigFile(t) dir := fixtures.SetupConfigFile(t)
defer dir.Remove() defer dir.Remove()

View File

@ -98,3 +98,13 @@ func SkipIfCgroupNamespacesNotSupported(t *testing.T) {
skip.If(t, !cgroupNsFound, fmt.Sprintf("running against a daemon that doesn't support cgroup namespaces (security options: %s)", result.Stdout())) skip.If(t, !cgroupNsFound, fmt.Sprintf("running against a daemon that doesn't support cgroup namespaces (security options: %s)", result.Stdout()))
} }
// SkipIfNotPlatform skips the test if the running docker daemon is not running on a specific platform.
// platform should be in format os/arch (for example linux/arm64).
func SkipIfNotPlatform(t *testing.T, platform string) {
t.Helper()
result := icmd.RunCmd(icmd.Command("docker", "version", "--format", "{{.Server.Os}}/{{.Server.Arch}}"))
result.Assert(t, icmd.Expected{Err: icmd.None})
daemonPlatform := strings.TrimSpace(result.Stdout())
skip.If(t, daemonPlatform != platform, "running against a non %s daemon", platform)
}

View File

@ -2,11 +2,11 @@
# Fetch images used for e2e testing # Fetch images used for e2e testing
set -eu -o pipefail set -eu -o pipefail
alpine_src=alpine@sha256:f006ecbb824d87947d0b51ab8488634bf69fe4094959d935c0c103f4820a417d alpine_src=alpine@sha256:69665d02cb32192e52e07644d76bc6f25abeb5410edc1c7a81a10ba3f0efb90a
alpine_dest=registry:5000/alpine:3.6 alpine_dest=registry:5000/alpine:frozen
busybox_src=busybox@sha256:3e8fa85ddfef1af9ca85a5cfb714148956984e02f00bec3f7f49d3925a91e0e7 busybox_src=busybox@sha256:3e8fa85ddfef1af9ca85a5cfb714148956984e02f00bec3f7f49d3925a91e0e7
busybox_dest=registry:5000/busybox:1.27.2 busybox_dest=registry:5000/busybox:frozen
fetch_tag_image() { fetch_tag_image() {
docker pull "$1" docker pull "$1"