Skip to content

Commit

Permalink
test: Use new incus snapshot commands
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Hipp <[email protected]>
  • Loading branch information
monstermunchkin committed Aug 18, 2023
1 parent 58f9921 commit d1481cd
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 88 deletions.
30 changes: 15 additions & 15 deletions test/suites/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ EOF
echo "hello world" | incus exec c1 --project test -- tee /mnt/test.txt
incus exec c1 --project test -- grep -xF "hello world" /mnt/test.txt
incus stop -f c1
incus snapshot c1
incus snapshot create c1
incus info c1

incus storage volume snapshot "${poolName}" vol1_test snap0
Expand Down Expand Up @@ -190,7 +190,7 @@ EOF
incus exec c1 --project test -- grep -xF "hello world" /mnt/test.txt

# Check snashot can be restored.
incus restore c1 snap0
incus snapshot restore c1 snap0
incus info c1
incus exec c1 --project test -- hostname

Expand All @@ -210,7 +210,7 @@ EOF

incus info c1 | grep snap0
incus exec c1 --project test -- hostname
incus restore c1 snap0
incus snapshot restore c1 snap0
incus info c1
incus exec c1 --project test -- hostname

Expand Down Expand Up @@ -265,7 +265,7 @@ EOF

incus info c1 | grep snap0
incus exec c1 --project test -- ls
incus restore c1 snap0
incus snapshot restore c1 snap0
incus info c1
incus exec c1 --project test -- ls
incus delete -f c1
Expand Down Expand Up @@ -366,7 +366,7 @@ test_backup_import_with_project() {

incus launch testimage c1
incus launch testimage c2
incus snapshot c2
incus snapshot create c2

incus_backend=$(storage_backend "$INCUS_DIR")

Expand Down Expand Up @@ -421,14 +421,14 @@ test_backup_import_with_project() {
incus start c3 --project "$project-b"
incus stop c2 --project "$project-b" --force
incus stop c3 --project "$project-b" --force
incus restore c2 snap0 --project "$project-b"
incus restore c3 snap0 --project "$project-b"
incus snapshot restore c2 snap0 --project "$project-b"
incus snapshot restore c3 snap0 --project "$project-b"
incus delete --force c2 --project "$project-b"
incus delete --force c3 --project "$project-b"
fi

incus restore c2 snap0
incus restore c3 snap0
incus snapshot restore c2 snap0
incus snapshot restore c3 snap0
incus start c2
incus start c3
incus delete --force c2
Expand All @@ -444,8 +444,8 @@ test_backup_import_with_project() {
incus start c3
incus stop c2 --force
incus stop c3 --force
incus restore c2 snap0
incus restore c3 snap0
incus snapshot restore c2 snap0
incus snapshot restore c3 snap0
incus start c2
incus start c3
incus delete --force c2
Expand All @@ -458,9 +458,9 @@ test_backup_import_with_project() {

incus launch testimage c1-foo
incus storage volume set "${default_pool}" container/c1-foo user.foo=c1-foo-snap0
incus snapshot c1-foo c1-foo-snap0
incus snapshot create c1-foo c1-foo-snap0
incus storage volume set "${default_pool}" container/c1-foo user.foo=c1-foo-snap1
incus snapshot c1-foo c1-foo-snap1
incus snapshot create c1-foo c1-foo-snap1
incus storage volume set "${default_pool}" container/c1-foo user.foo=post-c1-foo-snap1

incus export c1-foo "${INCUS_DIR}/c1-foo.tar.gz"
Expand Down Expand Up @@ -543,7 +543,7 @@ test_backup_export_with_project() {
ensure_has_localhost_remote "${INCUS_ADDR}"

incus launch testimage c1
incus snapshot c1
incus snapshot create c1

mkdir "${INCUS_DIR}/optimized" "${INCUS_DIR}/non-optimized"
incus_backend=$(storage_backend "$INCUS_DIR")
Expand Down Expand Up @@ -593,7 +593,7 @@ test_backup_export_with_project() {

# Check if hyphens cause issues when creating backups
incus launch testimage c1-foo
incus snapshot c1-foo
incus snapshot create c1-foo

incus export c1-foo "${INCUS_DIR}/c1-foo.tar.gz"

Expand Down
2 changes: 1 addition & 1 deletion test/suites/basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ test_basic_usage() {
! incus init testimage aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || false

# Test snapshot publish
incus snapshot bar
incus snapshot create bar
incus publish bar/snap0 --alias foo
incus init foo bar2
incus list | grep bar2
Expand Down
12 changes: 6 additions & 6 deletions test/suites/clustering.sh
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,10 @@ test_clustering_containers() {
INCUS_DIR="${INCUS_ONE_DIR}" incus info --show-log foo | grep -q Log

# Create, rename and delete a snapshot of the container via node1
INCUS_DIR="${INCUS_ONE_DIR}" incus snapshot foo foo-bak
INCUS_DIR="${INCUS_ONE_DIR}" incus snapshot create foo foo-bak
INCUS_DIR="${INCUS_ONE_DIR}" incus info foo | grep -q foo-bak
INCUS_DIR="${INCUS_ONE_DIR}" incus rename foo/foo-bak foo/foo-bak-2
INCUS_DIR="${INCUS_ONE_DIR}" incus delete foo/foo-bak-2
INCUS_DIR="${INCUS_ONE_DIR}" incus snapshot rename foo/foo-bak foo/foo-bak-2
INCUS_DIR="${INCUS_ONE_DIR}" incus snapshot delete foo/foo-bak-2
! INCUS_DIR="${INCUS_ONE_DIR}" incus info foo | grep -q foo-bak-2 || false

# Export from node1 the image that was imported on node2
Expand All @@ -482,7 +482,7 @@ test_clustering_containers() {
! INCUS_DIR="${INCUS_TWO_DIR}" incus list | grep -q bar || false

# Create a container on node1 using a snapshot from node2.
INCUS_DIR="${INCUS_ONE_DIR}" incus snapshot foo foo-bak
INCUS_DIR="${INCUS_ONE_DIR}" incus snapshot create foo foo-bak
INCUS_DIR="${INCUS_TWO_DIR}" incus copy foo/foo-bak bar --target node1
INCUS_DIR="${INCUS_TWO_DIR}" incus info bar | grep -q "Location: node1"
INCUS_DIR="${INCUS_THREE_DIR}" incus delete bar
Expand Down Expand Up @@ -764,7 +764,7 @@ test_clustering_storage() {

# Stop the container and create a snapshot
INCUS_DIR="${INCUS_ONE_DIR}" incus stop foo --force
INCUS_DIR="${INCUS_ONE_DIR}" incus snapshot foo snap-test
INCUS_DIR="${INCUS_ONE_DIR}" incus snapshot create foo snap-test

# Move the container to node1
INCUS_DIR="${INCUS_TWO_DIR}" incus move foo --target node1
Expand Down Expand Up @@ -1394,7 +1394,7 @@ test_clustering_publish() {
INCUS_DIR="${INCUS_ONE_DIR}" incus image show foo-image | grep -q "public: false"
INCUS_DIR="${INCUS_TWO_DIR}" incus image delete foo-image

INCUS_DIR="${INCUS_TWO_DIR}" incus snapshot foo backup
INCUS_DIR="${INCUS_TWO_DIR}" incus snapshot create foo backup
INCUS_DIR="${INCUS_ONE_DIR}" incus publish foo/backup --alias=foo-backup-image
INCUS_DIR="${INCUS_ONE_DIR}" incus image show foo-backup-image | grep -q "public: false"

Expand Down
6 changes: 3 additions & 3 deletions test/suites/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ test_property() {
incus config show foo | grep -q "ephemeral: false"

# Create a snap of the instance to set its expiration timestamp
incus snapshot foo s1
incus snapshot create foo s1
incus config set foo/s1 expires_at="2024-03-23T17:38:37.753398689-04:00" --property
incus config show foo/s1 | grep -q "expires_at: 2024-03-23T17:38:37.753398689-04:00"
incus config unset foo/s1 expires_at --property
Expand Down Expand Up @@ -349,7 +349,7 @@ test_config_edit_container_snapshot_pool_config() {
ensure_import_testimage

incus init testimage c1 -s "$storage_pool"
incus snapshot c1 s1
incus snapshot create c1 s1
# edit the container volume name
incus storage volume show "$storage_pool" container/c1 | \
sed 's/^description:.*/description: bar/' | \
Expand Down Expand Up @@ -404,7 +404,7 @@ test_container_snapshot_config() {
ensure_import_testimage

incus init testimage foo -s "incustest-$(basename "${INCUS_DIR}")"
incus snapshot foo
incus snapshot create foo
incus config show foo/snap0 | grep -q 'expires_at: 0001-01-01T00:00:00Z'

echo 'expires_at: 2100-01-01T00:00:00Z' | incus config edit foo/snap0
Expand Down
6 changes: 3 additions & 3 deletions test/suites/container_devices_nic_bridged.sh
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ test_container_devices_nic_bridged() {
grep -F "192.0.2.232" "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/${ctName}.eth0"
incus copy "${ctName}" foo # Gets new MAC address but IPs still conflict.
! stat "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" || false
incus snapshot foo
incus snapshot create foo
incus export foo foo.tar.gz
! incus start foo || false
incus config device set foo eth0 \
Expand All @@ -595,7 +595,7 @@ test_container_devices_nic_bridged() {
incus stop -f foo

# Test container snapshot with conflicting addresses can be restored.
incus restore foo snap0 # Test restore, IPs conflict on config device update (due to only IPs changing).
incus snapshot restore foo snap0 # Test restore, IPs conflict on config device update (due to only IPs changing).
! stat "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" || false # Check lease file removed (due to non-user requested update failing).
incus config device get foo eth0 ipv4.address | grep -Fx '192.0.2.232'
! incus start foo || false
Expand All @@ -606,7 +606,7 @@ test_container_devices_nic_bridged() {
incus start foo
incus stop -f foo

incus restore foo snap0 # Test restore, IPs conflict on config device remove/add (due to MAC change).
incus snapshot restore foo snap0 # Test restore, IPs conflict on config device remove/add (due to MAC change).
! stat "${INCUS_DIR}/networks/${brName}/dnsmasq.hosts/foo.eth0" || false # Check lease file removed (due to MAC change).
incus config device get foo eth0 ipv4.address | grep -Fx '192.0.2.232'
! incus start foo || false
Expand Down
9 changes: 4 additions & 5 deletions test/suites/container_local_cross_pool_handling.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ test_container_local_cross_pool_handling() {
incus delete -f c2

incus init testimage c1
incus snapshot c1
incus snapshot c1
incus snapshot create c1
incus snapshot create c1
incus copy c1 c2 -s "incustest-$(basename "${INCUS_DIR}")-${driver}1" --instance-only
incus storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2
! incus storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap0 || false
Expand All @@ -101,8 +101,8 @@ test_container_local_cross_pool_handling() {
incus delete -f c2

incus init testimage c1
incus snapshot c1
incus snapshot c1
incus snapshot create c1
incus snapshot create c1
incus copy c1 c2 -s "incustest-$(basename "${INCUS_DIR}")-${driver}1"
incus storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2
incus storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap0
Expand All @@ -124,4 +124,3 @@ test_container_local_cross_pool_handling() {
INCUS_DIR="${INCUS_DIR}"
kill_incus "${INCUS_STORAGE_DIR}"
}

6 changes: 3 additions & 3 deletions test/suites/incremental_copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ do_copy() {

# This will create snapshot c1/snap0
incus storage volume set "${source_pool}" container/c1 user.foo=snap0
incus snapshot c1
incus snapshot create c1
incus storage volume set "${source_pool}" container/c1 user.foo=snap1
incus snapshot c1
incus snapshot create c1
incus storage volume set "${source_pool}" container/c1 user.foo=main

# Remove the testfile from c1 and refresh again
Expand All @@ -88,7 +88,7 @@ do_copy() {
incus storage volume get "${target_pool}" container/c2/snap1 user.foo | grep -Fx "snap1"

# This will create snapshot c2/snap2
incus snapshot c2
incus snapshot create c2
incus config show c2/snap2
incus storage volume show "${target_pool}" container/c2/snap2

Expand Down
14 changes: 7 additions & 7 deletions test/suites/migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ migration() {

incus storage volume set "${pool}" container/cccp user.foo=snap0
echo "before" | incus file push - cccp/blah
incus snapshot cccp
incus snapshot create cccp
incus storage volume set "${pool}" container/cccp user.foo=snap1
incus snapshot cccp
incus snapshot create cccp
echo "after" | incus file push - cccp/blah
incus storage volume set "${pool}" container/cccp user.foo=postsnap1

Expand Down Expand Up @@ -238,8 +238,8 @@ migration() {

# Test container only copies
incus init testimage cccp
incus snapshot cccp
incus snapshot cccp
incus snapshot create cccp
incus snapshot create cccp

# Local container with snapshots move.
incus move cccp udssr --mode=pull
Expand All @@ -251,8 +251,8 @@ migration() {
# Test container only copies when zfs.clone_copy is set to false.
incus storage set "incustest-$(basename "${INCUS_DIR}")" zfs.clone_copy false
incus init testimage cccp
incus snapshot cccp
incus snapshot cccp
incus snapshot create cccp
incus snapshot create cccp

# Test container only copies when zfs.clone_copy is set to false.
incus copy cccp udssr --instance-only
Expand Down Expand Up @@ -558,7 +558,7 @@ migration() {

# On zfs, this used to crash due to a websocket read issue.
incus launch testimage c1
incus snapshot c1
incus snapshot create c1
incus copy c1 l2:c1 --stateless
incus copy c1 l2:c1 --stateless --refresh

Expand Down
20 changes: 10 additions & 10 deletions test/suites/projects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -202,26 +202,26 @@ test_projects_snapshots() {
incus init testimage c1

# Create, rename, restore and delete a snapshot
incus snapshot c1
incus snapshot create c1
incus info c1 | grep -q snap0
incus config show c1/snap0 | grep -q BusyBox
incus rename c1/snap0 c1/foo
incus restore c1 foo
incus delete c1/foo
incus snapshot rename c1/snap0 c1/foo
incus snapshot restore c1 foo
incus snapshot delete c1/foo

# Test copies
incus snapshot c1
incus snapshot c1
incus snapshot create c1
incus snapshot create c1
incus copy c1 c2
incus delete c2

# Create a snapshot in this project and another one in the default project
incus snapshot c1
incus snapshot create c1

incus project switch default
ensure_import_testimage
incus init testimage c1
incus snapshot c1
incus snapshot create c1
incus delete c1

# Switch back to the project
Expand Down Expand Up @@ -578,8 +578,8 @@ test_projects_limits() {
incus project set p1 limits.memory 3GiB

# Validate that snapshots don't fail with limits.
incus snapshot c2
incus restore c2 snap0
incus snapshot create c2
incus snapshot restore c2 snap0

incus delete c2

Expand Down
8 changes: 4 additions & 4 deletions test/suites/security.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ test_security_protection() {

# Test deletion protecton
incus init testimage c1
incus snapshot c1
incus snapshot create c1
incus delete c1

incus profile set default security.protection.delete true

incus init testimage c1
incus snapshot c1
incus delete c1/snap0
incus snapshot create c1
incus snapshot delete c1/snap0
! incus delete c1 || false

incus config set c1 security.protection.delete false
Expand Down Expand Up @@ -184,7 +184,7 @@ test_security_protection() {
incus publish c1 --alias=protected
incus image delete protected

incus snapshot c1
incus snapshot create c1
incus publish c1/snap0 --alias=protected
incus image delete protected

Expand Down
Loading

0 comments on commit d1481cd

Please sign in to comment.