Skip to content

Commit

Permalink
tests/remote_usage: Add integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
  • Loading branch information
gabrielmougard committed Apr 11, 2024
1 parent 1fc380f commit 35f93bb
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/suites/remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,36 @@ 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.
fingerprint=$(lxc_remote image info lxd2:bar | awk '/Fingerprint/ { print $2 }')
lxc_remote image delete lxd2:bar
lxc_remote init localhost:testimage lxd2:c1
cached=$(lxc_remote image info "lxd2:${fingerprint}" | 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:${fingerprint}" | 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
Expand Down

0 comments on commit 35f93bb

Please sign in to comment.