diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2025-01-06 23:16:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-06 23:16:33 +0100 |
commit | 2144b5dccf51a96e3aadbeceae859915a95a81b2 (patch) | |
tree | 1cd57f290d0d810a6de78f368706e57e000acded /test | |
parent | core: fix assert when AddDependencyUnitFiles is called with invalid parameter (diff) | |
parent | machine: move io.systemd.Machine.Map* tests into right position (diff) | |
download | systemd-2144b5dccf51a96e3aadbeceae859915a95a81b2.tar.xz systemd-2144b5dccf51a96e3aadbeceae859915a95a81b2.zip |
machine: introduce io.systemd.Machine.{CopyFrom, CopyTo} methods (#34913)
This PR introduces io.systemd.Machine.CopyFrom and CopyTo method which
are DBus alternatives of:
- CopyFromMachine
- CopyToMachine
- CopyFromMachineWithFlags
- CopyToMachineWithFlags
The PR also contain tests
Diffstat (limited to 'test')
-rwxr-xr-x | test/units/TEST-13-NSPAWN.machined.sh | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/test/units/TEST-13-NSPAWN.machined.sh b/test/units/TEST-13-NSPAWN.machined.sh index 11f6a6f483..f3d59722ea 100755 --- a/test/units/TEST-13-NSPAWN.machined.sh +++ b/test/units/TEST-13-NSPAWN.machined.sh @@ -259,7 +259,7 @@ done #################### # varlinkctl tests # -# ################## +#################### long_running_machine_start @@ -387,6 +387,11 @@ 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"}' +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 + # 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') @@ -396,14 +401,28 @@ varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.MapTo (! 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 - # io.systemd.Machine.BindMount is covered by testcase_check_machinectl_bind() in nspawn tests -# terminate machines +# test io.systemd.Machine.CopyTo +rm -f /tmp/foo /var/lib/machines/long-running/root/foo +cp /etc/machine-id /tmp/foo +varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.CopyTo '{"name": "long-running", "source": "/tmp/foo", "destination": "/root/foo"}' +diff /tmp/foo /var/lib/machines/long-running/root/foo +(! varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.CopyTo '{"name": "long-running", "source": "/tmp/foo", "destination": "/root/foo"}') # FileExists +varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.CopyTo '{"name": "long-running", "source": "/tmp/foo", "destination": "/root/foo", "replace": true}' + +echo "sample-test-output" > /tmp/foo +varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.CopyTo '{"name": "long-running", "source": "/tmp/foo", "destination": "/root/foo", "replace": true}' +diff /tmp/foo /var/lib/machines/long-running/root/foo +rm -f /tmp/foo /var/lib/machines/long-running/root/foo + +# test io.systemd.Machine.CopyFrom +cp /etc/machine-id /var/lib/machines/long-running/foo +varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.CopyFrom '{"name": "long-running", "source": "/foo"}' +diff /var/lib/machines/long-running/foo /foo +rm -f /var/lib/machines/long-running/root/foo /foo + +# Terminating machine, otherwise acquiring image metadata by io.systemd.MachineImage.List may fail in the below. 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" |