diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index 0311b11769..2475958580 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -1551,11 +1551,8 @@ func (s *PodmanSessionIntegration) jq(jqCommand string) (string, error) { } func (p *PodmanTestIntegration) buildImage(dockerfile, imageName string, layers string, label string, extraOptions []string) string { - 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) + dockerfilePath := filepath.Join(p.TempDir, "Dockerfile-"+stringid.GenerateRandomID()) + err := os.WriteFile(dockerfilePath, []byte(dockerfile), 0o755) Expect(err).ToNot(HaveOccurred()) cmd := []string{"build", "--pull-never", "--layers=" + layers, "--file", dockerfilePath} if label != "" { @@ -1567,7 +1564,7 @@ func (p *PodmanTestIntegration) buildImage(dockerfile, imageName string, layers if len(extraOptions) > 0 { cmd = append(cmd, extraOptions...) } - cmd = append(cmd, buildDir) + cmd = append(cmd, p.TempDir) 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 feaa083965..45fc033f1f 100644 --- a/test/e2e/container_create_volume_test.go +++ b/test/e2e/container_create_volume_test.go @@ -10,17 +10,12 @@ 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(buildDir, data) - err = os.WriteFile(dummyFile, []byte(data), 0o644) + dummyFile := filepath.Join(pTest.TempDir, data) + err := os.WriteFile(dummyFile, []byte(data), 0o644) Expect(err).ToNot(HaveOccurred()) // Create a data volume container image but no CMD binary in it @@ -28,11 +23,7 @@ func buildDataVolumeImage(pTest *PodmanTestIntegration, image, data, dest string CMD doesnotexist.sh ADD %s %s/ VOLUME %s/`, data, dest, dest) - - 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) + pTest.BuildImage(containerFile, image, "false") } func createContainersConfFile(pTest *PodmanTestIntegration) { diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go index a7e3a72d71..9f74b16735 100644 --- a/test/e2e/pod_create_test.go +++ b/test/e2e/pod_create_test.go @@ -20,7 +20,6 @@ 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() { @@ -176,12 +175,8 @@ var _ = Describe("Podman pod create", func() { Describe("podman create pod with --hosts-file", func() { BeforeEach(func() { - 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) + imageHosts := filepath.Join(podmanTest.TempDir, "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") @@ -196,16 +191,11 @@ var _ = Describe("Podman pod create", func() { podmanTest.RestartRemoteService() } - containerfile := strings.Join([]string{ + dockerfile := strings.Join([]string{ `FROM ` + INFRA_IMAGE, `COPY pause_hosts /etc/hosts`, }, "\n") - - 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) + podmanTest.BuildImage(dockerfile, "foobar.com/hosts_test_pause:latest", "false", "--no-hosts") }) It("--hosts-file=path", func() { diff --git a/test/e2e/pull_chunked_test.go b/test/e2e/pull_chunked_test.go index 5723f32c1d..3be2573eb0 100644 --- a/test/e2e/pull_chunked_test.go +++ b/test/e2e/pull_chunked_test.go @@ -69,18 +69,11 @@ 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(buildDir, chunkedNormalContentPath), fmt.Appendf(nil, "content-%d", rand.Int64()), 0o600) + err := os.WriteFile(filepath.Join(podmanTest.TempDir, chunkedNormalContentPath), fmt.Appendf(nil, "content-%d", rand.Int64()), 0o600) Expect(err).NotTo(HaveOccurred()) chunkedNormalContainerFile := fmt.Sprintf("FROM scratch\nADD %s /content", chunkedNormalContentPath) - 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.BuildImage(chunkedNormalContainerFile, chunkedNormal.localTag(), "true") 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()