diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 862a4e0b3a..99e32382bc 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -1547,8 +1547,11 @@ func (s *PodmanSessionIntegration) jq(jqCommand string) (string, error) { } func (p *PodmanTestIntegration) buildImage(dockerfile, imageName string, layers string, label string, extraOptions []string) string { - dockerfilePath := filepath.Join(p.TempDir, "Dockerfile-"+stringid.GenerateRandomID()) - err := os.WriteFile(dockerfilePath, []byte(dockerfile), 0o755) + buildDir := filepath.Join(p.TempDir, "build"+stringid.GenerateRandomID()) + err := os.Mkdir(buildDir, 0o755) + Expect(err).ToNot(HaveOccurred()) + dockerfilePath := filepath.Join(buildDir, "Dockerfile-"+stringid.GenerateRandomID()) + err = os.WriteFile(dockerfilePath, []byte(dockerfile), 0o644) Expect(err).ToNot(HaveOccurred()) cmd := []string{"build", "--pull-never", "--layers=" + layers, "--file", dockerfilePath} if label != "" { @@ -1560,7 +1563,7 @@ func (p *PodmanTestIntegration) buildImage(dockerfile, imageName string, layers if len(extraOptions) > 0 { cmd = append(cmd, extraOptions...) } - cmd = append(cmd, p.TempDir) + cmd = append(cmd, buildDir) session := p.Podman(cmd) session.Wait(240) Expect(session).Should(Exit(0), fmt.Sprintf("BuildImage session output: %q", session.OutputToString())) diff --git a/test/e2e/container_create_volume_test.go b/test/e2e/container_create_volume_test.go index 45fc033f1f..feaa083965 100644 --- a/test/e2e/container_create_volume_test.go +++ b/test/e2e/container_create_volume_test.go @@ -10,12 +10,17 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "go.podman.io/podman/v6/test/utils" + "go.podman.io/storage/pkg/stringid" ) func buildDataVolumeImage(pTest *PodmanTestIntegration, image, data, dest string) { + buildDir := filepath.Join(pTest.TempDir, "build"+stringid.GenerateRandomID()) + err := os.Mkdir(buildDir, 0o755) + Expect(err).ToNot(HaveOccurred()) + // Create a dummy file for data volume - dummyFile := filepath.Join(pTest.TempDir, data) - err := os.WriteFile(dummyFile, []byte(data), 0o644) + dummyFile := filepath.Join(buildDir, data) + err = os.WriteFile(dummyFile, []byte(data), 0o644) Expect(err).ToNot(HaveOccurred()) // Create a data volume container image but no CMD binary in it @@ -23,7 +28,11 @@ func buildDataVolumeImage(pTest *PodmanTestIntegration, image, data, dest string CMD doesnotexist.sh ADD %s %s/ VOLUME %s/`, data, dest, dest) - pTest.BuildImage(containerFile, image, "false") + + containerFilePath := filepath.Join(buildDir, "Containerfile") + err = os.WriteFile(containerFilePath, []byte(containerFile), 0o644) + Expect(err).ToNot(HaveOccurred()) + pTest.PodmanExitCleanly("build", "--pull-never", "-q", "-t", image, "--layers=false", "--file", containerFilePath) } func createContainersConfFile(pTest *PodmanTestIntegration) { diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go index 9f74b16735..a7e3a72d71 100644 --- a/test/e2e/pod_create_test.go +++ b/test/e2e/pod_create_test.go @@ -20,6 +20,7 @@ import ( "go.podman.io/common/pkg/sysinfo" "go.podman.io/podman/v6/pkg/util" . "go.podman.io/podman/v6/test/utils" + "go.podman.io/storage/pkg/stringid" ) var _ = Describe("Podman pod create", func() { @@ -175,8 +176,12 @@ var _ = Describe("Podman pod create", func() { Describe("podman create pod with --hosts-file", func() { BeforeEach(func() { - imageHosts := filepath.Join(podmanTest.TempDir, "pause_hosts") - err := os.WriteFile(imageHosts, []byte("56.78.12.34 image.example.com"), 0o755) + buildDir := filepath.Join(podmanTest.TempDir, "build"+stringid.GenerateRandomID()) + err := os.Mkdir(buildDir, 0o755) + Expect(err).ToNot(HaveOccurred()) + + imageHosts := filepath.Join(buildDir, "pause_hosts") + err = os.WriteFile(imageHosts, []byte("56.78.12.34 image.example.com"), 0o755) Expect(err).ToNot(HaveOccurred()) configHosts := filepath.Join(podmanTest.TempDir, "hosts") @@ -191,11 +196,16 @@ var _ = Describe("Podman pod create", func() { podmanTest.RestartRemoteService() } - dockerfile := strings.Join([]string{ + containerfile := strings.Join([]string{ `FROM ` + INFRA_IMAGE, `COPY pause_hosts /etc/hosts`, }, "\n") - podmanTest.BuildImage(dockerfile, "foobar.com/hosts_test_pause:latest", "false", "--no-hosts") + + containerFilePath := filepath.Join(buildDir, "Containerfile") + err = os.WriteFile(containerFilePath, []byte(containerfile), 0o644) + Expect(err).ToNot(HaveOccurred()) + + podmanTest.PodmanExitCleanly("build", "-q", "-t", "foobar.com/hosts_test_pause:latest", "--layers=false", "--no-hosts", buildDir) }) It("--hosts-file=path", func() { diff --git a/test/e2e/pull_chunked_test.go b/test/e2e/pull_chunked_test.go index 3be2573eb0..5723f32c1d 100644 --- a/test/e2e/pull_chunked_test.go +++ b/test/e2e/pull_chunked_test.go @@ -69,11 +69,18 @@ func pullChunkedTests() { // included in pull_test.go, must use a Ginkgo DSL at registryRef: pullChunkedRegistryPrefix + "chunked-normal", dirPath: filepath.Join(imageDir, "chunked-normal"), } + + buildDir := filepath.Join(podmanTest.TempDir, "build") + err := os.Mkdir(buildDir, 0o755) + Expect(err).ToNot(HaveOccurred()) chunkedNormalContentPath := "chunked-normal-image-content" - err := os.WriteFile(filepath.Join(podmanTest.TempDir, chunkedNormalContentPath), fmt.Appendf(nil, "content-%d", rand.Int64()), 0o600) + err = os.WriteFile(filepath.Join(buildDir, chunkedNormalContentPath), fmt.Appendf(nil, "content-%d", rand.Int64()), 0o600) Expect(err).NotTo(HaveOccurred()) chunkedNormalContainerFile := fmt.Sprintf("FROM scratch\nADD %s /content", chunkedNormalContentPath) - podmanTest.BuildImage(chunkedNormalContainerFile, chunkedNormal.localTag(), "true") + err = os.WriteFile(filepath.Join(buildDir, "Containerfile"), []byte(chunkedNormalContainerFile), 0o600) + Expect(err).NotTo(HaveOccurred()) + podmanTest.PodmanExitCleanly("build", "-q", "-t", chunkedNormal.localTag(), "--layers=true", buildDir) + podmanTest.PodmanExitCleanly("push", "-q", "--tls-verify=false", "--force-compression", "--compression-format=zstd:chunked", chunkedNormal.localTag(), chunkedNormal.registryRef) skopeo := SystemExec("skopeo", []string{"copy", "-q", "--preserve-digests", "--all", "--src-tls-verify=false", chunkedNormal.registryRef, "dir:" + chunkedNormal.dirPath}) skopeo.WaitWithDefaultTimeout()