Skip to content

Commit

Permalink
integration test for PSI metrics in runc events
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Dao <dqminh89@gmail.com>
  • Loading branch information
dqminh committed Feb 3, 2022
1 parent 53f2c48 commit 5699010
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/integration/events.bats
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,31 @@ function teardown() {
[[ "${lines[0]}" == *"data"* ]]
}

@test "events --stats with psi data" {
requires root cgroups_v2 psi
init_cgroup_paths

update_config '.linux.resources.cpu |= { "quota": 1000 }'

runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
[ "$status" -eq 0 ]

# stress the cpu a little bit
runc exec test_busybox dd if=/dev/zero bs=1M count=5 of=/dev/null
[ "$status" -eq 0 ]

runc events --stats test_busybox
[ "$status" -eq 0 ]
# fetch stats to see PSI metrics
for psi_type in some full; do
for psi_metric in avg10 avg60 avg300 total; do
[[ "$(echo "${lines[0]}" | jq .data.cpu.psi.$psi_type.$psi_metric)" != "" ]]
done
done
# total must have been more than 0
[[ "$(echo "${lines[0]}" | jq .data.cpu.psi.some.total)" != "0" ]]
}

function test_events() {
# XXX: currently cgroups require root containers.
requires root
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,13 @@ function requires() {
skip_me=1
fi
;;
psi)
# If PSI is not compiled in the kernel, the file will not exist.
# If PIS is compiled, but not enable, read will fail with ENOSUPP
if [[ ! $(cat /sys/fs/cgroup/cpu.pressure) ]]; then
skip_me=1
fi
;;
*)
fail "BUG: Invalid requires $var."
;;
Expand Down

0 comments on commit 5699010

Please sign in to comment.