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..b6914e8 100644 --- a/tests/cp.go +++ b/tests/cp.go @@ -104,20 +104,27 @@ func Cp(o *option.Option) { }) ginkgo.When("the container is not running", func() { - ginkgo.It("should not be able to copy file from host to container", func() { - command.Run(o, "run", "--name", testContainerName, defaultImage) + ginkgo.It("should be able to copy file from host to container", func() { + command.Run(o, "run", "--name", testContainerName, defaultImage, "sleep", "1") + command.Run(o, "stop", testContainerName) path := ffs.CreateTempFile(filename, content) ginkgo.DeferCleanup(os.RemoveAll, filepath.Dir(path)) - command.RunWithoutSuccessfulExit(o, "cp", path, containerResource) + command.Run(o, "cp", path, containerResource) + + // Need to run container to cat file, can't exec in stopped container. + // Start here will sleep 1s again so we can check file in container. + command.Run(o, "container", "start", testContainerName) + 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..8d74a3d 100644 --- a/tests/run.go +++ b/tests/run.go @@ -16,7 +16,6 @@ import ( "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" "github.com/onsi/gomega/gbytes" - "github.com/runfinch/common-tests/fenv" "github.com/runfinch/common-tests/command" "github.com/runfinch/common-tests/ffs" @@ -448,54 +447,12 @@ func Run(o *RunOption) { verifyMountsInfo(actualMount, expectedMount) }) - // TODO: Remove FINCH_DOCKER_COMPAT=1 check when FINCH_DOCKER_COMPAT flag is removed in finch - ginkgo.It("should create nested bind mounts within a container when FINCH_DOCKER_COMPAT is not set", func() { + ginkgo.It("should create nested bind mounts within a container", func() { const ( outerDir = "/outer" nestedDir = "/outer/nested" ) - if fenv.GetEnv("FINCH_DOCKER_COMPAT") == "1" { - ginkgo.Skip("Skipping test: FINCH_DOCKER_COMPAT is set to 1") - } - // Create the nested directory on the host - hostDirectory := ffs.CreateNestedDir(outerDir) - nestedDirectory := ffs.CreateNestedDir(nestedDir) - defer ffs.DeleteDirectory(hostDirectory) - - // Directory on host to be mounted at hostDirectory in container - tempDir := ffs.CreateTempDir("some_dir") - defer ffs.DeleteDirectory(tempDir) - // Write a file to the nested directory - nestedFilePath := filepath.Join(nestedDirectory, "file1.txt") - ffs.WriteFile(nestedFilePath, "test") - - // 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, - "-v", nestedDirectory+":"+nestedDirectory, - "-v", tempDir+":"+hostDirectory, - defaultImage, "sh", "-c", "ls "+nestedDirectory) - - // Mount parent directory first followed by nested - output := command.StdoutStr(o.BaseOpt, "run", "--rm", "--name", testContainerName2, - "-v", tempDir+":"+hostDirectory, - "-v", nestedDirectory+":"+nestedDirectory, - defaultImage, "sh", "-c", "ls "+nestedDirectory) - gomega.Expect(output).Should(gomega.ContainSubstring("file1.txt")) - }) - - // TODO: Remove FINCH_DOCKER_COMPAT=1 check when FINCH_DOCKER_COMPAT flag is removed in finch - // https://github.com/runfinch/finch/pull/417/files - - ginkgo.It("should create nested bind mounts within a container when FINCH_DOCKER_COMPAT is set", func() { - const ( - outerDir = "/outer" - nestedDir = "/outer/nested" - ) - if fenv.GetEnv("FINCH_DOCKER_COMPAT") != "1" { - ginkgo.Skip("Skipping test: FINCH_DOCKER_COMPAT is not set to 1") - } // Create the nested directory on the host hostDirectory := ffs.CreateNestedDir(outerDir) nestedDirectory := ffs.CreateNestedDir(nestedDir)