Skip to content

Commit afc89fd

Browse files
committed
qa/workunits/rbd: add test_import_nbd_stream_disconnected()
When the NBD server is killed, nbd_pread() can set errno to at least ENOTCONN, EINVAL and 0 which is supposed to stand for "no additional errno information is available for this error". Add a test to ensure that "rbd migration execute" command always fails and that the image isn't transitioned to MIGRATION_STATE_EXECUTED in this scenario. Signed-off-by: Ilya Dryomov <[email protected]>
1 parent e4657cb commit afc89fd

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

qa/suites/rbd/cli/workloads/rbd_cli_migration.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
overrides:
2+
install:
3+
extra_system_packages:
4+
rpm:
5+
- qemu-kvm-block-rbd
6+
deb:
7+
- qemu-block-extra
8+
- qemu-utils
19
tasks:
210
- workunit:
311
clients:

qa/workunits/rbd/cli_migration.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,68 @@ EOF
596596
kill_nbd_server
597597
}
598598

599+
test_import_nbd_stream_disconnected() {
600+
local dest_image=$1
601+
local migration_execute_pid
602+
603+
dd if=/dev/urandom of=${TEMPDIR}/large.raw bs=1M count=20480
604+
qemu-nbd -f raw --read-only --shared 10 --persistent --fork \
605+
${TEMPDIR}/large.raw
606+
607+
cat > ${TEMPDIR}/spec.json <<EOF
608+
{
609+
"type": "raw",
610+
"stream": {
611+
"type": "nbd",
612+
"uri": "nbd://localhost"
613+
}
614+
}
615+
EOF
616+
cat ${TEMPDIR}/spec.json
617+
618+
# server disappears while importing - abort
619+
rbd migration prepare --import-only \
620+
--source-spec-path ${TEMPDIR}/spec.json ${dest_image}
621+
rbd status ${dest_image} | grep 'state: prepared'
622+
qemu-img compare ${TEMPDIR}/large.raw rbd:rbd/${dest_image}
623+
rbd migration execute ${dest_image} &
624+
migration_execute_pid=$!
625+
sleep $((5 + RANDOM % 35))
626+
kill_nbd_server
627+
expect_false wait $migration_execute_pid
628+
expect_false rbd status ${dest_image}
629+
rbd migration abort ${dest_image}
630+
631+
qemu-nbd -f raw --read-only --shared 10 --persistent --fork \
632+
${TEMPDIR}/large.raw
633+
634+
# server disappears while importing - resume
635+
rbd migration prepare --import-only \
636+
--source-spec-path ${TEMPDIR}/spec.json ${dest_image}
637+
rbd status ${dest_image} | grep 'state: prepared'
638+
qemu-img compare ${TEMPDIR}/large.raw rbd:rbd/${dest_image}
639+
rbd migration execute ${dest_image} &
640+
migration_execute_pid=$!
641+
sleep $((5 + RANDOM % 35))
642+
kill_nbd_server
643+
expect_false wait $migration_execute_pid
644+
expect_false rbd status ${dest_image}
645+
qemu-nbd -f raw --read-only --shared 10 --persistent --fork \
646+
${TEMPDIR}/large.raw
647+
rbd status ${dest_image} | grep 'state: executing'
648+
qemu-img compare ${TEMPDIR}/large.raw rbd:rbd/${dest_image}
649+
rbd migration execute ${dest_image}
650+
rbd status ${dest_image} | grep 'state: executed'
651+
qemu-img compare ${TEMPDIR}/large.raw rbd:rbd/${dest_image}
652+
rbd migration commit ${dest_image}
653+
rbd status ${dest_image} | expect_false grep 'Migration:'
654+
qemu-img compare ${TEMPDIR}/large.raw rbd:rbd/${dest_image}
655+
656+
remove_image "${dest_image}"
657+
658+
kill_nbd_server
659+
}
660+
599661
# make sure rbd pool is EMPTY.. this is a test script!!
600662
rbd ls 2>&1 | wc -l | grep -v '^0$' && echo "nonempty rbd pool, aborting! run this script on an empty test cluster only." && exit 1
601663

@@ -614,6 +676,8 @@ test_import_nbd_stream_qcow2 ${IMAGE2} ${IMAGE3}
614676
test_import_raw_format ${IMAGE1} ${IMAGE2}
615677
test_import_nbd_stream_raw ${IMAGE1} ${IMAGE2}
616678

679+
test_import_nbd_stream_disconnected ${IMAGE2}
680+
617681
rbd namespace create rbd/${NAMESPACE1}
618682
rbd namespace create rbd/${NAMESPACE2}
619683
create_base_image rbd/${NAMESPACE1}/${IMAGE1}

0 commit comments

Comments
 (0)