summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorumohnani8 <umohnani@redhat.com>2018-01-12 10:19:48 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-01-15 19:27:10 +0000
commit2bfb31ddf4b7f28a67ef94b8b318536c367a663b (patch)
treef76fca0eb6087cc4d5c3b65dc06b73113fe588d9 /test
parent7853262a84b1312e29a78708865a28bd41c4cc2f (diff)
downloadpodman-2bfb31ddf4b7f28a67ef94b8b318536c367a663b.tar.gz
podman-2bfb31ddf4b7f28a67ef94b8b318536c367a663b.tar.bz2
podman-2bfb31ddf4b7f28a67ef94b8b318536c367a663b.zip
Implement and test the following flags for podman run and create
memory, memory-reservation, memory-swap, memory-swappiness, kernel-memory, cpu-period, cou-quota, cpu-shares, cpus, cpuset-cpus, cpuset-mems, blkio-weight, blkio-weight-device, sysctl, and ulimit Signed-off-by: umohnani8 <umohnani@redhat.com> Closes: #221 Approved by: mheon
Diffstat (limited to 'test')
-rw-r--r--test/podman_run.bats19
-rw-r--r--test/podman_run_cpu.bats71
-rw-r--r--test/podman_run_memory.bats39
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 ]
+}