mirror of
https://github.com/containers/podman.git
synced 2025-06-30 07:26:39 +08:00
Merge pull request #22207 from edsantiago/e2e-var-tmp
e2e tests: use /var/tmp, not $TMPDIR, as workdirs
This commit is contained in:
@ -33,7 +33,7 @@ env:
|
||||
DEBIAN_NAME: "debian-13"
|
||||
|
||||
# Image identifiers
|
||||
IMAGE_SUFFIX: "c20240409t192511z-f39f38d13"
|
||||
IMAGE_SUFFIX: "c20240411t124913z-f39f38d13"
|
||||
|
||||
# EC2 images
|
||||
FEDORA_AMI: "fedora-aws-${IMAGE_SUFFIX}"
|
||||
|
@ -143,7 +143,7 @@ exec_container() {
|
||||
set -x
|
||||
# shellcheck disable=SC2154
|
||||
exec bin/podman run --rm --privileged --net=host --cgroupns=host \
|
||||
-v `mktemp -d -p /var/tmp`:/tmp:Z \
|
||||
-v `mktemp -d -p /var/tmp`:/var/tmp:Z \
|
||||
-v /dev/fuse:/dev/fuse \
|
||||
-v "$GOPATH:$GOPATH:Z" \
|
||||
--workdir "$GOSRC" \
|
||||
|
@ -62,6 +62,7 @@ type PodmanTestIntegration struct {
|
||||
TmpDir string
|
||||
}
|
||||
|
||||
var GlobalTmpDir string // Single top-level tmpdir for all tests
|
||||
var LockTmpDir string
|
||||
|
||||
// PodmanSessionIntegration struct for command line session
|
||||
@ -101,14 +102,14 @@ func TestLibpod(t *testing.T) {
|
||||
}
|
||||
|
||||
var (
|
||||
tempdir string
|
||||
tempdir string // Working dir for _one_ subtest
|
||||
err error
|
||||
podmanTest *PodmanTestIntegration
|
||||
safeIPOctets [2]uint8
|
||||
timingsFile *os.File
|
||||
|
||||
_ = BeforeEach(func() {
|
||||
tempdir, err = CreateTempDirInTempDir()
|
||||
tempdir, err = os.MkdirTemp(GlobalTmpDir, "subtest-")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
podmanTest = PodmanTestCreate(tempdir)
|
||||
podmanTest.Setup()
|
||||
@ -130,26 +131,34 @@ var (
|
||||
)
|
||||
|
||||
const (
|
||||
// lockdir - do not use directly use LockTmpDir
|
||||
// lockdir - do not use directly; use LockTmpDir
|
||||
lockdir = "libpodlock"
|
||||
// imageCacheDir - do not use directly use ImageCacheDir
|
||||
imageCacheDir = "imagecachedir"
|
||||
)
|
||||
|
||||
var _ = SynchronizedBeforeSuite(func() []byte {
|
||||
globalTmpDir := GinkgoT().TempDir()
|
||||
// One global scratch directory under which all test files will live.
|
||||
// The usual case is that these tests are running in CI, on VMs
|
||||
// with limited RAM, so we use /var/tmp.
|
||||
baseTmpDir := "/var/tmp"
|
||||
if os.Getenv("CI") == "" {
|
||||
// Almost certainly a manual run, e.g., a developer with
|
||||
// a hotrod workstation. Assume they know what they're doing.
|
||||
baseTmpDir = ""
|
||||
}
|
||||
globalTmpDir, err := os.MkdirTemp(baseTmpDir, "podman-e2e-")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
// make cache dir
|
||||
ImageCacheDir = filepath.Join(globalTmpDir, imageCacheDir)
|
||||
if err := os.MkdirAll(ImageCacheDir, 0700); err != nil {
|
||||
GinkgoWriter.Printf("%q\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
err = os.MkdirAll(ImageCacheDir, 0700)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
// Cache images
|
||||
cwd, _ := os.Getwd()
|
||||
INTEGRATION_ROOT = filepath.Join(cwd, "../../")
|
||||
podman := PodmanTestSetup(GinkgoT().TempDir())
|
||||
podman := PodmanTestSetup(filepath.Join(globalTmpDir, "image-init"))
|
||||
|
||||
// Pull cirros but don't put it into the cache
|
||||
pullImages := []string{CIRROS_IMAGE, fedoraToolbox, volumeTest}
|
||||
@ -177,16 +186,16 @@ var _ = SynchronizedBeforeSuite(func() []byte {
|
||||
podman.StopRemoteService()
|
||||
}
|
||||
|
||||
// remove temporary podman files, images are now cached in ImageCacheDir
|
||||
// remove temporary podman files; images are now cached in ImageCacheDir
|
||||
rmAll(podman.PodmanBinary, podman.TempDir)
|
||||
|
||||
return []byte(globalTmpDir)
|
||||
}, func(data []byte) {
|
||||
cwd, _ := os.Getwd()
|
||||
INTEGRATION_ROOT = filepath.Join(cwd, "../../")
|
||||
globalTmpDir := string(data)
|
||||
ImageCacheDir = filepath.Join(globalTmpDir, imageCacheDir)
|
||||
LockTmpDir = filepath.Join(globalTmpDir, lockdir)
|
||||
GlobalTmpDir = string(data)
|
||||
ImageCacheDir = filepath.Join(GlobalTmpDir, imageCacheDir)
|
||||
LockTmpDir = filepath.Join(GlobalTmpDir, lockdir)
|
||||
|
||||
timingsFile, err = os.Create(fmt.Sprintf("%s/timings-%d", LockTmpDir, GinkgoParallelProcess()))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@ -229,7 +238,7 @@ var _ = SynchronizedAfterSuite(func() {
|
||||
}
|
||||
|
||||
cwd, _ := os.Getwd()
|
||||
rmAll(getPodmanBinary(cwd), ImageCacheDir)
|
||||
rmAll(getPodmanBinary(cwd), GlobalTmpDir)
|
||||
})
|
||||
|
||||
func getPodmanBinary(cwd string) string {
|
||||
@ -242,40 +251,38 @@ func getPodmanBinary(cwd string) string {
|
||||
|
||||
// PodmanTestCreate creates a PodmanTestIntegration instance for the tests
|
||||
func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration {
|
||||
var podmanRemoteBinary string
|
||||
|
||||
host := GetHostDistributionInfo()
|
||||
cwd, _ := os.Getwd()
|
||||
|
||||
root := filepath.Join(tempDir, "root")
|
||||
podmanBinary := getPodmanBinary(cwd)
|
||||
|
||||
podmanRemoteBinary = filepath.Join(cwd, "../../bin/podman-remote")
|
||||
if os.Getenv("PODMAN_REMOTE_BINARY") != "" {
|
||||
podmanRemoteBinary = os.Getenv("PODMAN_REMOTE_BINARY")
|
||||
podmanRemoteBinary := os.Getenv("PODMAN_REMOTE_BINARY")
|
||||
if podmanRemoteBinary == "" {
|
||||
podmanRemoteBinary = filepath.Join(cwd, "../../bin/podman-remote")
|
||||
}
|
||||
|
||||
quadletBinary := filepath.Join(cwd, "../../bin/quadlet")
|
||||
if os.Getenv("QUADLET_BINARY") != "" {
|
||||
quadletBinary = os.Getenv("QUADLET_BINARY")
|
||||
quadletBinary := os.Getenv("QUADLET_BINARY")
|
||||
if quadletBinary == "" {
|
||||
quadletBinary = filepath.Join(cwd, "../../bin/quadlet")
|
||||
}
|
||||
|
||||
conmonBinary := "/usr/libexec/podman/conmon"
|
||||
altConmonBinary := "/usr/bin/conmon"
|
||||
if _, err := os.Stat(conmonBinary); os.IsNotExist(err) {
|
||||
conmonBinary = altConmonBinary
|
||||
}
|
||||
if os.Getenv("CONMON_BINARY") != "" {
|
||||
conmonBinary = os.Getenv("CONMON_BINARY")
|
||||
}
|
||||
storageOptions := STORAGE_OPTIONS
|
||||
if os.Getenv("STORAGE_OPTIONS") != "" {
|
||||
storageOptions = os.Getenv("STORAGE_OPTIONS")
|
||||
conmonBinary := os.Getenv("CONMON_BINARY")
|
||||
if conmonBinary == "" {
|
||||
conmonBinary = "/usr/libexec/podman/conmon"
|
||||
if _, err := os.Stat(conmonBinary); errors.Is(err, os.ErrNotExist) {
|
||||
conmonBinary = "/usr/bin/conmon"
|
||||
}
|
||||
}
|
||||
|
||||
cgroupManager := CGROUP_MANAGER
|
||||
if os.Getenv("CGROUP_MANAGER") != "" {
|
||||
cgroupManager = os.Getenv("CGROUP_MANAGER")
|
||||
storageOptions := os.Getenv("STORAGE_OPTIONS")
|
||||
if storageOptions == "" {
|
||||
storageOptions = STORAGE_OPTIONS
|
||||
}
|
||||
|
||||
cgroupManager := os.Getenv("CGROUP_MANAGER")
|
||||
if cgroupManager == "" {
|
||||
cgroupManager = CGROUP_MANAGER
|
||||
}
|
||||
|
||||
ociRuntime := os.Getenv("OCI_RUNTIME")
|
||||
@ -390,10 +397,8 @@ func (p PodmanTestIntegration) AddImageToRWStore(image string) {
|
||||
func imageTarPath(image string) string {
|
||||
cacheDir := os.Getenv("PODMAN_TEST_IMAGE_CACHE_DIR")
|
||||
if cacheDir == "" {
|
||||
cacheDir = os.Getenv("TMPDIR")
|
||||
if cacheDir == "" {
|
||||
cacheDir = "/tmp"
|
||||
}
|
||||
// Avoid /tmp: it may be tmpfs, and these images are large
|
||||
cacheDir = "/var/tmp"
|
||||
}
|
||||
|
||||
// e.g., registry.com/fubar:latest -> registry.com-fubar-latest.tar
|
||||
|
@ -1,11 +1,11 @@
|
||||
## assert-podman-args "kube"
|
||||
## assert-podman-args "play"
|
||||
## assert-podman-final-args-regex .*/podman_test.*/quadlet/deployment.yml
|
||||
## assert-podman-final-args-regex .*/podman-e2e-.*/subtest-.*/quadlet/deployment.yml
|
||||
## assert-podman-args "--replace"
|
||||
## assert-podman-args "--service-container=true"
|
||||
## assert-podman-stop-post-args "kube"
|
||||
## assert-podman-stop-post-args "down"
|
||||
## assert-podman-stop-post-final-args-regex .*/podman_test.*/quadlet/deployment.yml
|
||||
## assert-podman-stop-post-final-args-regex .*/podman-e2e-.*/subtest-.*/quadlet/deployment.yml
|
||||
## assert-key-is "Unit" "RequiresMountsFor" "%t/containers"
|
||||
## assert-key-is "Service" "KillMode" "mixed"
|
||||
## assert-key-is "Service" "Type" "notify"
|
||||
|
@ -1,5 +1,5 @@
|
||||
## assert-podman-args "--configmap" "/opt/k8s/abs.yml"
|
||||
## assert-podman-args-regex "--configmap" ".*/podman_test.*/quadlet/rel.yml"
|
||||
## assert-podman-args-regex "--configmap" ".*/podman-e2e-.*/subtest-.*/quadlet/rel.yml"
|
||||
|
||||
[Kube]
|
||||
Yaml=deployment.yml
|
||||
|
@ -1,7 +1,7 @@
|
||||
## assert-podman-stop-post-args "kube"
|
||||
## assert-podman-stop-post-args "down"
|
||||
## assert-podman-stop-post-args "--force"
|
||||
## assert-podman-stop-post-final-args-regex .*/podman_test.*/quadlet/deployment.yml
|
||||
## assert-podman-stop-post-final-args-regex .*/podman-e2e-.*/subtest-.*/quadlet/deployment.yml
|
||||
|
||||
[Kube]
|
||||
Yaml=deployment.yml
|
||||
|
@ -1,7 +1,7 @@
|
||||
## assert-podman-final-args localhost/imagename
|
||||
## assert-podman-args --env-file /opt/env/abs-1
|
||||
## assert-podman-args --env-file /opt/env/abs-2
|
||||
## assert-podman-args-regex --env-file /.*/podman_test.*/quadlet/rel-1
|
||||
## assert-podman-args-regex --env-file /.*/podman-e2e-.*/subtest-.*/quadlet/rel-1
|
||||
## assert-podman-args --env-file %h/env
|
||||
|
||||
[Container]
|
||||
|
@ -18,11 +18,11 @@ Mount=type=tmpfs,tmpfs-size=512M,destination=/path/in/container
|
||||
Mount=type=image,source=fedora,destination=/fedora-image,rw=true
|
||||
## assert-podman-args-key-val "--mount" "," "type=devpts,destination=/dev/pts"
|
||||
Mount=type=devpts,destination=/dev/pts
|
||||
## assert-podman-args-key-val-regex "--mount" "," "type=bind,source=.*/podman_test.*/quadlet/path/on/host,destination=/path/in/container"
|
||||
## assert-podman-args-key-val-regex "--mount" "," "type=bind,source=.*/podman-e2e-.*/subtest-.*/quadlet/path/on/host,destination=/path/in/container"
|
||||
Mount=type=bind,source=./path/on/host,destination=/path/in/container
|
||||
## assert-podman-args-key-val "--mount" "," "type=volume,source=vol1,destination=/path/in/container,ro"
|
||||
Mount=type=volume,source=vol1,destination=/path/in/container,ro
|
||||
## assert-podman-args-key-val "--mount" "," "type=bind,source=/tmp,\"dst=/path,1\""
|
||||
Mount=type=bind,src=/tmp,\"dst=/path,1\"
|
||||
## assert-podman-args-key-val-regex "--mount" "," "type=bind,source=.*/podman_test.*/quadlet/src,destination=/dst/,idmap=uids=12-34-1;gids=56-78-1"
|
||||
## assert-podman-args-key-val-regex "--mount" "," "type=bind,source=.*/podman-e2e-.*/subtest-.*/quadlet/src,destination=/dst/,idmap=uids=12-34-1;gids=56-78-1"
|
||||
Mount=type=bind,source=./src/,destination=/dst/,idmap=uids=12-34-1;gids=56-78-1
|
||||
|
@ -1,11 +1,11 @@
|
||||
## assert-podman-args "kube"
|
||||
## assert-podman-args "play"
|
||||
## assert-podman-final-args-regex .*/podman_test.*/quadlet/deployment.yml
|
||||
## assert-podman-final-args-regex .*/podman-e2e-.*/subtest-.*/quadlet/deployment.yml
|
||||
## assert-podman-args "--replace"
|
||||
## assert-podman-args "--service-container=true"
|
||||
## assert-podman-stop-post-args "kube"
|
||||
## assert-podman-stop-post-args "down"
|
||||
## assert-podman-stop-post-final-args-regex .*/podman_test.*/quadlet/deployment.yml
|
||||
## assert-podman-stop-post-final-args-regex .*/podman-e2e-.*/subtest-.*/quadlet/deployment.yml
|
||||
## assert-key-is "Unit" "RequiresMountsFor" "%t/containers"
|
||||
## assert-key-is "Service" "KillMode" "mixed"
|
||||
## assert-key-is "Service" "Type" "oneshot"
|
||||
|
@ -1,6 +1,6 @@
|
||||
## assert-podman-args -v /host/dir:/container/volume
|
||||
## assert-podman-args -v /host/dir2:/container/volume2:Z
|
||||
## assert-podman-args-regex -v .*/podman_test.*/quadlet/host/dir3:/container/volume3
|
||||
## assert-podman-args-regex -v .*/podman-e2e-.*/subtest-.*/quadlet/host/dir3:/container/volume3
|
||||
## assert-podman-args -v named:/container/named
|
||||
## assert-podman-args -v systemd-quadlet:/container/quadlet
|
||||
## assert-podman-args -v %h/container:/container/volume4
|
||||
|
@ -1,6 +1,6 @@
|
||||
## assert-podman-pre-args -v /host/dir:/container/volume
|
||||
## assert-podman-pre-args -v /host/dir2:/container/volume2:Z
|
||||
## assert-podman-pre-args-regex -v .*/podman_test.*/quadlet/host/dir3:/container/volume3
|
||||
## assert-podman-pre-args-regex -v .*/podman-e2e-.*/subtest-.*/quadlet/host/dir3:/container/volume3
|
||||
## assert-podman-pre-args -v named:/container/named
|
||||
## assert-podman-pre-args -v systemd-quadlet:/container/quadlet
|
||||
## assert-podman-pre-args -v %h/container:/container/volume4
|
||||
|
@ -1,4 +1,4 @@
|
||||
## assert-key-is-regex "Service" "WorkingDirectory" ".*/podman_test.*/quadlet"
|
||||
## assert-key-is-regex "Service" "WorkingDirectory" ".*/podman-e2e-.*/subtest-.*/quadlet"
|
||||
|
||||
[Kube]
|
||||
Yaml=deployment.yml
|
||||
|
@ -1,4 +1,4 @@
|
||||
## assert-key-is-regex "Service" "WorkingDirectory" ".*/podman_test.*/quadlet/myservice"
|
||||
## assert-key-is-regex "Service" "WorkingDirectory" ".*/podman-e2e-.*/subtest-.*/quadlet/myservice"
|
||||
|
||||
[Kube]
|
||||
Yaml=./myservice/deployment.yml
|
||||
|
@ -695,12 +695,12 @@ BOGUS=foo
|
||||
"---basic.service---",
|
||||
"## assert-podman-args \"kube\"",
|
||||
"## assert-podman-args \"play\"",
|
||||
"## assert-podman-final-args-regex .*/podman_test.*/quadlet/deployment.yml",
|
||||
"## assert-podman-final-args-regex .*/podman-e2e-.*/subtest-.*/quadlet/deployment.yml",
|
||||
"## assert-podman-args \"--replace\"",
|
||||
"## assert-podman-args \"--service-container=true\"",
|
||||
"## assert-podman-stop-post-args \"kube\"",
|
||||
"## assert-podman-stop-post-args \"down\"",
|
||||
"## assert-podman-stop-post-final-args-regex .*/podman_test.*/quadlet/deployment.yml",
|
||||
"## assert-podman-stop-post-final-args-regex .*/podman-e2e-.*/subtest-.*/quadlet/deployment.yml",
|
||||
"## assert-key-is \"Unit\" \"RequiresMountsFor\" \"%t/containers\"",
|
||||
"## assert-key-is \"Service\" \"KillMode\" \"mixed\"",
|
||||
"## assert-key-is \"Service\" \"Type\" \"notify\"",
|
||||
|
@ -532,14 +532,6 @@ EXPOSE 2004-2005/tcp`, ALPINE)
|
||||
Expect(session.OutputToString()).To(Equal(sysctlValue))
|
||||
})
|
||||
|
||||
It("podman run network expose host port 18082 to container port 8000 using slirp4netns port handler", func() {
|
||||
session := podmanTest.Podman([]string{"run", "--network", "slirp4netns:port_handler=slirp4netns", "-dt", "-p", "18082:8000", ALPINE, "/bin/sh"})
|
||||
session.Wait(30)
|
||||
Expect(session).Should(ExitCleanly())
|
||||
ncBusy := SystemExec("nc", []string{"-l", "-p", "18082"})
|
||||
Expect(ncBusy).To(ExitWithError())
|
||||
})
|
||||
|
||||
It("podman run network expose host port 8080 to container port 8000 using invalid port handler", func() {
|
||||
session := podmanTest.Podman([]string{"run", "--network", "slirp4netns:port_handler=invalid", "-dt", "-p", "8080:8000", ALPINE, "/bin/sh"})
|
||||
session.Wait(30)
|
||||
|
@ -27,12 +27,6 @@ var _ = Describe("Common functions test", func() {
|
||||
ProcessOneCgroupPath = defaultCgroupPath
|
||||
})
|
||||
|
||||
It("Test CreateTempDirInTempDir", func() {
|
||||
tmpDir, _ := CreateTempDirInTempDir()
|
||||
_, err := os.Stat(tmpDir)
|
||||
Expect(os.IsNotExist(err)).ShouldNot(BeTrue(), "Directory is not created as expect")
|
||||
})
|
||||
|
||||
It("Test SystemExec", func() {
|
||||
session := SystemExec(GoechoPath, []string{})
|
||||
Expect(session.Command.Process).ShouldNot(BeNil(), "SystemExec cannot start a process")
|
||||
|
@ -376,11 +376,6 @@ func (s *PodmanSession) WaitWithTimeout(timeout int) {
|
||||
os.Stderr.Sync()
|
||||
}
|
||||
|
||||
// CreateTempDirInTempDir create a temp dir with prefix podman_test
|
||||
func CreateTempDirInTempDir() (string, error) {
|
||||
return os.MkdirTemp("", "podman_test")
|
||||
}
|
||||
|
||||
// SystemExec is used to exec a system command to check its exit code or output
|
||||
func SystemExec(command string, args []string) *PodmanSession {
|
||||
c := exec.Command(command, args...)
|
||||
|
Reference in New Issue
Block a user