Skip to content

Commit

Permalink
test: Use new incus storage volume 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 30, 2023
1 parent 5b4aac6 commit be0995d
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 96 deletions.
18 changes: 9 additions & 9 deletions test/suites/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ EOF
incus snapshot create c1
incus info c1

incus storage volume snapshot "${poolName}" vol1_test snap0
incus storage volume snapshot create "${poolName}" vol1_test snap0
incus storage volume show "${poolName}" vol1_test
incus storage volume show "${poolName}" vol1_test/snap0
incus storage volume snapshot show "${poolName}" vol1_test/snap0

# Remove container DB records and symlink.
incusd sql global "PRAGMA foreign_keys=ON; DELETE FROM instances WHERE name='c1'"
Expand Down Expand Up @@ -136,7 +136,7 @@ EOF
! ls "${INCUS_DIR}/containers/test_c1" || false
! incus info c1 || false
! incus storage volume show "${poolName}" container/c1 || false
! incus storage volume show "${poolName}" container/c1/snap0 || false
! incus storage volume snapshot show "${poolName}" container/c1/snap0 || false

if [ "$poolDriver" != "dir" ] && [ "$poolDriver" != "btrfs" ] && [ "$poolDriver" != "cephfs" ]; then
! ls "${INCUS_DIR}/storage-pools/${poolName}/containers/test_c1" || false
Expand All @@ -145,7 +145,7 @@ EOF

# Check custom volume appears removed.
! incus storage volume show "${poolName}" vol1_test || false
! incus storage volume show "${poolName}" vol1_test/snap0 || false
! incus storage volume snapshot show "${poolName}" vol1_test/snap0 || false

# Shutdown Incus so pools are unmounted.
shutdown_incus "${INCUS_DIR}"
Expand Down Expand Up @@ -175,13 +175,13 @@ EOF

# Check custom volume record exists with snapshot.
incus storage volume show "${poolName}" vol1_test
incus storage volume show "${poolName}" vol1_test/snap0
incus storage volume snapshot show "${poolName}" vol1_test/snap0

# Check snapshot exists and container can be started.
incus info c1 | grep snap0
incus storage volume ls "${poolName}"
incus storage volume show "${poolName}" container/c1
incus storage volume show "${poolName}" container/c1/snap0
incus storage volume snapshot show "${poolName}" container/c1/snap0
incus start c1
incus exec c1 --project test -- hostname

