Merge component 'engine' from git@github.com:moby/moby master

This commit is contained in:
GordonTheTurtle
2018-04-28 17:06:52 +00:00
12 changed files with 34 additions and 26 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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