Skip to content

Commit

Permalink
fix: make tests compatible with nerdctlv1.5
Browse files Browse the repository at this point in the history
nerdctl released v1.5 and we saw some test regressions in
runfinch/finch#521:

* compose container suffix changed
* cp now works with stopped containers
* nested bind mounts issue resolved

Signed-off-by: Gavin Inglis <[email protected]>
  • Loading branch information
ginglis13 committed Aug 8, 2023
1 parent 2755cb2 commit 10f0759
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/compose_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
// ComposeBuild tests functionality of `compose build` command.
func ComposeBuild(o *option.Option) {
services := []string{"svc1_build_cmd", "svc2_build_cmd"}
imageSuffix := []string{"alpine:latest", "_svc2_build_cmd:latest"}
imageSuffix := []string{"alpine:latest", "-svc2_build_cmd:latest"}
ginkgo.Describe("Compose build command", func() {
var composeContext string
var composeFilePath string
Expand Down
9 changes: 6 additions & 3 deletions tests/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,23 @@ func Cp(o *option.Option) {
})

ginkgo.When("the container is not running", func() {
// TODO: not working either with Run or RunWithoutSuccessfulExit..
ginkgo.It("should not be able to copy file from host to container", func() {
command.Run(o, "run", "--name", testContainerName, defaultImage)
path := ffs.CreateTempFile(filename, content)
ginkgo.DeferCleanup(os.RemoveAll, filepath.Dir(path))
command.RunWithoutSuccessfulExit(o, "cp", path, containerResource)
command.Run(o, "cp", path, containerResource)
fileShouldExistInContainer(o, testContainerName, containerFilepath, content)
})

ginkgo.It("should not be able to copy file from container to host", func() {
ginkgo.It("should be able to copy file from container to host", func() {
cmd := fmt.Sprintf("echo -n %s > %s", content, containerFilepath)
command.Run(o, "run", "--name", testContainerName, defaultImage, "sh", "-c", cmd)
fileDir := ffs.CreateTempDir("finch-test")
path := filepath.Join(fileDir, filename)
ginkgo.DeferCleanup(os.RemoveAll, fileDir)
command.RunWithoutSuccessfulExit(o, "cp", containerResource, path)
command.Run(o, "cp", containerResource, path)
fileShouldExist(path, content)
})
})
})
Expand Down
3 changes: 2 additions & 1 deletion tests/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ func Run(o *RunOption) {

// Mount nested directory first followed by parent directory
// Upstream issue: https://github.com/containerd/nerdctl/issues/2254
command.RunWithoutSuccessfulExit(o.BaseOpt, "run", "--rm", "--name", testContainerName,
// has been resolved. TODO to remove FINCH_DOCKER_COMPAT
command.Run(o.BaseOpt, "run", "--rm", "--name", testContainerName,
"-v", nestedDirectory+":"+nestedDirectory,
"-v", tempDir+":"+hostDirectory,
defaultImage, "sh", "-c", "ls "+nestedDirectory)
Expand Down

0 comments on commit 10f0759

Please sign in to comment.