mirror of https://github.com/docker/buildx.git
Merge pull request #1897 from crazy-max/test-containerd-snap
test: register docker worker with containerd snapshotter
This commit is contained in:
commit
b3a4f95110
|
@ -66,6 +66,7 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
worker:
|
worker:
|
||||||
- docker
|
- docker
|
||||||
|
- docker\+containerd # same as docker, but with containerd snapshotter
|
||||||
- docker-container
|
- docker-container
|
||||||
- remote
|
- remote
|
||||||
pkg:
|
pkg:
|
||||||
|
@ -101,8 +102,8 @@ jobs:
|
||||||
export TEST_REPORT_SUFFIX=-${{ github.job }}-$(echo "${{ matrix.pkg }}-${{ matrix.skip-integration-tests }}-${{ matrix.worker }}" | tr -dc '[:alnum:]-\n\r' | tr '[:upper:]' '[:lower:]')
|
export TEST_REPORT_SUFFIX=-${{ github.job }}-$(echo "${{ matrix.pkg }}-${{ matrix.skip-integration-tests }}-${{ matrix.worker }}" | tr -dc '[:alnum:]-\n\r' | tr '[:upper:]' '[:lower:]')
|
||||||
./hack/test
|
./hack/test
|
||||||
env:
|
env:
|
||||||
TEST_DOCKERD: "${{ (matrix.worker == 'docker' || matrix.worker == 'docker-container') && '1' || '0' }}"
|
TEST_DOCKERD: "${{ startsWith(matrix.worker, 'docker') && '1' || '0' }}"
|
||||||
TESTFLAGS: "${{ (matrix.worker == 'docker') && env.TESTFLAGS_DOCKER || env.TESTFLAGS }} --run=//worker=${{ matrix.worker }}$"
|
TESTFLAGS: "${{ (matrix.worker == 'docker' || matrix.worker == 'docker\\+containerd') && env.TESTFLAGS_DOCKER || env.TESTFLAGS }} --run=//worker=${{ matrix.worker }}$"
|
||||||
TESTPKGS: "${{ matrix.pkg }}"
|
TESTPKGS: "${{ matrix.pkg }}"
|
||||||
SKIP_INTEGRATION_TESTS: "${{ matrix.skip-integration-tests }}"
|
SKIP_INTEGRATION_TESTS: "${{ matrix.skip-integration-tests }}"
|
||||||
-
|
-
|
||||||
|
|
36
Dockerfile
36
Dockerfile
|
@ -2,13 +2,12 @@
|
||||||
|
|
||||||
ARG GO_VERSION=1.20
|
ARG GO_VERSION=1.20
|
||||||
ARG XX_VERSION=1.2.1
|
ARG XX_VERSION=1.2.1
|
||||||
ARG DOCKERD_VERSION=20.10.14
|
|
||||||
|
ARG DOCKER_VERSION=24.0.2
|
||||||
ARG GOTESTSUM_VERSION=v1.9.0
|
ARG GOTESTSUM_VERSION=v1.9.0
|
||||||
ARG REGISTRY_VERSION=2.8.0
|
ARG REGISTRY_VERSION=2.8.0
|
||||||
ARG BUILDKIT_VERSION=v0.11.6
|
ARG BUILDKIT_VERSION=v0.11.6
|
||||||
|
|
||||||
FROM docker:$DOCKERD_VERSION AS dockerd-release
|
|
||||||
|
|
||||||
# xx is a helper for cross-compilation
|
# xx is a helper for cross-compilation
|
||||||
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
|
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
|
||||||
|
|
||||||
|
@ -25,6 +24,22 @@ FROM registry:$REGISTRY_VERSION AS registry
|
||||||
|
|
||||||
FROM moby/buildkit:$BUILDKIT_VERSION AS buildkit
|
FROM moby/buildkit:$BUILDKIT_VERSION AS buildkit
|
||||||
|
|
||||||
|
FROM gobase AS docker
|
||||||
|
ARG TARGETPLATFORM
|
||||||
|
ARG DOCKER_VERSION
|
||||||
|
WORKDIR /opt/docker
|
||||||
|
RUN DOCKER_ARCH=$(case ${TARGETPLATFORM:-linux/amd64} in \
|
||||||
|
"linux/amd64") echo "x86_64" ;; \
|
||||||
|
"linux/arm/v6") echo "armel" ;; \
|
||||||
|
"linux/arm/v7") echo "armhf" ;; \
|
||||||
|
"linux/arm64") echo "aarch64" ;; \
|
||||||
|
"linux/ppc64le") echo "ppc64le" ;; \
|
||||||
|
"linux/s390x") echo "s390x" ;; \
|
||||||
|
*) echo "" ;; esac) \
|
||||||
|
&& echo "DOCKER_ARCH=$DOCKER_ARCH" \
|
||||||
|
&& wget -qO- "https://download.docker.com/linux/static/stable/${DOCKER_ARCH}/docker-${DOCKER_VERSION}.tgz" | tar xvz --strip 1
|
||||||
|
RUN ./dockerd --version && ./containerd --version && ./ctr --version && ./runc --version
|
||||||
|
|
||||||
FROM gobase AS gotestsum
|
FROM gobase AS gotestsum
|
||||||
ARG GOTESTSUM_VERSION
|
ARG GOTESTSUM_VERSION
|
||||||
ENV GOFLAGS=
|
ENV GOFLAGS=
|
||||||
|
@ -77,9 +92,20 @@ FROM binaries-$TARGETOS AS binaries
|
||||||
ARG BUILDKIT_SBOM_SCAN_STAGE=true
|
ARG BUILDKIT_SBOM_SCAN_STAGE=true
|
||||||
|
|
||||||
FROM gobase AS integration-test-base
|
FROM gobase AS integration-test-base
|
||||||
RUN apk add --no-cache docker runc containerd
|
# https://github.com/docker/docker/blob/master/project/PACKAGERS.md#runtime-dependencies
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
btrfs-progs \
|
||||||
|
e2fsprogs \
|
||||||
|
e2fsprogs-extra \
|
||||||
|
ip6tables \
|
||||||
|
iptables \
|
||||||
|
openssl \
|
||||||
|
shadow-uidmap \
|
||||||
|
xfsprogs \
|
||||||
|
xz
|
||||||
COPY --link --from=gotestsum /out/gotestsum /usr/bin/
|
COPY --link --from=gotestsum /out/gotestsum /usr/bin/
|
||||||
COPY --link --from=registry /bin/registry /usr/bin/
|
COPY --link --from=registry /bin/registry /usr/bin/
|
||||||
|
COPY --link --from=docker /opt/docker/* /usr/bin/
|
||||||
COPY --link --from=buildkit /usr/bin/buildkitd /usr/bin/
|
COPY --link --from=buildkit /usr/bin/buildkitd /usr/bin/
|
||||||
COPY --link --from=buildkit /usr/bin/buildctl /usr/bin/
|
COPY --link --from=buildkit /usr/bin/buildctl /usr/bin/
|
||||||
COPY --link --from=binaries /buildx /usr/bin/
|
COPY --link --from=binaries /buildx /usr/bin/
|
||||||
|
@ -102,7 +128,7 @@ FROM scratch AS release
|
||||||
COPY --from=releaser /out/ /
|
COPY --from=releaser /out/ /
|
||||||
|
|
||||||
# Shell
|
# Shell
|
||||||
FROM docker:$DOCKERD_VERSION AS dockerd-release
|
FROM docker:$DOCKER_VERSION AS dockerd-release
|
||||||
FROM alpine AS shell
|
FROM alpine AS shell
|
||||||
RUN apk add --no-cache iptables tmux git vim less openssh
|
RUN apk add --no-cache iptables tmux git vim less openssh
|
||||||
RUN mkdir -p /usr/local/lib/docker/cli-plugins && ln -s /usr/local/bin/buildx /usr/local/lib/docker/cli-plugins/docker-buildx
|
RUN mkdir -p /usr/local/lib/docker/cli-plugins && ln -s /usr/local/bin/buildx /usr/local/lib/docker/cli-plugins/docker-buildx
|
||||||
|
|
|
@ -106,7 +106,7 @@ func testImageIDOutput(t *testing.T, sb integration.Sandbox) {
|
||||||
|
|
||||||
cmd := buildxCmd(
|
cmd := buildxCmd(
|
||||||
sb,
|
sb,
|
||||||
withArgs("build", "-q", outFlag, "--iidfile", filepath.Join(targetDir, "iid.txt"), "--metadata-file", filepath.Join(targetDir, "md.json"), dir),
|
withArgs("build", "-q", "--provenance", "false", outFlag, "--iidfile", filepath.Join(targetDir, "iid.txt"), "--metadata-file", filepath.Join(targetDir, "md.json"), dir),
|
||||||
)
|
)
|
||||||
stdout := bytes.NewBuffer(nil)
|
stdout := bytes.NewBuffer(nil)
|
||||||
cmd.Stdout = stdout
|
cmd.Stdout = stdout
|
||||||
|
|
|
@ -33,6 +33,8 @@ func testInspect(t *testing.T, sb integration.Sandbox) {
|
||||||
driver = strings.TrimSpace(v)
|
driver = strings.TrimSpace(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
require.Equal(t, sb.Address(), name)
|
require.Equal(t, sb.Address(), name)
|
||||||
require.Equal(t, sb.Name(), driver)
|
sbDriver, _, _ := strings.Cut(sb.Name(), "+")
|
||||||
|
require.Equal(t, sbDriver, driver)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,10 @@ func testLs(t *testing.T, sb integration.Sandbox) {
|
||||||
out, err := lsCmd(sb)
|
out, err := lsCmd(sb)
|
||||||
require.NoError(t, err, string(out))
|
require.NoError(t, err, string(out))
|
||||||
|
|
||||||
|
sbDriver, _, _ := strings.Cut(sb.Name(), "+")
|
||||||
for _, line := range strings.Split(out, "\n") {
|
for _, line := range strings.Split(out, "\n") {
|
||||||
if strings.Contains(line, sb.Address()) {
|
if strings.Contains(line, sb.Address()) {
|
||||||
require.Contains(t, line, sb.Name())
|
require.Contains(t, line, sbDriver)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,15 @@ func InitDockerWorker() {
|
||||||
integration.Register(&dockerWorker{
|
integration.Register(&dockerWorker{
|
||||||
id: "docker",
|
id: "docker",
|
||||||
})
|
})
|
||||||
|
integration.Register(&dockerWorker{
|
||||||
|
id: "docker+containerd",
|
||||||
|
containerdSnapshotter: true,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type dockerWorker struct {
|
type dockerWorker struct {
|
||||||
id string
|
id string
|
||||||
|
containerdSnapshotter bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c dockerWorker) Name() string {
|
func (c dockerWorker) Name() string {
|
||||||
|
@ -31,6 +36,7 @@ func (c dockerWorker) Rootless() bool {
|
||||||
func (c dockerWorker) New(ctx context.Context, cfg *integration.BackendConfig) (b integration.Backend, cl func() error, err error) {
|
func (c dockerWorker) New(ctx context.Context, cfg *integration.BackendConfig) (b integration.Backend, cl func() error, err error) {
|
||||||
moby := integration.Moby{
|
moby := integration.Moby{
|
||||||
ID: c.id,
|
ID: c.id,
|
||||||
|
ContainerdSnapshotter: c.containerdSnapshotter,
|
||||||
}
|
}
|
||||||
bk, bkclose, err := moby.New(ctx, cfg)
|
bk, bkclose, err := moby.New(ctx, cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue