diff --git a/test/main.sh b/test/main.sh index 37e88a823b7..decad43790b 100755 --- a/test/main.sh +++ b/test/main.sh @@ -296,6 +296,7 @@ if [ "${1:-"all"}" != "cluster" ]; then run_test test_image_auto_update "image auto-update" run_test test_image_prefer_cached "image prefer cached" run_test test_image_import_dir "import image from directory" + run_test test_image_import_with_reuse "import image with reuse flag" run_test test_image_refresh "image refresh" run_test test_image_acl "image acl" run_test test_cloud_init "cloud-init" diff --git a/test/suites/image.sh b/test/suites/image.sh index 02c8ac2811b..76fcb7e6884 100644 --- a/test/suites/image.sh +++ b/test/suites/image.sh @@ -122,6 +122,23 @@ test_image_import_existing_alias() { incus image delete newimage image2 } +test_image_import_with_reuse() { + ensure_import_testimage + incus init testimage c + testimage_fingerprint="$(incus image ls -c F -f csv testimage)" + image1_fingerprint="$(incus publish c --alias image1 | awk '{print $NF;}')" + incus delete c + incus image export image1 image1.file + incus image delete image1 + + incus image import image1.file.tar.gz --alias testimage --reuse + + [ "$(incus image ls -c F -f csv testimage)" = "${image1_fingerprint}" ] + [ "$(incus image ls -c F -f csv "${testimage_fingerprint}" | wc -l)" = "0" ] + + incus image delete testimage +} + test_image_refresh() { # shellcheck disable=2039,3043 local INCUS2_DIR INCUS2_ADDR