diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/podman_run.bats | 19 | ||||
-rw-r--r-- | test/podman_run_cpu.bats | 71 | ||||
-rw-r--r-- | test/podman_run_memory.bats | 39 |
3 files changed, 129 insertions, 0 deletions
diff --git a/test/podman_run.bats b/test/podman_run.bats index 7066000d0..465468a5c 100644 --- a/test/podman_run.bats +++ b/test/podman_run.bats @@ -110,6 +110,11 @@ IMAGE="docker.io/library/fedora:latest" [ "$status" -eq 0 ] [ "$output" = 2048 ] + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --ulimit nofile=1024:1028 ${IMAGE} ulimit -n | tr -d '\r'" + echo $output + [ "$status" -eq 0 ] + [ "$output" = 1024 ] + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --oom-kill-disable=true ${IMAGE} echo memory-hog" echo $output [ "$status" -eq 0 ] @@ -141,3 +146,17 @@ IMAGE="docker.io/library/fedora:latest" echo "$output" [ "$status" -eq 0 ] } + +@test "podman run sysctl test" { + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --sysctl net.core.somaxconn=65535 ${ALPINE} sysctl net.core.somaxconn | tr -d '\r'" + echo "$output" + [ "$status" -eq 0 ] + [ "$output" = "net.core.somaxconn = 65535" ] +} + +@test "podman run blkio-weight test" { + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --blkio-weight=15 ${ALPINE} cat /sys/fs/cgroup/blkio/blkio.weight | tr -d '\r'" + echo "$output" + [ "$status" -eq 0 ] + [ "$output" = 15 ] +} diff --git a/test/podman_run_cpu.bats b/test/podman_run_cpu.bats new file mode 100644 index 000000000..ebd411b41 --- /dev/null +++ b/test/podman_run_cpu.bats @@ -0,0 +1,71 @@ +#!/usr/bin/env bats + +load helpers + +function teardown() { + cleanup_test +} + +function setup() { + copy_images +} + +@test "run cpu-period test" { + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --cpu-period=5000 ${ALPINE} cat /sys/fs/cgroup/cpu/cpu.cfs_period_us | tr -d '\r'" + echo $output + [ "$status" -eq 0 ] + [ "$output" = 5000 ] +} + +@test "run cpu-quota test" { + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --cpu-quota=5000 ${ALPINE} cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us | tr -d '\r'" + echo "$output" + [ "$status" -eq 0 ] + [ "$output" = 5000 ] +} + +@test "run cpus test" { + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --cpus=0.5 ${ALPINE} cat /sys/fs/cgroup/cpu/cpu.cfs_period_us | tr -d '\r'" + echo "$output" + [ "$status" -eq 0 ] + [ "$output" = 100000 ] + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --cpus=0.5 ${ALPINE} cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us | tr -d '\r'" + echo "$output" + [ "$status" -eq 0 ] + [ "$output" = 50000 ] +} + +@test "run cpu-shares test" { + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --cpu-shares=2 ${ALPINE} cat /sys/fs/cgroup/cpu/cpu.shares | tr -d '\r'" + echo "$output" + [ "$status" -eq 0 ] + [ "$output" = 2 ] +} + +@test "run cpuset-cpus test" { + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --cpuset-cpus=0 ${ALPINE} cat /sys/fs/cgroup/cpuset/cpuset.cpus | tr -d '\r'" + echo "$output" + [ "$status" -eq 0 ] + [ "$output" = 0 ] +} + +@test "run cpuset-mems test" { + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --cpuset-mems=0 ${ALPINE} cat /sys/fs/cgroup/cpuset/cpuset.mems | tr -d '\r'" + echo "$output" + [ "$status" -eq 0 ] + [ "$output" = 0 ] +} + +@test "run failure if cpus and cpu-period set together test" { + # skip, error code incorrect with bash -c and will fail centos test without bash -c + run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --cpu-period=5000 --cpus=0.5 ${ALPINE} /bin/bash + echo "$output" + [ "$status" -ne 0 ] +} + +@test "run failure if cpus and cpu-quota set together test" { + # skip, error code incorrect with bash -c and will fail centos test without bash -c + run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --cpu-quota=5000 --cpus=0.5 ${ALPINE} /bin/bash + echo "$output" + [ "$status" -ne 0 ] +} diff --git a/test/podman_run_memory.bats b/test/podman_run_memory.bats new file mode 100644 index 000000000..2eaebe104 --- /dev/null +++ b/test/podman_run_memory.bats @@ -0,0 +1,39 @@ +#!/usr/bin/env bats + +load helpers + +function teardown() { + cleanup_test +} + +function setup() { + copy_images +} + +@test "run memory test" { + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --memory=40m ${ALPINE} cat /sys/fs/cgroup/memory/memory.limit_in_bytes | tr -d '\r'" + echo $output + [ "$status" -eq 0 ] + [ "$output" = 41943040 ] +} + +@test "run memory-reservation test" { + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --memory-reservation=40m ${ALPINE} cat /sys/fs/cgroup/memory/memory.soft_limit_in_bytes | tr -d '\r'" + echo "$output" + [ "$status" -eq 0 ] + [ "$output" = 41943040 ] +} + +@test "run memory-swappiness test" { + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --memory-swappiness=15 ${ALPINE} cat /sys/fs/cgroup/memory/memory.swappiness | tr -d '\r'" + echo "$output" + [ "$status" -eq 0 ] + [ "$output" = 15 ] +} + +@test "run kernel-memory test" { + run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} run --rm --kernel-memory=40m ${ALPINE} cat /sys/fs/cgroup/memory/memory.kmem.limit_in_bytes | tr -d '\r'" + echo "$output" + [ "$status" -eq 0 ] + [ "$output" = 41943040 ] +} |