TEST-04-JOURNAL: Make LogFilterPatterns= tests more robust

Let's use oneshot services as we don't need long running services
for the tests we're doing. Let's also increase the sleeps a little
as the current values weren't sufficient when running the test locally
on my machine with mkosi.
This commit is contained in:
Daan De Meyer
2024-04-28 22:52:59 +02:00
parent 191a31fbcf
commit b81ece59c4
5 changed files with 13 additions and 22 deletions

View File

@@ -2,7 +2,7 @@
Description=Test service for delegated logs filtering
[Service]
Type=simple
Type=oneshot
ExecStart=/usr/lib/systemd/tests/testdata/units/delegated_cgroup_filtering_payload.sh
Delegate=yes
SyslogLevel=notice

View File

@@ -2,5 +2,6 @@
Description=Log filtering unit
[Service]
ExecStart=sh -c 'while true; do echo "Logging from the service, and ~more~ foo bar"; sleep .25; done'
Type=oneshot
ExecStart=sh -c 'echo "Logging from the service, and ~more~ foo bar" && sleep 2'
SyslogLevel=notice

View File

@@ -2,11 +2,8 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
mkdir /sys/fs/cgroup/system.slice/delegated-cgroup-filtering.service/the_child
/bin/sh /usr/lib/systemd/tests/testdata/units/delegated_cgroup_filtering_payload_child.sh &
/bin/sh /usr/lib/systemd/tests/testdata/units/delegated_cgroup_filtering_payload_child.sh
while true
do
echo "parent_process: hello, world!"
echo "parent_process: hello, people!"
sleep .15
done
echo "parent_process: hello, world!"
echo "parent_process: hello, people!"
sleep .15

View File

@@ -3,9 +3,6 @@
echo $$ >/sys/fs/cgroup/system.slice/delegated-cgroup-filtering.service/the_child/cgroup.procs
while true
do
echo "child_process: hello, world!"
echo "child_process: hello, people!"
sleep .15
done
echo "child_process: hello, world!"
echo "child_process: hello, people!"
sleep .15

View File

@@ -18,16 +18,12 @@ add_logs_filtering_override() {
run_service_and_fetch_logs() {
local unit="${1:?}"
local start end
local start
start="$(date '+%Y-%m-%d %T.%6N')"
systemctl restart "$unit"
sleep .5
systemctl start "$unit"
journalctl --sync
end="$(date '+%Y-%m-%d %T.%6N')"
journalctl -q -u "$unit" -S "$start" -U "$end" -p notice
systemctl stop "$unit"
journalctl -q -u "$unit" -S "$start" -p notice
}
if cgroupfs_supports_user_xattrs; then