Skip to content

Commit

Permalink
support test integration docker 23 compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Kay Yan <kay.yan@daocloud.io>
  • Loading branch information
yankay committed Aug 10, 2023
1 parent 2486f7b commit b4cd36f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 23 deletions.
17 changes: 2 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,27 +181,14 @@ jobs:
go-version: ${{ env.GO_VERSION }}
cache: true
check-latest: true
# Docker >= 23 is still unsupported: https://github.com/containerd/nerdctl/issues/2421
- name: "Install Docker 20.10"
- name: "Enable BuildKit"
run: |
set -eux -o pipefail
# Uninstall the preinstalled Docker (Moby)
sudo apt-get remove moby-*
# Enable BuildKit explicitly
sudo apt-get install -y moreutils
cat /etc/docker/daemon.json
jq '.features.buildkit = true' </etc/docker/daemon.json | sudo sponge /etc/docker/daemon.json
cat /etc/docker/daemon.json
# Download Docker packages
curl -OSL https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/containerd.io_1.6.22-1_amd64.deb
curl -OSL https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce_20.10.24~3-0~ubuntu-jammy_amd64.deb
curl -OSL https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce-cli_20.10.24~3-0~ubuntu-jammy_amd64.deb
curl -OSL https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-buildx-plugin_0.11.2-1~ubuntu.22.04~jammy_amd64.deb
curl -OSL https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-compose-plugin_2.20.2-1~ubuntu.22.04~jammy_amd64.deb
# Install Docker
sudo apt-get install -y ./*.deb
rm -f ./*.deb
# Print docker info
sudo systemctl restart docker
docker info
docker version
- name: "Register QEMU (tonistiigi/binfmt)"
Expand Down
4 changes: 2 additions & 2 deletions cmd/nerdctl/builder_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ CMD echo $TEST_STRING
})
}

t.Run("InvalidBuildArgCausesError", func(t *testing.T) {
base.Cmd("build", buildCtx, "-t", imageName, "--build-arg", "=TEST_STRING").AssertFail()
t.Run("InvalidBuildArgNotCausesError", func(t *testing.T) {
base.Cmd("build", buildCtx, "-t", imageName, "--build-arg", "=TEST_STRING").AssertOK()
})
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/compose_up_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ services:
Err: `exec: \"invalid\": executable file not found in $PATH`,
}
if base.Target == testutil.Docker {
expected.Err = `Unknown runtime specified invalid`
expected.Err = `unknown or invalid runtime name: invalid`
}
c.Assert(expected)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/nerdctl/system_prune_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestSystemPrune(t *testing.T) {
base.Cmd("images").AssertOutContains(testutil.ImageRepo(testutil.CommonImage))

base.Cmd("system", "prune", "-f", "--volumes", "--all").AssertOK()
base.Cmd("volume", "ls").AssertNoOut(vID)
base.Cmd("volume", "ls").AssertOutContains(vID) // docker system prune --all --volume does not prune named volume
base.Cmd("ps", "-a").AssertNoOut(tID)
base.Cmd("network", "ls").AssertNoOut(nID)
base.Cmd("images").AssertNoOut(testutil.ImageRepo(testutil.CommonImage))
Expand Down
6 changes: 3 additions & 3 deletions cmd/nerdctl/volume_prune_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ import (
func TestVolumePrune(t *testing.T) {
base := testutil.NewBase(t)
tID := testutil.Identifier(t)
base.Cmd("volume", "prune", "-f").Run()
base.Cmd("volume", "prune", "-a", "-f").Run()

base.Cmd("volume", "create", tID+"-1").AssertOK()
base.Cmd("volume", "create", tID+"-2").AssertOK()

base.Cmd("run", "-v", fmt.Sprintf("%s:/volume", tID+"-1"), "--name", tID, testutil.CommonImage).AssertOK()
defer base.Cmd("rm", "-f", tID).Run()

base.Cmd("volume", "prune", "-f").AssertOutContains(tID + "-2")
base.Cmd("volume", "prune", "-a", "-f").AssertOutContains(tID + "-2")
base.Cmd("volume", "ls").AssertOutContains(tID + "-1")
base.Cmd("volume", "ls").AssertNoOut(tID + "-2")

base.Cmd("rm", "-f", tID).AssertOK()
base.Cmd("volume", "prune", "-f").AssertOK()
base.Cmd("volume", "prune", "-a", "-f").AssertOK()
base.Cmd("volume", "ls").AssertNoOut(tID + "-1")
}
2 changes: 1 addition & 1 deletion pkg/cmd/builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func generateBuildctlArgs(ctx context.Context, client *containerd.Client, option
} else {
logrus.Debugf("ignoring unset build arg %q", ba)
}
} else if len(arr) > 1 && len(arr[0]) > 0 {
} else if len(arr) > 1 {
buildctlArgs = append(buildctlArgs, "--opt=build-arg:"+ba)

// Support `--build-arg BUILDKIT_INLINE_CACHE=1` for compatibility with `docker buildx build`
Expand Down

0 comments on commit b4cd36f

Please sign in to comment.