diff options
author | Ivan Kruglov <mail@ikruglov.com> | 2024-11-07 11:09:14 +0100 |
---|---|---|
committer | Ivan Kruglov <mail@ikruglov.com> | 2024-12-17 11:25:24 +0100 |
commit | 1fc1a32941d175edf34cfdc78a9a7a771d736f74 (patch) | |
tree | cf74fcecb8462f5d1d4d336b08c2632910d06c6b | |
parent | machine: introduce io.systemd.Machine.{MapFrom, MapTo} methods (diff) | |
download | systemd-1fc1a32941d175edf34cfdc78a9a7a771d736f74.tar.xz systemd-1fc1a32941d175edf34cfdc78a9a7a771d736f74.zip |
machine: tests for io.systemd.Machine.{MapFrom, MapTo} methods
-rwxr-xr-x | test/units/TEST-13-NSPAWN.machined.sh | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/test/units/TEST-13-NSPAWN.machined.sh b/test/units/TEST-13-NSPAWN.machined.sh index 59ba8c92db..85eb89b14d 100755 --- a/test/units/TEST-13-NSPAWN.machined.sh +++ b/test/units/TEST-13-NSPAWN.machined.sh @@ -357,12 +357,7 @@ 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 30 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 call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{"name": ".host"}' | grep 'addresses') @@ -386,11 +381,26 @@ varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.Open varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.Open '{"name": ".host", "mode": "login"}' varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.Open '{"name": ".host", "mode": "shell"}' +# test io.systemd.Machine.MapFrom +varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.MapFrom '{"name": "long-running", "uid":0, "gid": 0}' +container_uid=$(varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.MapFrom '{"name": "long-running", "uid":0}' | jq '.uid') +container_gid=$(varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.MapFrom '{"name": "long-running", "gid":0}' | jq '.gid') +# test io.systemd.Machine.MapTo +varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.MapTo "{\"uid\": $container_uid, \"gid\": $container_gid}" | grep "long-running" +(! varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.MapTo '{"uid": 0}') +(! varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.MapTo '{"gid": 0}') + rm -f /tmp/none-existent-file varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.Open '{"name": ".host", "mode": "shell", "user": "root", "path": "/bin/sh", "args": ["/bin/sh", "-c", "echo $FOO > /tmp/none-existent-file"], "environment": ["FOO=BAR"]}' timeout 30 bash -c "until test -e /tmp/none-existent-file; do sleep .5; done" grep -q "BAR" /tmp/none-existent-file +# terminate machines +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 || : + # test io.systemd.MachineImage.List varlinkctl --more call /run/systemd/machine/io.systemd.MachineImage io.systemd.MachineImage.List '{}' | grep 'long-running' varlinkctl --more call /run/systemd/machine/io.systemd.MachineImage io.systemd.MachineImage.List '{}' | grep '.host' |