From: Yu Watanabe Date: Thu, 31 Oct 2024 02:02:23 +0000 (+0900) Subject: TEST-13-NSPAWN: add test cases for listing multiple machines X-Git-Tag: v257-rc1~74^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1e11a252ddd6b826e17e630e4c8f2f42ef7773d;p=thirdparty%2Fsystemd.git TEST-13-NSPAWN: add test cases for listing multiple machines --- diff --git a/test/units/TEST-13-NSPAWN.machined.sh b/test/units/TEST-13-NSPAWN.machined.sh index b259a5bc16c..9a6e86cefbd 100755 --- a/test/units/TEST-13-NSPAWN.machined.sh +++ b/test/units/TEST-13-NSPAWN.machined.sh @@ -341,7 +341,23 @@ assert_eq "$(echo "$output" | jq --seq .addresses[0].address[0] | tr -d \\036)" assert_eq "$(echo "$output" | jq --seq .addresses[0].address[1] | tr -d \\036)" '0' assert_eq "$(echo "$output" | jq --seq .addresses[0].address[2] | tr -d \\036)" '2' assert_eq "$(echo "$output" | jq --seq .addresses[0].address[3] | tr -d \\036)" '1' -machinectl terminate "container-without-os-release" +# test for listing multiple machines. +long_running_machine_start +varlinkctl --more call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{}' +varlinkctl --more call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{"acquireMetadata": "no"}' +varlinkctl --more call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{"acquireMetadata": "graceful"}' +# check if machined does not try to send anything after error message +journalctl --sync +TS="$(date '+%H:%M:%S')" +(! varlinkctl --more call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{"acquireMetadata": "yes"}') +journalctl --sync +(! journalctl -u systemd-machined.service --since="$TS" --grep 'Connection busy') +# terminate machines +machinectl terminate container-without-os-release +machinectl terminate long-running +# wait for the container being stopped, otherwise acquiring image metadata by io.systemd.MachineImage.List may fail in the below. +timeout 10 bash -c "while machinectl status long-running &>/dev/null; do sleep .5; done" +systemctl kill --signal=KILL systemd-nspawn@long-running.service || : (ip addr show lo | grep -q 192.168.1.100) || ip address add 192.168.1.100/24 dev lo (! varlinkctl --more call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{"name": ".host"}' | grep 'addresses')