Skip to content

Commit a789613

Browse files
authored
Merge pull request ceph#62189 from idryomov/wip-66419
qa/workunits/rbd: wait for resize to be applied in rbd-nbd Reviewed-by: Ramana Raja <[email protected]>
2 parents 3887b27 + bedc75f commit a789613

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

qa/workunits/rbd/luks-encryption.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff 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+
3347
function 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 --getsize64 $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

qa/workunits/rbd/rbd-nbd.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff 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})
210224
blocks=$(awk -v dev=${devname} '$4 == dev {print $3}' /proc/partitions)
211225
test -n "${blocks}"
212226
rbd resize ${POOL}/${IMAGE} --size $((SIZE * 2))M
213-
rbd info ${POOL}/${IMAGE}
227+
wait_for_blockdev_size ${DEV} $(((SIZE * 2) << 20))
214228
blocks2=$(awk -v dev=${devname} '$4 == dev {print $3}' /proc/partitions)
215229
test -n "${blocks2}"
216230
test ${blocks2} -eq $((blocks * 2))
217231
rbd resize ${POOL}/${IMAGE} --allow-shrink --size ${SIZE}M
232+
wait_for_blockdev_size ${DEV} $((SIZE << 20))
218233
blocks2=$(awk -v dev=${devname} '$4 == dev {print $3}' /proc/partitions)
219234
test -n "${blocks2}"
220235
test ${blocks2} -eq ${blocks}

0 commit comments

Comments
 (0)