File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,20 @@ function expect_false() {
3030 if " $@ " ; then return 1; else return 0; fi
3131}
3232
33+ function wait_for_blockdev_size() {
34+ local dev=$1
35+ local size=$2
36+
37+ for s in 0.25 0.5 0.75 1 1.25 1.5 1.75 2 2.25 2.5 2.75 3 3.25 3.5 3.75; do
38+ if (( $(sudo blockdev -- getsize64 $dev ) == $size )) ; then
39+ return 0
40+ fi
41+ sleep $s
42+ done
43+
44+ return 1
45+ }
46+
3347function test_encryption_format() {
3448 local format=$1
3549
@@ -62,7 +76,7 @@ function test_encryption_format() {
6276 (( $(sudo blockdev -- getsize64 $LIBRBD_DEV ) < (32 << 20 ) ))
6377 expect_false rbd resize --size 32M testimg
6478 rbd resize --size 32M --encryption-passphrase-file /tmp/passphrase testimg
65- (( $(sudo blockdev -- getsize 64 $ LIBRBD_DEV) == ( 32 << 20 ) ))
79+ wait_for_blockdev_size $ LIBRBD_DEV $(( 32 << 20 ))
6680
6781 _sudo rbd device unmap -t nbd $LIBRBD_DEV
6882 sudo cryptsetup close cryptsetupdev
Original file line number Diff line number Diff line change @@ -122,6 +122,20 @@ unmap_device()
122122 sleep 0.5
123123}
124124
125+ function wait_for_blockdev_size() {
126+ local dev=$1
127+ local size=$2
128+
129+ for s in 0.25 0.5 0.75 1 1.25 1.5 1.75 2 2.25 2.5 2.75 3 3.25 3.5 3.75; do
130+ if (( $(sudo blockdev -- getsize64 $dev ) == $size )) ; then
131+ return 0
132+ fi
133+ sleep $s
134+ done
135+
136+ return 1
137+ }
138+
125139#
126140# main
127141#
@@ -210,11 +224,12 @@ devname=$(basename ${DEV})
210224blocks=$( awk -v dev=${devname} ' $4 == dev {print $3}' /proc/partitions)
211225test -n " ${blocks} "
212226rbd resize ${POOL} /${IMAGE} --size $(( SIZE * 2 )) M
213- rbd info ${POOL} / ${IMAGE}
227+ wait_for_blockdev_size ${DEV} $(( (SIZE * 2 ) << 20 ))
214228blocks2=$( awk -v dev=${devname} ' $4 == dev {print $3}' /proc/partitions)
215229test -n " ${blocks2} "
216230test ${blocks2} -eq $(( blocks * 2 ))
217231rbd resize ${POOL} /${IMAGE} --allow-shrink --size ${SIZE} M
232+ wait_for_blockdev_size ${DEV} $(( SIZE << 20 ))
218233blocks2=$( awk -v dev=${devname} ' $4 == dev {print $3}' /proc/partitions)
219234test -n " ${blocks2} "
220235test ${blocks2} -eq ${blocks}
You can’t perform that action at this time.
0 commit comments