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