Skip to content

Commit

Permalink
Merge pull request #22532 from Luap99/more-e2e-fixes
Browse files Browse the repository at this point in the history
test/e2e: more fixes to not leak tmp files/dirs
  • Loading branch information
openshift-merge-bot[bot] authored Apr 29, 2024
2 parents 9ac6d9d + 88b80c1 commit 9eefb5d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
8 changes: 3 additions & 5 deletions test/e2e/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,24 +441,22 @@ RUN find /test`, CITEST_IMAGE)
It("podman remote build must not allow symlink for ignore files", func() {
// Create a random file where symlink must be resolved
// but build should not be able to access it.
privateFile := filepath.Join("/tmp", "private_file")
privateFile := filepath.Join(podmanTest.TempDir, "private_file")
f, err := os.Create(privateFile)
Expect(err).ToNot(HaveOccurred())
// Mark hello to be ignored in outerfile, but it should not be ignored.
_, err = f.WriteString("hello\n")
Expect(err).ToNot(HaveOccurred())
defer f.Close()

// Create .dockerignore which is a symlink to /tmp/private_file.
// Create .dockerignore which is a symlink to /tmp/.../private_file outside of the context dir.
currentDir, err := os.Getwd()
Expect(err).ToNot(HaveOccurred())
ignoreFile := filepath.Join(currentDir, "build/containerignore-symlink/.dockerignore")
err = os.Symlink(privateFile, ignoreFile)
Expect(err).ToNot(HaveOccurred())
// Remove created .dockerignore for this test when test ends.
defer func() {
os.Remove(ignoreFile)
}()
defer os.Remove(ignoreFile)

if IsRemote() {
podmanTest.StopRemoteService()
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/mount_rootless_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package integration

import (
"slices"

. "github.com/containers/podman/v5/test/utils"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -63,5 +65,14 @@ var _ = Describe("Podman mount", func() {
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
Expect(session.OutputToString()).To(ContainSubstring(podmanTest.TempDir))

// We have to unmount the image again otherwise we leak the tmpdir
// as active mount points cannot be removed.
index := slices.Index(args, "mount")
Expect(index).To(BeNumerically(">", 0), "index should be found")
args[index] = "unmount"
session = podmanTest.Podman(args)
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
})
})
2 changes: 1 addition & 1 deletion test/e2e/play_kube_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4093,7 +4093,7 @@ o: {{ .Options.o }}`})
It("persistentVolumeClaim with source", func() {
fileName := "data"
expectedFileContent := "Test"
tarFilePath := filepath.Join(os.TempDir(), "podmanVolumeSource.tgz")
tarFilePath := filepath.Join(podmanTest.TempDir, "podmanVolumeSource.tgz")
err := createSourceTarFile(fileName, expectedFileContent, tarFilePath)
Expect(err).ToNot(HaveOccurred())

Expand Down

1 comment on commit 9eefb5d

@packit-as-a-service
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

podman-next COPR build failed. @containers/packit-build please check.

Please sign in to comment.