diff options
author | umohnani8 <umohnani@redhat.com> | 2018-01-12 10:19:48 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-01-15 19:27:10 +0000 |
commit | 2bfb31ddf4b7f28a67ef94b8b318536c367a663b (patch) | |
tree | f76fca0eb6087cc4d5c3b65dc06b73113fe588d9 /test/podman_run_cpu.bats | |
parent | 7853262a84b1312e29a78708865a28bd41c4cc2f (diff) | |
download | podman-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/podman_run_cpu.bats')
-rw-r--r-- | test/podman_run_cpu.bats | 71 |
1 files changed, 71 insertions, 0 deletions
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 ] +} |