]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/workunits/rbd: add test_import_nbd_stream_disconnected() 61567/head
authorIlya Dryomov <idryomov@gmail.com>
Tue, 28 Jan 2025 08:33:37 +0000 (09:33 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 30 Jan 2025 12:19:16 +0000 (13:19 +0100)
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 <idryomov@gmail.com>
qa/suites/rbd/cli/workloads/rbd_cli_migration.yaml
qa/workunits/rbd/cli_migration.sh

index b04ac08f7b4e7099ed69b2def41031212fdd8702..96845dce4367dc0eec133f9f52a98e7e370b860e 100644 (file)
@@ -1,3 +1,11 @@
+overrides:
+  install:
+    extra_system_packages:
+      rpm:
+      - qemu-kvm-block-rbd
+      deb:
+      - qemu-block-extra
+      - qemu-utils
 tasks:
 - workunit:
     clients:
index 3af194209577107c3edc5d55c3109c4f97c48bbb..d4bcf7f77dff8e6a6b7ec0542ca14e29667351cf 100755 (executable)
@@ -596,6 +596,68 @@ EOF
     kill_nbd_server
 }
 
+test_import_nbd_stream_disconnected() {
+    local dest_image=$1
+    local migration_execute_pid
+
+    dd if=/dev/urandom of=${TEMPDIR}/large.raw bs=1M count=20480
+    qemu-nbd -f raw --read-only --shared 10 --persistent --fork \
+        ${TEMPDIR}/large.raw
+
+    cat > ${TEMPDIR}/spec.json <<EOF
+{
+  "type": "raw",
+  "stream": {
+    "type": "nbd",
+    "uri": "nbd://localhost"
+  }
+}
+EOF
+    cat ${TEMPDIR}/spec.json
+
+    # server disappears while importing - abort
+    rbd migration prepare --import-only \
+        --source-spec-path ${TEMPDIR}/spec.json ${dest_image}
+    rbd status ${dest_image} | grep 'state: prepared'
+    qemu-img compare ${TEMPDIR}/large.raw rbd:rbd/${dest_image}
+    rbd migration execute ${dest_image} &
+    migration_execute_pid=$!
+    sleep $((5 + RANDOM % 35))
+    kill_nbd_server
+    expect_false wait $migration_execute_pid
+    expect_false rbd status ${dest_image}
+    rbd migration abort ${dest_image}
+
+    qemu-nbd -f raw --read-only --shared 10 --persistent --fork \
+        ${TEMPDIR}/large.raw
+
+    # server disappears while importing - resume
+    rbd migration prepare --import-only \
+        --source-spec-path ${TEMPDIR}/spec.json ${dest_image}
+    rbd status ${dest_image} | grep 'state: prepared'
+    qemu-img compare ${TEMPDIR}/large.raw rbd:rbd/${dest_image}
+    rbd migration execute ${dest_image} &
+    migration_execute_pid=$!
+    sleep $((5 + RANDOM % 35))
+    kill_nbd_server
+    expect_false wait $migration_execute_pid
+    expect_false rbd status ${dest_image}
+    qemu-nbd -f raw --read-only --shared 10 --persistent --fork \
+        ${TEMPDIR}/large.raw
+    rbd status ${dest_image} | grep 'state: executing'
+    qemu-img compare ${TEMPDIR}/large.raw rbd:rbd/${dest_image}
+    rbd migration execute ${dest_image}
+    rbd status ${dest_image} | grep 'state: executed'
+    qemu-img compare ${TEMPDIR}/large.raw rbd:rbd/${dest_image}
+    rbd migration commit ${dest_image}
+    rbd status ${dest_image} | expect_false grep 'Migration:'
+    qemu-img compare ${TEMPDIR}/large.raw rbd:rbd/${dest_image}
+
+    remove_image "${dest_image}"
+
+    kill_nbd_server
+}
+
 # make sure rbd pool is EMPTY.. this is a test script!!
 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
 
@@ -614,6 +676,8 @@ test_import_nbd_stream_qcow2 ${IMAGE2} ${IMAGE3}
 test_import_raw_format ${IMAGE1} ${IMAGE2}
 test_import_nbd_stream_raw ${IMAGE1} ${IMAGE2}
 
+test_import_nbd_stream_disconnected ${IMAGE2}
+
 rbd namespace create rbd/${NAMESPACE1}
 rbd namespace create rbd/${NAMESPACE2}
 create_base_image rbd/${NAMESPACE1}/${IMAGE1}