Skip to content

Commit 3bee376

Browse files
authored
Merge pull request #5956 from profnandaa/tests-enable-dockerd-worker
util: testutil: enable `dockerd-containerd` worker for wcow integration tests
2 parents 94f3b37 + f1f804d commit 3bee376

File tree

6 files changed

+54
-5
lines changed

6 files changed

+54
-5
lines changed

util/testutil/dockerd/daemon.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func NewDaemon(workingDir string, ops ...Option) (*Daemon, error) {
7272
execRoot: filepath.Join(os.TempDir(), "dxr", id),
7373
dockerdBinary: DefaultDockerdBinary,
7474
Log: nopLog{},
75-
sockPath: filepath.Join(sockRoot, id+".sock"),
75+
sockPath: getDockerdSockPath(sockRoot, id),
7676
envs: os.Environ(),
7777
}
7878

@@ -96,7 +96,7 @@ func WithExtraEnv(envs []string) Option {
9696
}
9797

9898
func (d *Daemon) Sock() string {
99-
return "unix://" + d.sockPath
99+
return socketScheme + d.sockPath
100100
}
101101

102102
func (d *Daemon) StartWithError(daemonLogs map[string]*bytes.Buffer, providedArgs ...string) error {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//go:build !windows
2+
3+
package dockerd
4+
5+
import "path/filepath"
6+
7+
const socketScheme = "unix://"
8+
9+
func getDockerdSockPath(sockRoot, id string) string {
10+
return filepath.Join(sockRoot, id+".sock")
11+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package dockerd
2+
3+
const socketScheme = "npipe://"
4+
5+
func getDockerdSockPath(_, id string) string {
6+
return `//./pipe/dockerd-` + id
7+
}

util/testutil/workers/dockerd.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ func (c Moby) New(ctx context.Context, cfg *integration.BackendConfig) (b integr
111111
"containerd-snapshotter": c.ContainerdSnapshotter,
112112
},
113113
}
114+
114115
if reg, ok := bkcfg.Registries["docker.io"]; ok && len(reg.Mirrors) > 0 {
115116
for _, m := range reg.Mirrors {
116117
dcfg.Mirrors = append(dcfg.Mirrors, "http://"+m)
@@ -158,10 +159,13 @@ func (c Moby) New(ctx context.Context, cfg *integration.BackendConfig) (b integr
158159

159160
dockerdFlags := []string{
160161
"--config-file", dockerdConfigFile,
161-
"--userland-proxy=false",
162162
"--tls=false",
163163
"--debug",
164164
}
165+
166+
// add platform-specific flags
167+
dockerdFlags = applyDockerdPlatformFlags(dockerdFlags, c.ID)
168+
165169
if s := os.Getenv("BUILDKIT_INTEGRATION_DOCKERD_FLAGS"); s != "" {
166170
dockerdFlags = append(dockerdFlags, strings.Split(strings.TrimSpace(s), "\n")...)
167171
}
@@ -198,7 +202,7 @@ func (c Moby) New(ctx context.Context, cfg *integration.BackendConfig) (b integr
198202
f.Close()
199203
os.Remove(localPath)
200204

201-
listener, err := net.Listen("unix", localPath)
205+
listener, err := net.Listen(buildkitdNetworkProtocol, getBuildkitdNetworkAddr(localPath))
202206
if err != nil {
203207
return nil, nil, errors.Wrapf(err, "dockerd listener error: %s", integration.FormatLogs(cfg.Logs))
204208
}
@@ -234,7 +238,7 @@ func (c Moby) New(ctx context.Context, cfg *integration.BackendConfig) (b integr
234238
})
235239

236240
return backend{
237-
address: "unix://" + listener.Addr().String(),
241+
address: buildkitdNetworkProtocol + "://" + listener.Addr().String(),
238242
dockerAddress: d.Sock(),
239243
rootless: c.IsRootless,
240244
netnsDetached: false,

util/testutil/workers/util_unix.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
"github.com/pkg/errors"
1414
)
1515

16+
const buildkitdNetworkProtocol = "unix"
17+
1618
func applyBuildkitdPlatformFlags(args []string) []string {
1719
return append(args, "--oci-worker=false")
1820
}
@@ -75,3 +77,12 @@ func normalizeAddress(address string) string {
7577
// for parity with windows, no effect for unix
7678
return address
7779
}
80+
81+
func applyDockerdPlatformFlags(flags []string, _ string) []string {
82+
flags = append(flags, "--userland-proxy=false")
83+
return flags
84+
}
85+
86+
func getBuildkitdNetworkAddr(tmpdir string) string {
87+
return tmpdir
88+
}

util/testutil/workers/util_windows.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ import (
44
"path/filepath"
55
"strings"
66
"syscall"
7+
8+
"github.com/containerd/containerd/v2/defaults"
79
)
810

11+
const buildkitdNetworkProtocol = "tcp"
12+
913
func applyBuildkitdPlatformFlags(args []string) []string {
1014
return args
1115
}
@@ -55,3 +59,15 @@ func normalizeAddress(address string) string {
5559
}
5660
return address
5761
}
62+
63+
func applyDockerdPlatformFlags(flags []string, workerID string) []string {
64+
if workerID == "dockerd-containerd" {
65+
flags = append(flags, "--default-runtime="+defaults.DefaultRuntime)
66+
}
67+
return flags
68+
}
69+
70+
func getBuildkitdNetworkAddr(_ string) string {
71+
// Using TCP on Windows, instead of Unix sockets.
72+
return "localhost:0"
73+
}

0 commit comments

Comments
 (0)