diff --git a/hack/make/.integration-test-helpers b/hack/make/.integration-test-helpers index 16bab622c1..f66bc898ea 100644 --- a/hack/make/.integration-test-helpers +++ b/hack/make/.integration-test-helpers @@ -174,7 +174,6 @@ test_env() { DOCKER_INTEGRATION_DAEMON_DEST="$DOCKER_INTEGRATION_DAEMON_DEST" \ DOCKER_TLS_VERIFY="$DOCKER_TEST_TLS_VERIFY" \ DOCKER_CERT_PATH="$DOCKER_TEST_CERT_PATH" \ - DOCKER_ENGINE_GOARCH="$DOCKER_ENGINE_GOARCH" \ DOCKER_GRAPHDRIVER="$DOCKER_GRAPHDRIVER" \ DOCKER_USERLANDPROXY="$DOCKER_USERLANDPROXY" \ DOCKER_HOST="$DOCKER_HOST" \ diff --git a/hack/test/e2e-run.sh b/hack/test/e2e-run.sh index 5e4d8f2154..312d7e88ad 100755 --- a/hack/test/e2e-run.sh +++ b/hack/test/e2e-run.sh @@ -53,7 +53,6 @@ test_env() { DOCKER_INTEGRATION_DAEMON_DEST="$DOCKER_INTEGRATION_DAEMON_DEST" \ DOCKER_TLS_VERIFY="$DOCKER_TEST_TLS_VERIFY" \ DOCKER_CERT_PATH="$DOCKER_TEST_CERT_PATH" \ - DOCKER_ENGINE_GOARCH="$DOCKER_ENGINE_GOARCH" \ DOCKER_GRAPHDRIVER="$DOCKER_GRAPHDRIVER" \ DOCKER_USERLANDPROXY="$DOCKER_USERLANDPROXY" \ DOCKER_HOST="$DOCKER_HOST" \ diff --git a/integration-cli/requirements_test.go b/integration-cli/requirements_test.go index 8bcf0919ed..2313272d77 100644 --- a/integration-cli/requirements_test.go +++ b/integration-cli/requirements_test.go @@ -19,10 +19,6 @@ import ( "github.com/docker/docker/testutil/registry" ) -func ArchitectureIsNot(arch string) bool { - return os.Getenv("DOCKER_ENGINE_GOARCH") != arch -} - func DaemonIsWindows() bool { return testEnv.OSType == "windows" } @@ -50,15 +46,15 @@ func OnlyDefaultNetworks() bool { } func IsAmd64() bool { - return os.Getenv("DOCKER_ENGINE_GOARCH") == "amd64" + return testEnv.DaemonVersion.Arch == "amd64" } func NotArm64() bool { - return ArchitectureIsNot("arm64") + return testEnv.DaemonVersion.Arch != "arm64" } func NotPpc64le() bool { - return ArchitectureIsNot("ppc64le") + return testEnv.DaemonVersion.Arch != "ppc64le" } func UnixCli() bool { diff --git a/integration/image/remove_unix_test.go b/integration/image/remove_unix_test.go index 046fa8532e..c5f5177c53 100644 --- a/integration/image/remove_unix_test.go +++ b/integration/image/remove_unix_test.go @@ -32,7 +32,7 @@ func TestRemoveImageGarbageCollector(t *testing.T) { // This test uses very platform specific way to prevent // daemon for remove image layer. skip.If(t, testEnv.DaemonInfo.OSType != "linux") - skip.If(t, os.Getenv("DOCKER_ENGINE_GOARCH") != "amd64") + skip.If(t, testEnv.NotAmd64) skip.If(t, testEnv.IsRootless, "rootless mode doesn't support overlay2 on most distros") // Create daemon with overlay2 graphdriver because vfs uses disk differently diff --git a/integration/plugin/authz/authz_plugin_v2_test.go b/integration/plugin/authz/authz_plugin_v2_test.go index c01f2e7af7..fe24644905 100644 --- a/integration/plugin/authz/authz_plugin_v2_test.go +++ b/integration/plugin/authz/authz_plugin_v2_test.go @@ -7,7 +7,6 @@ import ( "context" "fmt" "io" - "os" "strings" "testing" @@ -41,7 +40,7 @@ func setupTestV2(t *testing.T) func() { } func TestAuthZPluginV2AllowNonVolumeRequest(t *testing.T) { - skip.If(t, os.Getenv("DOCKER_ENGINE_GOARCH") != "amd64") + skip.If(t, testEnv.NotAmd64) defer setupTestV2(t)() c := d.NewClientT(t) @@ -63,7 +62,7 @@ func TestAuthZPluginV2AllowNonVolumeRequest(t *testing.T) { } func TestAuthZPluginV2Disable(t *testing.T) { - skip.If(t, os.Getenv("DOCKER_ENGINE_GOARCH") != "amd64") + skip.If(t, testEnv.NotAmd64) defer setupTestV2(t)() c := d.NewClientT(t) @@ -89,7 +88,7 @@ func TestAuthZPluginV2Disable(t *testing.T) { } func TestAuthZPluginV2RejectVolumeRequests(t *testing.T) { - skip.If(t, os.Getenv("DOCKER_ENGINE_GOARCH") != "amd64") + skip.If(t, testEnv.NotAmd64) defer setupTestV2(t)() c := d.NewClientT(t) @@ -124,7 +123,7 @@ func TestAuthZPluginV2RejectVolumeRequests(t *testing.T) { } func TestAuthZPluginV2BadManifestFailsDaemonStart(t *testing.T) { - skip.If(t, os.Getenv("DOCKER_ENGINE_GOARCH") != "amd64") + skip.If(t, testEnv.NotAmd64) defer setupTestV2(t)() c := d.NewClientT(t) diff --git a/integration/plugin/graphdriver/external_test.go b/integration/plugin/graphdriver/external_test.go index 5e9d9b851e..9452ce3b54 100644 --- a/integration/plugin/graphdriver/external_test.go +++ b/integration/plugin/graphdriver/external_test.go @@ -407,7 +407,7 @@ func TestGraphdriverPluginV2(t *testing.T) { skip.If(t, runtime.GOOS == "windows") skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") skip.If(t, !requirement.HasHubConnectivity(t)) - skip.If(t, os.Getenv("DOCKER_ENGINE_GOARCH") != "amd64") + skip.If(t, testEnv.NotAmd64) skip.If(t, !requirement.Overlay2Supported(testEnv.DaemonInfo.KernelVersion)) d := daemon.New(t, daemon.WithExperimental()) diff --git a/integration/service/plugin_test.go b/integration/service/plugin_test.go index 33505990ca..696cd1d5d5 100644 --- a/integration/service/plugin_test.go +++ b/integration/service/plugin_test.go @@ -3,7 +3,6 @@ package service import ( "context" "io" - "os" "path" "strings" "testing" @@ -24,7 +23,7 @@ import ( func TestServicePlugin(t *testing.T) { skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") skip.If(t, testEnv.DaemonInfo.OSType == "windows") - skip.If(t, os.Getenv("DOCKER_ENGINE_GOARCH") != "amd64") + skip.If(t, testEnv.NotAmd64) defer setupTest(t)() reg := registry.NewV2(t) diff --git a/testutil/environment/environment.go b/testutil/environment/environment.go index fda7cf1265..ce101e1c00 100644 --- a/testutil/environment/environment.go +++ b/testutil/environment/environment.go @@ -21,6 +21,7 @@ import ( type Execution struct { client client.APIClient DaemonInfo types.Info + DaemonVersion types.Version OSType string PlatformDefaults PlatformDefaults protectedElements protectedElements @@ -49,12 +50,17 @@ func FromClient(c *client.Client) (*Execution, error) { if err != nil { return nil, errors.Wrapf(err, "failed to get info from daemon") } + v, err := c.ServerVersion(context.Background()) + if err != nil { + return nil, errors.Wrapf(err, "failed to get version info from daemon") + } osType := getOSType(info) return &Execution{ client: c, DaemonInfo: info, + DaemonVersion: v, OSType: osType, PlatformDefaults: getPlatformDefaults(info, osType), protectedElements: newProtectedElements(), @@ -232,3 +238,8 @@ func EnsureFrozenImagesLinux(testEnv *Execution) error { func (e *Execution) GitHubActions() bool { return os.Getenv("GITHUB_ACTIONS") != "" } + +// NotAmd64 returns true if the daemon's architecture is not amd64 +func (e *Execution) NotAmd64() bool { + return e.DaemonVersion.Arch != "amd64" +} diff --git a/testutil/fakestorage/fixtures.go b/testutil/fakestorage/fixtures.go index e11bee3b28..6d109bd0fa 100644 --- a/testutil/fakestorage/fixtures.go +++ b/testutil/fakestorage/fixtures.go @@ -39,7 +39,7 @@ func ensureHTTPServerImage(t testing.TB) { if goos == "" { goos = "linux" } - goarch := os.Getenv("DOCKER_ENGINE_GOARCH") + goarch := testEnv.DaemonVersion.Arch if goarch == "" { goarch = "amd64" }