Expand Down Expand Up @@ -700,13 +700,13 @@ test_backup_volume_export_with_project() {

# Snapshot the custom volume.
incus storage volume set "${custom_vol_pool}" testvol user.foo=test-snap0
incus storage volume snapshot "${custom_vol_pool}" testvol test-snap0
incus storage volume snapshot create "${custom_vol_pool}" testvol test-snap0

# Change the content (the snapshot will contain the old value).
echo bar | incus file push - c1/mnt/test

incus storage volume set "${custom_vol_pool}" testvol user.foo=test-snap1
incus storage volume snapshot "${custom_vol_pool}" testvol test-snap1
incus storage volume snapshot create "${custom_vol_pool}" testvol test-snap1
incus storage volume set "${custom_vol_pool}" testvol user.foo=post-test-snap1

if [ "$incus_backend" = "btrfs" ] || [ "$incus_backend" = "zfs" ]; then
Expand Down Expand Up @@ -782,7 +782,7 @@ test_backup_volume_export_with_project() {
incus storage volume import "${custom_vol_pool}" "${INCUS_DIR}/testvol.tar.gz"
incus storage volume ls "${custom_vol_pool}"
incus storage volume get "${custom_vol_pool}" testvol user.foo | grep -Fx "post-test-snap1"
incus storage volume show "${custom_vol_pool}" testvol/test-snap0
incus storage volume snapshot show "${custom_vol_pool}" testvol/test-snap0
incus storage volume get "${custom_vol_pool}" testvol/test-snap0 user.foo | grep -Fx "test-snap0"
incus storage volume get "${custom_vol_pool}" testvol/test-snap1 user.foo | grep -Fx "test-snap1"

Expand Down
10 changes: 5 additions & 5 deletions test/suites/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,12 @@ test_property() {
incus launch testimage c1 -s "${storage_pool}"

# This will create a snapshot named 'snap0'
incus storage volume snapshot "${storage_pool}" "${storage_volume}"
incus storage volume snapshot create "${storage_pool}" "${storage_volume}"

incus storage volume set "${storage_pool}" "${storage_volume}"/snap0 expires_at="2024-03-23T17:38:37.753398689-04:00" --property
incus storage volume show "${storage_pool}" "${storage_volume}/snap0" | grep 'expires_at: 2024-03-23T17:38:37.753398689-04:00'
incus storage volume snapshot show "${storage_pool}" "${storage_volume}/snap0" | grep 'expires_at: 2024-03-23T17:38:37.753398689-04:00'
incus storage volume unset "${storage_pool}" "${storage_volume}"/snap0 expires_at --property
incus storage volume show "${storage_pool}" "${storage_volume}/snap0" | grep 'expires_at: 0001-01-01T00:00:00Z'
incus storage volume snapshot show "${storage_pool}" "${storage_volume}/snap0" | grep 'expires_at: 0001-01-01T00:00:00Z'

incus delete -f c1
incus storage volume delete "${storage_pool}" "${storage_volume}"
Expand All @@ -356,10 +356,10 @@ test_config_edit_container_snapshot_pool_config() {
incus storage volume edit "$storage_pool" container/c1
incus storage volume show "$storage_pool" container/c1 | grep -q 'description: bar'
# edit the container snapshot volume name
incus storage volume show "$storage_pool" container/c1/s1 | \
incus storage volume snapshot show "$storage_pool" container/c1/s1 | \
sed 's/^description:.*/description: baz/' | \
incus storage volume edit "$storage_pool" container/c1/s1
incus storage volume show "$storage_pool" container/c1/s1 | grep -q 'description: baz'
incus storage volume snapshot show "$storage_pool" container/c1/s1 | grep -q 'description: baz'
incus delete c1
}

Expand Down
16 changes: 8 additions & 8 deletions test/suites/container_local_cross_pool_handling.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,29 +90,29 @@ test_container_local_cross_pool_handling() {
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
! incus storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap1 || false
! incus storage volume snapshot show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap0 || false
! incus storage volume snapshot show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap1 || false
incus delete -f c2
incus move c1 c2 -s "incustest-$(basename "${INCUS_DIR}")-${driver}1" --instance-only
! incus info c1 || false
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
! incus storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap1 || false
! incus storage volume snapshot show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap0 || false
! incus storage volume snapshot show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap1 || false
incus delete -f c2

incus init testimage 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
incus storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap1
incus storage volume snapshot show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap0
incus storage volume snapshot show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap1
incus delete -f c2
incus move c1 c2 -s "incustest-$(basename "${INCUS_DIR}")-${driver}1"
! incus info c1 || false
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
incus storage volume show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap1
incus storage volume snapshot show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap0
incus storage volume snapshot show "incustest-$(basename "${INCUS_DIR}")-${driver}1" container/c2/snap1
incus delete -f c2
fi
done
Expand Down
4 changes: 2 additions & 2 deletions test/suites/incremental_copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ do_copy() {
# This will create snapshot c2/snap2
incus snapshot create c2
incus config show c2/snap2
incus storage volume show "${target_pool}" container/c2/snap2
incus storage volume snapshot show "${target_pool}" container/c2/snap2

# This should remove c2/snap2
# shellcheck disable=2086
incus copy c1 c2 --refresh ${targetPoolFlag}
! incus config show c2/snap2 || false
! incus storage volume show "${target_pool}" container/c2/snap2 || false
! incus storage volume snapshot show "${target_pool}" container/c2/snap2 || false

incus rm -f c1 c2
}
16 changes: 8 additions & 8 deletions test/suites/migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,9 @@ migration() {

incus_remote storage volume create l1:"$remote_pool1" vol1
incus_remote storage volume set l1:"$remote_pool1" vol1 user.foo=snap0vol1
incus_remote storage volume snapshot l1:"$remote_pool1" vol1
incus_remote storage volume snapshot create l1:"$remote_pool1" vol1
incus_remote storage volume set l1:"$remote_pool1" vol1 user.foo=snap1vol1
incus_remote storage volume snapshot l1:"$remote_pool1" vol1
incus_remote storage volume snapshot create l1:"$remote_pool1" vol1
incus_remote storage volume set l1:"$remote_pool1" vol1 user.foo=postsnap1vol1

# remote storage volume and snapshots migration in "pull" mode
Expand All @@ -363,7 +363,7 @@ migration() {

# remote storage volume and snapshots migration refresh in "pull" mode
incus_remote storage volume set l1:"$remote_pool1" vol1 user.foo=snapremovevol1
incus_remote storage volume snapshot l1:"$remote_pool1" vol1 snapremove
incus_remote storage volume snapshot create l1:"$remote_pool1" vol1 snapremove
incus_remote storage volume set l1:"$remote_pool1" vol1 user.foo=postsnap1vol1
incus_remote storage volume copy l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol2" --refresh
incus_remote storage volume delete l1:"$remote_pool1" vol1
Expand All @@ -376,11 +376,11 @@ migration() {
# check remote storage volume refresh from a different volume
incus_remote storage volume create l1:"$remote_pool1" vol3
incus_remote storage volume set l1:"$remote_pool1" vol3 user.foo=snap0vol3
incus_remote storage volume snapshot l1:"$remote_pool1" vol3
incus_remote storage volume snapshot create l1:"$remote_pool1" vol3
incus_remote storage volume set l1:"$remote_pool1" vol3 user.foo=snap1vol3
incus_remote storage volume snapshot l1:"$remote_pool1" vol3
incus_remote storage volume snapshot create l1:"$remote_pool1" vol3
incus_remote storage volume set l1:"$remote_pool1" vol3 user.foo=snap2vol3
incus_remote storage volume snapshot l1:"$remote_pool1" vol3
incus_remote storage volume snapshot create l1:"$remote_pool1" vol3
incus_remote storage volume set l1:"$remote_pool1" vol3 user.foo=postsnap1vol3

# check snapshot volumes and snapshots are refreshed
Expand All @@ -398,7 +398,7 @@ migration() {
# remote storage volume migration in "push" mode
incus_remote storage volume create l1:"$remote_pool1" vol1
incus_remote storage volume create l1:"$remote_pool1" vol2
incus_remote storage volume snapshot l1:"$remote_pool1" vol2
incus_remote storage volume snapshot create l1:"$remote_pool1" vol2

incus_remote storage volume copy l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol2" --mode=push
incus_remote storage volume move l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol3" --mode=push
Expand All @@ -416,7 +416,7 @@ migration() {
# remote storage volume migration in "relay" mode
incus_remote storage volume create l1:"$remote_pool1" vol1
incus_remote storage volume create l1:"$remote_pool1" vol2
incus_remote storage volume snapshot l1:"$remote_pool1" vol2
incus_remote storage volume snapshot create l1:"$remote_pool1" vol2

incus_remote storage volume copy l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol2" --mode=relay
incus_remote storage volume move l1:"$remote_pool1/vol1" l2:"$remote_pool2/vol3" --mode=relay
Expand Down
12 changes: 6 additions & 6 deletions test/suites/serverconfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ test_server_config_storage() {
! incus config set storage.backups_volume "${pool}/bar"
! incus config set storage.images_volume "${pool}/bar"

incus storage volume snapshot "${pool}" backups
incus storage volume snapshot "${pool}" images
incus storage volume snapshot create "${pool}" backups
incus storage volume snapshot create "${pool}" images
! incus config set storage.backups_volume "${pool}/backups"
! incus config set storage.images_volume "${pool}/images"

incus storage volume delete "${pool}" backups/snap0
incus storage volume delete "${pool}" images/snap0
incus storage volume snapshot delete "${pool}" backups/snap0
incus storage volume snapshot delete "${pool}" images/snap0

# Set the configuration
incus config set storage.backups_volume "${pool}/backups"
Expand All @@ -89,8 +89,8 @@ test_server_config_storage() {
! incus storage volume delete "${pool}" images
! incus storage volume rename "${pool}" backups backups1
! incus storage volume rename "${pool}" images images1
! incus storage volume snapshot "${pool}" backups
! incus storage volume snapshot "${pool}" images
! incus storage volume snapshot create "${pool}" backups
! incus storage volume snapshot create "${pool}" images

# Modify container and publish to image on custom volume.
incus start foo
Expand Down
4 changes: 2 additions & 2 deletions test/suites/snapshots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ test_snap_volume_db_recovery() {
! incus start c1 || false # Shouldn't be able to start as backup.yaml generation checks for DB consistency.
incusd shutdown
respawn_incus "${INCUS_DIR}" true
incus storage volume show "${poolName}" container/c1/snap0 | grep "Auto repaired"
incus storage volume show "${poolName}" container/c1/snap1 | grep "Auto repaired"
incus storage volume snapshot show "${poolName}" container/c1/snap0 | grep "Auto repaired"
incus storage volume snapshot show "${poolName}" container/c1/snap1 | grep "Auto repaired"
incus start c1
incus delete -f c1
}
4 changes: 2 additions & 2 deletions test/suites/storage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,9 @@ test_storage() {

incus storage volume create "incustest-$(basename "${INCUS_DIR}")-pool5" c12pool5
# should create snap0
incus storage volume snapshot "incustest-$(basename "${INCUS_DIR}")-pool5" c12pool5
incus storage volume snapshot create "incustest-$(basename "${INCUS_DIR}")-pool5" c12pool5
# should create snap1
incus storage volume snapshot "incustest-$(basename "${INCUS_DIR}")-pool5" c12pool5
incus storage volume snapshot create "incustest-$(basename "${INCUS_DIR}")-pool5" c12pool5

if [ "$incus_backend" = "lvm" ]; then
incus init testimage c10pool6 -s "incustest-$(basename "${INCUS_DIR}")-pool6"
Expand Down
16 changes: 8 additions & 8 deletions test/suites/storage_driver_cephfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ test_storage_driver_cephfs() {

# Snapshots
incus storage volume create cephfs vol1
incus storage volume snapshot cephfs vol1
incus storage volume snapshot cephfs vol1
incus storage volume snapshot cephfs vol1 blah1
incus storage volume rename cephfs vol1/blah1 vol1/blah2
incus storage volume snapshot cephfs vol1 blah1
incus storage volume delete cephfs vol1/snap0
incus storage volume delete cephfs vol1/snap1
incus storage volume restore cephfs vol1 blah1
incus storage volume snapshot create cephfs vol1
incus storage volume snapshot create cephfs vol1
incus storage volume snapshot create cephfs vol1 blah1
incus storage volume snapshot rename cephfs vol1 blah1 blah2
incus storage volume snapshot create cephfs vol1 blah1
incus storage volume snapshot delete cephfs vol1/snap0
incus storage volume snapshot delete cephfs vol1/snap1
incus storage volume snapshot restore cephfs vol1 blah1
incus storage volume copy cephfs/vol1 cephfs/vol2 --volume-only
incus storage volume copy cephfs/vol1 cephfs/vol3 --volume-only
incus storage volume delete cephfs vol1
Expand Down
Loading

0 comments on commit be0995d

Please sign in to comment.