mirror of
https://github.com/systemd/systemd.git
synced 2025-02-28 05:57:33 +03:00
test: configure swap for TEST-55-OOMD
oomd works way better with swap, so let's make the test less flaky by configuring a swap device for it. This also allows us to drop the ugly `cat`s from the load-generating script.
This commit is contained in:
parent
3a1e9d8083
commit
6f47e45c67
@ -2,10 +2,23 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
TEST_DESCRIPTION="systemd-oomd Memory Pressure Test"
|
TEST_DESCRIPTION="systemd-oomd Memory Pressure Test"
|
||||||
|
IMAGE_NAME="oomd"
|
||||||
|
|
||||||
# shellcheck source=test/test-functions
|
# shellcheck source=test/test-functions
|
||||||
. "${TEST_BASE_DIR:?}/test-functions"
|
. "${TEST_BASE_DIR:?}/test-functions"
|
||||||
|
|
||||||
|
test_append_files() {
|
||||||
|
# Create a swap device
|
||||||
|
(
|
||||||
|
mkswap "${LOOPDEV:?}p2"
|
||||||
|
dracut_install swapon swapoff
|
||||||
|
|
||||||
|
cat >>"${initdir:?}/etc/fstab" <<EOF
|
||||||
|
UUID=$(blkid -o value -s UUID "${LOOPDEV}p2") none swap defaults 0 0
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
check_result_nspawn() {
|
check_result_nspawn() {
|
||||||
local workspace="${1:?}"
|
local workspace="${1:?}"
|
||||||
local ret=1
|
local ret=1
|
||||||
|
@ -12,9 +12,7 @@ PID="$$"
|
|||||||
function bloat {
|
function bloat {
|
||||||
local set_size mem_usage target_mem_size
|
local set_size mem_usage target_mem_size
|
||||||
|
|
||||||
# Following `| cat` weirdness is intentional to generate some reclaim
|
set_size=$(cut -d " " -f2 "/proc/$PID/statm")
|
||||||
# activity in case there's no swap available.
|
|
||||||
set_size=$(cut -d " " -f2 "/proc/$PID/statm" | cat)
|
|
||||||
mem_usage=$((set_size * PAGE_SIZE))
|
mem_usage=$((set_size * PAGE_SIZE))
|
||||||
target_mem_size=$((mem_usage + $1))
|
target_mem_size=$((mem_usage + $1))
|
||||||
|
|
||||||
@ -23,7 +21,7 @@ function bloat {
|
|||||||
echo "target $target_mem_size"
|
echo "target $target_mem_size"
|
||||||
echo "mem usage $mem_usage"
|
echo "mem usage $mem_usage"
|
||||||
BLOAT_HOLDER+=("$(printf "=%0.s" {1..1000000})")
|
BLOAT_HOLDER+=("$(printf "=%0.s" {1..1000000})")
|
||||||
set_size=$(cut -d " " -f2 "/proc/$PID/statm" | cat)
|
set_size=$(cut -d " " -f2 "/proc/$PID/statm")
|
||||||
mem_usage=$((set_size * PAGE_SIZE))
|
mem_usage=$((set_size * PAGE_SIZE))
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user