Files
.github
cmd
cni
completions
contrib
dependencies
docs
hack
libpod
logo
nix
pkg
test
apiv2
build
buildah-bud
certs
checkseccomp
compose
e2e
build
cdi
config
hooks
sign
testdata
attach_test.go
build_test.go
checkpoint_test.go
commit_test.go
common_test.go
config.go
config_amd64.go
config_ppc64le.go
container_clone_test.go
container_create_volume_test.go
container_inspect_test.go
containers_conf_test.go
cp_test.go
create_staticip_test.go
create_staticmac_test.go
create_test.go
diff_test.go
events_test.go
exec_test.go
exists_test.go
export_test.go
generate_kube_test.go
generate_systemd_test.go
healthcheck_run_test.go
history_test.go
image_scp_test.go
image_sign_test.go
images_test.go
import_test.go
info_test.go
init_test.go
inspect_test.go
kill_test.go
libpod_suite_remote_test.go
libpod_suite_test.go
load_test.go
login_logout_test.go
logs_test.go
manifest_test.go
mount_rootless_test.go
mount_test.go
namespace_test.go
negative_test.go
network_connect_disconnect_test.go
network_create_test.go
network_test.go
pause_test.go
play_build_test.go
play_kube_test.go
pod_create_test.go
pod_infra_container_test.go
pod_initcontainers_test.go
pod_inspect_test.go
pod_kill_test.go
pod_pause_test.go
pod_pod_namespaces_test.go
pod_prune_test.go
pod_ps_test.go
pod_restart_test.go
pod_rm_test.go
pod_start_test.go
pod_stats_test.go
pod_stop_test.go
pod_top_test.go
port_test.go
prune_test.go
ps_test.go
pull_test.go
push_test.go
rename_test.go
restart_test.go
rm_test.go
rmi_test.go
run_apparmor_test.go
run_cgroup_parent_test.go
run_cleanup_test.go
run_cpu_test.go
run_device_test.go
run_dns_test.go
run_entrypoint_test.go
run_env_test.go
run_exit_test.go
run_memory_test.go
run_networking_test.go
run_ns_test.go
run_passwd_test.go
run_privileged_test.go
run_restart_test.go
run_seccomp_test.go
run_security_labels_test.go
run_selinux_test.go
run_signal_test.go
run_staticip_test.go
run_test.go
run_userns_test.go
run_volume_test.go
run_working_dir_test.go
runlabel_test.go
save_test.go
search_test.go
secret_test.go
start_test.go
stats_test.go
stop_test.go
system_connection_test.go
system_df_test.go
system_dial_stdio_test.go
system_reset_test.go
system_service_test.go
systemd_test.go
tag_test.go
toolbox_test.go
top_test.go
tree_test.go
trust_test.go
unshare_test.go
untag_test.go
version_test.go
volume_create_test.go
volume_exists_test.go
volume_inspect_test.go
volume_ls_test.go
volume_plugin_test.go
volume_prune_test.go
volume_rm_test.go
wait_test.go
framework
goecho
install
python
system
testvol
upgrade
utils
version
README.md
policy.json
redhat_sigstore.yaml
registries.conf
test_podman_baseline.sh
test_podman_build.sh
test_podman_pods.sh
utils
vendor
version
.cirrus.yml
.dockerignore
.gitignore
.golangci.yml
.pre-commit-config.yaml
.ubuntu_prepare.sh
CODE-OF-CONDUCT.md
CONTRIBUTING.md
Containerfile-testvol
LICENSE
Makefile
OWNERS
README.md
RELEASE_NOTES.md
RELEASE_PROCESS.md
SECURITY.md
Vagrantfile
build_osx.md
commands-demo.md
commands.md
docker
go.mod
go.sum
install.md
podman.spec.rpkg
rootless.md
transfer.md
troubleshooting.md
podman/test/e2e/run_memory_test.go
Valentin Rothberg bd09b7aa79 bump go module to version 4
Automated for .go files via gomove [1]:
`gomove github.com/containers/podman/v3 github.com/containers/podman/v4`

Remaining files via vgrep [2]:
`vgrep github.com/containers/podman/v3`

[1] https://github.com/KSubedi/gomove
[2] https://github.com/vrothberg/vgrep

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2022-01-18 12:47:07 +01:00

82 lines
2.5 KiB
Go

package integration
import (
"fmt"
"os"
. "github.com/containers/podman/v4/test/utils"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
var _ = Describe("Podman run memory", func() {
var (
tempdir string
err error
podmanTest *PodmanTestIntegration
)
BeforeEach(func() {
SkipIfRootlessCgroupsV1("Setting Memory not supported on cgroupv1 for rootless users")
tempdir, err = CreateTempDirInTempDir()
if err != nil {
os.Exit(1)
}
podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup()
podmanTest.SeedImages()
})
AfterEach(func() {
podmanTest.Cleanup()
f := CurrentGinkgoTestDescription()
processTestResult(f)
})
It("podman run memory test", func() {
var session *PodmanSessionIntegration
if CGROUPSV2 {
session = podmanTest.Podman([]string{"run", "--memory=40m", "--net=none", ALPINE, "sh", "-c", "cat /sys/fs/cgroup/$(sed -e 's|0::||' < /proc/self/cgroup)/memory.max"})
} else {
session = podmanTest.Podman([]string{"run", "--memory=40m", ALPINE, "cat", "/sys/fs/cgroup/memory/memory.limit_in_bytes"})
}
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(Equal("41943040"))
})
It("podman run memory-reservation test", func() {
if podmanTest.Host.Distribution == "ubuntu" {
Skip("Unable to perform test on Ubuntu distributions due to memory management")
}
var session *PodmanSessionIntegration
if CGROUPSV2 {
session = podmanTest.Podman([]string{"run", "--memory-reservation=40m", "--net=none", ALPINE, "sh", "-c", "cat /sys/fs/cgroup/$(sed -e 's|0::||' < /proc/self/cgroup)/memory.low"})
} else {
session = podmanTest.Podman([]string{"run", "--memory-reservation=40m", ALPINE, "cat", "/sys/fs/cgroup/memory/memory.soft_limit_in_bytes"})
}
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(Equal("41943040"))
})
for _, limit := range []string{"0", "15", "100"} {
limit := limit // Keep this value in a proper scope
testName := fmt.Sprintf("podman run memory-swappiness test(%s)", limit)
It(testName, func() {
SkipIfCgroupV2("memory-swappiness not supported on cgroupV2")
session := podmanTest.Podman([]string{"run", fmt.Sprintf("--memory-swappiness=%s", limit), ALPINE, "cat", "/sys/fs/cgroup/memory/memory.swappiness"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(Equal(limit))
})
}
})