Skip to content

Commit 41b6ec0

Browse files
committed
e2e: Skip tests with platform-specific digests on other platforms
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
1 parent 591320d commit 41b6ec0

5 files changed

Lines changed: 32 additions & 0 deletions

File tree

e2e/container/run_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ const registryPrefix = "registry:5000"
1818
func TestRunAttachedFromRemoteImageAndRemove(t *testing.T) {
1919
skip.If(t, environment.RemoteDaemon())
2020

21+
// Digests in golden file are linux/amd64 specific.
22+
// TODO: Fix this test and make it work on all platforms.
23+
environment.SkipIfNotPlatform(t, "linux/amd64")
24+
2125
image := createRemoteImage(t)
2226

2327
result := icmd.RunCommand("docker", "run", "--rm", image,

e2e/image/pull_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ const registryPrefix = "registry:5000"
1717
func TestPullWithContentTrust(t *testing.T) {
1818
skip.If(t, environment.RemoteDaemon())
1919

20+
// Digests in golden files are linux/amd64 specific.
21+
// TODO: Fix this test and make it work on all platforms.
22+
environment.SkipIfNotPlatform(t, "linux/amd64")
23+
2024
dir := fixtures.SetupConfigFile(t)
2125
defer dir.Remove()
2226
image := fixtures.CreateMaskedTrustedRemoteImage(t, registryPrefix, "trust-pull", "latest")

e2e/image/push_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ const (
3333
func TestPushAllTags(t *testing.T) {
3434
skip.If(t, environment.RemoteDaemon())
3535

36+
// Compared digests are linux/amd64 specific.
37+
// TODO: Fix this test and make it work on all platforms.
38+
environment.SkipIfNotPlatform(t, "linux/amd64")
39+
3640
_ = createImage(t, "push-all-tags", "latest", "v1", "v1.0", "v1.0.1")
3741
result := icmd.RunCmd(icmd.Command("docker", "push", "--all-tags", registryPrefix+"/push-all-tags"))
3842

@@ -51,6 +55,10 @@ func TestPushAllTags(t *testing.T) {
5155
func TestPushWithContentTrust(t *testing.T) {
5256
skip.If(t, environment.RemoteDaemon())
5357

58+
// Compared digests are linux/amd64 specific.
59+
// TODO: Fix this test and make it work on all platforms.
60+
environment.SkipIfNotPlatform(t, "linux/amd64")
61+
5462
dir := fixtures.SetupConfigFile(t)
5563
defer dir.Remove()
5664
image := createImage(t, "trust-push", "latest")

e2e/trust/sign_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ const (
2020

2121
func TestSignLocalImage(t *testing.T) {
2222
skip.If(t, environment.RemoteDaemon())
23+
// Digests in golden files are linux/amd64 specific.
24+
// TODO: Fix this test and make it work on all platforms.
25+
environment.SkipIfNotPlatform(t, "linux/amd64")
2326

2427
dir := fixtures.SetupConfigFile(t)
2528
defer dir.Remove()
@@ -35,6 +38,9 @@ func TestSignLocalImage(t *testing.T) {
3538

3639
func TestSignWithLocalFlag(t *testing.T) {
3740
skip.If(t, environment.RemoteDaemon())
41+
// Digests in golden files are linux/amd64 specific.
42+
// TODO: Fix this test and make it work on all platforms.
43+
environment.SkipIfNotPlatform(t, "linux/amd64")
3844

3945
dir := fixtures.SetupConfigFile(t)
4046
defer dir.Remove()

internal/test/environment/testenv.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,13 @@ func SkipIfCgroupNamespacesNotSupported(t *testing.T) {
9898

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

0 commit comments

Comments
 (0)