From 40b08ea4d12fa96f14e34e00d5dc5cfab4e4a6e8 Mon Sep 17 00:00:00 2001 From: Dennis Chen Date: Mon, 9 Apr 2018 10:33:42 +0000 Subject: [PATCH 1/2] Dockerbuilder: use the arch info from base image Currently we hardcode the architecture to the `runtime.GOARCH` when building a docker image, this will result in a confusing info if the arch in the base image is different from the one on the host. This PR takes use of the arch data from the base image during the build process, thus we can get consistent arch info between the base image and the finally built image. Signed-off-by: Dennis Chen Upstream-commit: 92b17b10bad1f1788419b70db5d6ed9cdf8d15ef Component: engine --- components/engine/image/image.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/components/engine/image/image.go b/components/engine/image/image.go index 683c3fedd0..7e0646f072 100644 --- a/components/engine/image/image.go +++ b/components/engine/image/image.go @@ -96,6 +96,15 @@ func (img *Image) RunConfig() *container.Config { return img.Config } +// BaseImgArch returns the image's architecture. If not populated, defaults to the host runtime arch. +func (img *Image) BaseImgArch() string { + arch := img.Architecture + if arch == "" { + arch = runtime.GOARCH + } + return arch +} + // OperatingSystem returns the image's operating system. If not populated, defaults to the host runtime OS. func (img *Image) OperatingSystem() string { os := img.OS @@ -157,7 +166,7 @@ func NewChildImage(img *Image, child ChildConfig, platform string) *Image { V1Image: V1Image{ DockerVersion: dockerversion.Version, Config: child.Config, - Architecture: runtime.GOARCH, + Architecture: img.BaseImgArch(), OS: platform, Container: child.ContainerID, ContainerConfig: *child.ContainerConfig, From 7dc2c5606a136b4d2e3ee8920383afb8e624dec0 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Wed, 25 Apr 2018 11:03:43 +0200 Subject: [PATCH 2/2] Skip some test on remote daemon for e2e run(s) We really need to run those on the CI too at some point. Signed-off-by: Vincent Demeester Signed-off-by: Tibor Vass Upstream-commit: ef2c2040c22eba8ab6ea1033ad64ba9b0095db9b Component: engine --- .../integration/build/build_session_test.go | 21 ++++++++----------- .../integration/build/build_squash_test.go | 9 +++----- .../container/daemon_linux_test.go | 2 +- .../integration/container/restart_test.go | 2 +- .../integration/internal/swarm/service.go | 2 +- .../integration/plugin/authz/main_test.go | 2 +- .../plugin/graphdriver/external_test.go | 4 ++-- .../plugin/logging/validation_test.go | 2 +- .../integration/plugin/volumes/mounts_test.go | 2 ++ .../engine/integration/service/plugin_test.go | 1 + .../engine/integration/volume/volume_test.go | 2 ++ 11 files changed, 24 insertions(+), 25 deletions(-) diff --git a/components/engine/integration/build/build_session_test.go b/components/engine/integration/build/build_session_test.go index ff04b63d8f..3abac981e5 100644 --- a/components/engine/integration/build/build_session_test.go +++ b/components/engine/integration/build/build_session_test.go @@ -8,23 +8,20 @@ import ( "testing" dclient "github.com/docker/docker/client" - "github.com/docker/docker/internal/test/daemon" "github.com/docker/docker/internal/test/fakecontext" "github.com/docker/docker/internal/test/request" "github.com/gotestyourself/gotestyourself/assert" is "github.com/gotestyourself/gotestyourself/assert/cmp" + "github.com/gotestyourself/gotestyourself/skip" "github.com/moby/buildkit/session" "github.com/moby/buildkit/session/filesync" "golang.org/x/sync/errgroup" ) func TestBuildWithSession(t *testing.T) { - d := daemon.New(t, daemon.WithExperimental) - d.StartWithBusybox(t) - defer d.Stop(t) + skip.If(t, !testEnv.DaemonInfo.ExperimentalBuild) - client, err := d.NewClient() - assert.NilError(t, err) + client := testEnv.APIClient() dockerfile := ` FROM busybox @@ -37,7 +34,7 @@ func TestBuildWithSession(t *testing.T) { ) defer fctx.Close() - out := testBuildWithSession(t, client, d.Sock(), fctx.Dir, dockerfile) + out := testBuildWithSession(t, client, client.DaemonHost(), fctx.Dir, dockerfile) assert.Check(t, is.Contains(out, "some content")) fctx.Add("second", "contentcontent") @@ -47,7 +44,7 @@ func TestBuildWithSession(t *testing.T) { RUN cat /second ` - out = testBuildWithSession(t, client, d.Sock(), fctx.Dir, dockerfile) + out = testBuildWithSession(t, client, client.DaemonHost(), fctx.Dir, dockerfile) assert.Check(t, is.Equal(strings.Count(out, "Using cache"), 2)) assert.Check(t, is.Contains(out, "contentcontent")) @@ -55,7 +52,7 @@ func TestBuildWithSession(t *testing.T) { assert.Check(t, err) assert.Check(t, du.BuilderSize > 10) - out = testBuildWithSession(t, client, d.Sock(), fctx.Dir, dockerfile) + out = testBuildWithSession(t, client, client.DaemonHost(), fctx.Dir, dockerfile) assert.Check(t, is.Equal(strings.Count(out, "Using cache"), 4)) du2, err := client.DiskUsage(context.TODO()) @@ -67,7 +64,7 @@ func TestBuildWithSession(t *testing.T) { // FIXME(vdemeester) use sock here res, body, err := request.Do( "/build", - request.Host(d.Sock()), + request.Host(client.DaemonHost()), request.Method(http.MethodPost), request.RawContent(fctx.AsTarReader(t)), request.ContentType("application/x-tar")) @@ -87,7 +84,7 @@ func TestBuildWithSession(t *testing.T) { assert.Check(t, is.Equal(du.BuilderSize, int64(0))) } -func testBuildWithSession(t *testing.T, client dclient.APIClient, daemonSock string, dir, dockerfile string) (outStr string) { +func testBuildWithSession(t *testing.T, client dclient.APIClient, daemonHost string, dir, dockerfile string) (outStr string) { sess, err := session.NewSession("foo1", "foo") assert.Check(t, err) @@ -106,7 +103,7 @@ func testBuildWithSession(t *testing.T, client dclient.APIClient, daemonSock str // FIXME use sock here res, body, err := request.Do( "/build?remote=client-session&session="+sess.ID(), - request.Host(daemonSock), + request.Host(daemonHost), request.Method(http.MethodPost), request.With(func(req *http.Request) error { req.Body = ioutil.NopCloser(strings.NewReader(dockerfile)) diff --git a/components/engine/integration/build/build_squash_test.go b/components/engine/integration/build/build_squash_test.go index faac658d7d..9110604e4f 100644 --- a/components/engine/integration/build/build_squash_test.go +++ b/components/engine/integration/build/build_squash_test.go @@ -10,20 +10,17 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/integration/internal/container" - "github.com/docker/docker/internal/test/daemon" "github.com/docker/docker/internal/test/fakecontext" "github.com/docker/docker/pkg/stdcopy" "github.com/gotestyourself/gotestyourself/assert" is "github.com/gotestyourself/gotestyourself/assert/cmp" + "github.com/gotestyourself/gotestyourself/skip" ) func TestBuildSquashParent(t *testing.T) { - d := daemon.New(t, daemon.WithExperimental) - d.StartWithBusybox(t) - defer d.Stop(t) + skip.If(t, !testEnv.DaemonInfo.ExperimentalBuild) - client, err := d.NewClient() - assert.NilError(t, err) + client := testEnv.APIClient() dockerfile := ` FROM busybox diff --git a/components/engine/integration/container/daemon_linux_test.go b/components/engine/integration/container/daemon_linux_test.go index abcf9b0d06..df6aa683ab 100644 --- a/components/engine/integration/container/daemon_linux_test.go +++ b/components/engine/integration/container/daemon_linux_test.go @@ -27,7 +27,7 @@ import ( // the container process, then start dockerd back up and attempt to start the // container again. func TestContainerStartOnDaemonRestart(t *testing.T) { - skip.If(t, testEnv.IsRemoteDaemon(), "cannot start daemon on remote test run") + skip.If(t, testEnv.IsRemoteDaemon, "cannot start daemon on remote test run") t.Parallel() d := daemon.New(t) diff --git a/components/engine/integration/container/restart_test.go b/components/engine/integration/container/restart_test.go index 630c50f42b..64e37cf749 100644 --- a/components/engine/integration/container/restart_test.go +++ b/components/engine/integration/container/restart_test.go @@ -14,7 +14,7 @@ import ( ) func TestDaemonRestartKillContainers(t *testing.T) { - skip.If(t, testEnv.IsRemoteDaemon(), "cannot start daemon on remote test run") + skip.If(t, testEnv.IsRemoteDaemon, "cannot start daemon on remote test run") type testCase struct { desc string config *container.Config diff --git a/components/engine/integration/internal/swarm/service.go b/components/engine/integration/internal/swarm/service.go index 506bb778de..cea482a1f9 100644 --- a/components/engine/integration/internal/swarm/service.go +++ b/components/engine/integration/internal/swarm/service.go @@ -50,7 +50,7 @@ func ContainerPoll(config *poll.Settings) { // NewSwarm creates a swarm daemon for testing func NewSwarm(t *testing.T, testEnv *environment.Execution, ops ...func(*daemon.Daemon)) *daemon.Daemon { t.Helper() - skip.IfCondition(t, testEnv.IsRemoteDaemon()) + skip.If(t, testEnv.IsRemoteDaemon) if testEnv.DaemonInfo.ExperimentalBuild { ops = append(ops, daemon.WithExperimental) } diff --git a/components/engine/integration/plugin/authz/main_test.go b/components/engine/integration/plugin/authz/main_test.go index 1958ce376a..54bf259e95 100644 --- a/components/engine/integration/plugin/authz/main_test.go +++ b/components/engine/integration/plugin/authz/main_test.go @@ -47,7 +47,7 @@ func TestMain(m *testing.M) { } func setupTest(t *testing.T) func() { - skip.IfCondition(t, testEnv.IsRemoteDaemon(), "cannot run daemon when remote daemon") + skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") environment.ProtectAll(t, testEnv) d = daemon.New(t, daemon.WithExperimental) diff --git a/components/engine/integration/plugin/graphdriver/external_test.go b/components/engine/integration/plugin/graphdriver/external_test.go index d42700beab..11e24aec70 100644 --- a/components/engine/integration/plugin/graphdriver/external_test.go +++ b/components/engine/integration/plugin/graphdriver/external_test.go @@ -46,7 +46,7 @@ type graphEventsCounter struct { func TestExternalGraphDriver(t *testing.T) { skip.If(t, runtime.GOOS == "windows") - skip.If(t, testEnv.IsRemoteDaemon(), "cannot run daemon when remote daemon") + skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") skip.If(t, !requirement.HasHubConnectivity(t)) // Setup plugin(s) @@ -405,7 +405,7 @@ func testGraphDriverPull(c client.APIClient, d *daemon.Daemon) func(*testing.T) 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, 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, !requirement.Overlay2Supported(testEnv.DaemonInfo.KernelVersion)) diff --git a/components/engine/integration/plugin/logging/validation_test.go b/components/engine/integration/plugin/logging/validation_test.go index 7f67aea75c..b0398cc6ab 100644 --- a/components/engine/integration/plugin/logging/validation_test.go +++ b/components/engine/integration/plugin/logging/validation_test.go @@ -14,7 +14,7 @@ import ( // Ensure that a daemon with a log plugin set as the default logger for containers // does not keep the daemon from starting. func TestDaemonStartWithLogOpt(t *testing.T) { - skip.IfCondition(t, testEnv.IsRemoteDaemon(), "cannot run daemon when remote daemon") + skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") t.Parallel() d := daemon.New(t) diff --git a/components/engine/integration/plugin/volumes/mounts_test.go b/components/engine/integration/plugin/volumes/mounts_test.go index 8cb58f2804..97e8222797 100644 --- a/components/engine/integration/plugin/volumes/mounts_test.go +++ b/components/engine/integration/plugin/volumes/mounts_test.go @@ -10,11 +10,13 @@ import ( "github.com/docker/docker/internal/test/daemon" "github.com/docker/docker/internal/test/fixtures/plugin" "github.com/gotestyourself/gotestyourself/assert" + "github.com/gotestyourself/gotestyourself/skip" ) // TestPluginWithDevMounts tests very specific regression caused by mounts ordering // (sorted in the daemon). See #36698 func TestPluginWithDevMounts(t *testing.T) { + skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") t.Parallel() d := daemon.New(t) diff --git a/components/engine/integration/service/plugin_test.go b/components/engine/integration/service/plugin_test.go index 7617e4d480..29a0398323 100644 --- a/components/engine/integration/service/plugin_test.go +++ b/components/engine/integration/service/plugin_test.go @@ -21,6 +21,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") defer setupTest(t)() diff --git a/components/engine/integration/volume/volume_test.go b/components/engine/integration/volume/volume_test.go index ac67292548..d4dc648771 100644 --- a/components/engine/integration/volume/volume_test.go +++ b/components/engine/integration/volume/volume_test.go @@ -16,9 +16,11 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/gotestyourself/gotestyourself/assert" is "github.com/gotestyourself/gotestyourself/assert/cmp" + "github.com/gotestyourself/gotestyourself/skip" ) func TestVolumesCreateAndList(t *testing.T) { + skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") defer setupTest(t)() client := request.NewAPIClient(t) ctx := context.Background()