From 3330c367dbcc4eeeec70f088f17d0705c36aab99 Mon Sep 17 00:00:00 2001 From: Gabriel Mougard Date: Wed, 10 Apr 2024 10:56:19 +0200 Subject: [PATCH] tests/remote_usage: Add integration tests Signed-off-by: Gabriel Mougard --- test/suites/remote.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/suites/remote.sh b/test/suites/remote.sh index 4075bb62a21f..6cc69055a311 100644 --- a/test/suites/remote.sh +++ b/test/suites/remote.sh @@ -339,6 +339,35 @@ test_remote_usage() { lxc_remote image delete "lxd2:${sum}" lxc_remote profile delete lxd2:foo + lxc_remote image copy localhost:testimage lxd2: --alias bar + # Get the `cached` and `aliases` fields for the image `bar` in lxd2 + cached=$(lxc_remote image info lxd2:bar | awk '/Cached/ { print $2 }') + alias=$(lxc_remote image info lxd2:bar | grep -A 1 "Aliases:" | tail -n1 | awk '{print $2}') + + # Check that image is not cached + [ "${cached}" = "no" ] + # Check that the alias is correct + [ "${alias}" = "bar" ] + + # Now, lets delete the image and observe that when its downloaded implicitly as part of an instance create, + # the image becomes `cached` and has no alias. + lxc_remote image delete lxd2:bar + lxc_remote init localhost:testimage lxd2:c1 + cached=$(lxc_remote image info lxd2:testimage | awk '/Cached/ { print $2 }') + # The `cached` field should be set to `yes` since the image was implicitly downloaded by the instance create operation + [ "${cached}" = "yes" ] + # There should be no alias for the image + ! lxc_remote image info lxd2:testimage | grep -q "Aliases:" + + # Finally, lets copy the remote image explicitly to the local server with an alias like we did before + lxc_remote image copy localhost:testimage lxd2: --alias bar + cached=$(lxc_remote image info lxd2:bar | awk '/Cached/ { print $2 }') + alias=$(lxc_remote image info lxd2:bar | grep -A 1 "Aliases:" | tail -n1 | awk '{print $2}') + # The `cached` field should be set to `no` since the image was explicitly copied. + [ "${cached}" = "no" ] + # The alias should be set to `bar`. + [ "${alias}" = "bar" ] + lxc_remote image alias delete localhost:foo lxc_remote remote remove lxd2