Skip to content

Commit 59e141e

Browse files
committed
test/suites/storage_local_volume_handling: replace some grep with shell comparisons
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
1 parent eded904 commit 59e141e

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

test/suites/storage_local_volume_handling.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ test_storage_local_volume_handling() {
8383
lxc storage volume show "${pool}" vol1copy/snap1
8484

8585
# Check snapshot volume config was copied
86-
lxc storage volume get "${pool}" vol1copy user.foo | grep -Fx "postsnap1"
87-
lxc storage volume get "${pool}" vol1copy/snap0 user.foo | grep -Fx "snap0"
88-
lxc storage volume get "${pool}" vol1copy/snap1 user.foo | grep -Fx "snap1"
86+
[ "$(lxc storage volume get "${pool}" vol1copy user.foo)" = "postsnap1" ]
87+
[ "$(lxc storage volume get "${pool}" vol1copy/snap0 user.foo)" = "snap0" ]
88+
[ "$(lxc storage volume get "${pool}" vol1copy/snap1 user.foo)" = "snap1" ]
8989

9090
# Check the volume and snapshot UUIDs are different
9191
[ "$(lxc storage volume get "${pool}" vol1 volatile.uuid)" != "$(lxc storage volume get "${pool}" vol1copy volatile.uuid)" ]
@@ -101,9 +101,9 @@ test_storage_local_volume_handling() {
101101
lxc storage volume show "${pool}1" vol1/snap1
102102

103103
# Check snapshot volume config was copied
104-
lxc storage volume get "${pool}1" vol1 user.foo | grep -Fx "postsnap1"
105-
lxc storage volume get "${pool}1" vol1/snap0 user.foo | grep -Fx "snap0"
106-
lxc storage volume get "${pool}1" vol1/snap1 user.foo | grep -Fx "snap1"
104+
[ "$(lxc storage volume get "${pool}1" vol1 user.foo)" = "postsnap1" ]
105+
[ "$(lxc storage volume get "${pool}1" vol1/snap0 user.foo)" = "snap0" ]
106+
[ "$(lxc storage volume get "${pool}1" vol1/snap1 user.foo)" = "snap1" ]
107107

108108
# Copy volume only
109109
lxc storage volume copy --volume-only "${pool}/vol1" "${pool}1/vol2"
@@ -113,14 +113,14 @@ test_storage_local_volume_handling() {
113113
! lxc storage volume show "${pool}1" vol2/snap1 || false
114114

115115
# Check snapshot volume config was copied
116-
lxc storage volume get "${pool}1" vol2 user.foo | grep -Fx "postsnap1"
116+
[ "$(lxc storage volume get "${pool}1" vol2 user.foo)" = "postsnap1" ]
117117

118118
# Copy snapshot to volume
119119
lxc storage volume copy "${pool}/vol1/snap0" "${pool}1/vol3"
120120

121121
# Check snapshot volume config was copied from snapshot
122122
lxc storage volume show "${pool}1" vol3
123-
lxc storage volume get "${pool}1" vol3 user.foo | grep -Fx "snap0"
123+
[ "$(lxc storage volume get "${pool}1" vol3 user.foo)" = "snap0" ]
124124

125125
# Rename custom volume using `lxc storage volume move`
126126
lxc storage volume move "${pool}1/vol1" "${pool}1/vol4"
@@ -264,10 +264,10 @@ test_storage_local_volume_handling() {
264264
lxc storage volume copy --refresh "${source_pool}/vol5" "${target_pool}/vol5"
265265

266266
# check snapshot volumes (including config) were copied
267-
lxc storage volume get "${target_pool}" vol5 user.foo | grep -Fx "postsnap1vol5"
268-
lxc storage volume get "${target_pool}" vol5/snap0 user.foo | grep -Fx "snap0vol5"
269-
lxc storage volume get "${target_pool}" vol5/snap1 user.foo | grep -Fx "snap1vol5"
270-
lxc storage volume get "${target_pool}" vol5/snapremove user.foo | grep -Fx "snapremovevol5"
267+
[ "$(lxc storage volume get "${target_pool}" vol5 user.foo)" = "postsnap1vol5" ]
268+
[ "$(lxc storage volume get "${target_pool}" vol5/snap0 user.foo)" = "snap0vol5" ]
269+
[ "$(lxc storage volume get "${target_pool}" vol5/snap1 user.foo)" = "snap1vol5" ]
270+
[ "$(lxc storage volume get "${target_pool}" vol5/snapremove user.foo)" = "snapremovevol5" ]
271271

272272
# incremental copy to existing volume destination with refresh flag
273273
lxc storage volume copy --refresh "${source_pool}/vol6" "${target_pool}/vol5"
@@ -276,10 +276,10 @@ test_storage_local_volume_handling() {
276276
# present and that the missing snapshot has been removed.
277277
# Note: Due to a known issue we are currently only diffing the snapshots by name and creation date, so infact existing
278278
# snapshots of the same name and date won't be overwritten even if their config or contents is different.
279-
lxc storage volume get "${target_pool}" vol5 user.foo | grep -Fx "postsnap1vol5"
280-
lxc storage volume get "${target_pool}" vol5/snap0 user.foo | grep -Fx "snap0vol6"
281-
lxc storage volume get "${target_pool}" vol5/snap1 user.foo | grep -Fx "snap1vol6"
282-
lxc storage volume get "${target_pool}" vol5/snap2 user.foo | grep -Fx "snap2vol6"
279+
[ "$(lxc storage volume get "${target_pool}" vol5 user.foo)" = "postsnap1vol5" ]
280+
[ "$(lxc storage volume get "${target_pool}" vol5/snap0 user.foo)" = "snap0vol6" ]
281+
[ "$(lxc storage volume get "${target_pool}" vol5/snap1 user.foo)" = "snap1vol6" ]
282+
[ "$(lxc storage volume get "${target_pool}" vol5/snap2 user.foo)" = "snap2vol6" ]
283283
! lxc storage volume get "${target_pool}" vol5/snapremove user.foo || false
284284

285285
# check that another refresh doesn't change the volume's and snapshot's UUID

0 commit comments

Comments
 (0)