test: use info from the version endpoint for arch checks

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
(cherry picked from commit 84a4f37cf7)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Djordje Lukic 2023-08-31 09:22:29 +02:00 committed by Sebastiaan van Stijn
parent 6af38fa650
commit f928838f31
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
9 changed files with 22 additions and 19 deletions

View file

@ -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" \

View file

@ -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" \

View file

@ -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 {

View file

@ -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

View file

@ -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)

View file

@ -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())

View file

@ -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)

View file

@ -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"
}

View file

@ -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"
}