From 10f0759185638b6dc46c3b8bc2e7df7f962f69e7 Mon Sep 17 00:00:00 2001 From: Gavin Inglis Date: Mon, 7 Aug 2023 19:09:05 -0700 Subject: [PATCH] fix: make tests compatible with nerdctlv1.5 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 --- tests/compose_build.go | 2 +- tests/cp.go | 9 ++++++--- tests/run.go | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/compose_build.go b/tests/compose_build.go index c98538a..5c75b42 100644 --- a/tests/compose_build.go +++ b/tests/compose_build.go @@ -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 diff --git a/tests/cp.go b/tests/cp.go index e44b959..3e48af0 100644 --- a/tests/cp.go +++ b/tests/cp.go @@ -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) }) }) }) diff --git a/tests/run.go b/tests/run.go index 869cf3c..7a3f0b7 100644 --- a/tests/run.go +++ b/tests/run.go @@ -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)