e2e: Skip tests with platform-specific digests on other platforms

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski 2023-02-24 12:36:53 +01:00
parent 591320db4a
commit 41b6ec07ce
No known key found for this signature in database
GPG Key ID: B85EFCFE26DEF92A
5 changed files with 32 additions and 0 deletions

View File

@ -18,6 +18,10 @@ const registryPrefix = "registry:5000"
func TestRunAttachedFromRemoteImageAndRemove(t *testing.T) {
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)
result := icmd.RunCommand("docker", "run", "--rm", image,

View File

@ -17,6 +17,10 @@ const registryPrefix = "registry:5000"
func TestPullWithContentTrust(t *testing.T) {
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)
defer dir.Remove()
image := fixtures.CreateMaskedTrustedRemoteImage(t, registryPrefix, "trust-pull", "latest")

View File

@ -33,6 +33,10 @@ const (
func TestPushAllTags(t *testing.T) {
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")
result := icmd.RunCmd(icmd.Command("docker", "push", "--all-tags", registryPrefix+"/push-all-tags"))
@ -51,6 +55,10 @@ func TestPushAllTags(t *testing.T) {
func TestPushWithContentTrust(t *testing.T) {
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)
defer dir.Remove()
image := createImage(t, "trust-push", "latest")

View File

@ -20,6 +20,9 @@ const (
func TestSignLocalImage(t *testing.T) {
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)
defer dir.Remove()
@ -35,6 +38,9 @@ func TestSignLocalImage(t *testing.T) {
func TestSignWithLocalFlag(t *testing.T) {
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)
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()))
}
// 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)
}