From 80fe5a87354d6895247d636e91646e8b4fc02d1c Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Tue, 1 Dec 2020 22:35:51 -0500 Subject: [PATCH] qa/suites/rbd: new basic migration CLI test case Pending a larger suite of tests for instant-restore image migration, this test provides a basic sanity check for both the native and raw image formats -- including basic snapshot tests. Signed-off-by: Jason Dillaman --- .../rbd/cli/workloads/rbd_cli_migration.yaml | 5 + qa/workunits/rbd/cli_migration.sh | 219 ++++++++++++++++++ 2 files changed, 224 insertions(+) create mode 100644 qa/suites/rbd/cli/workloads/rbd_cli_migration.yaml create mode 100755 qa/workunits/rbd/cli_migration.sh diff --git a/qa/suites/rbd/cli/workloads/rbd_cli_migration.yaml b/qa/suites/rbd/cli/workloads/rbd_cli_migration.yaml new file mode 100644 index 00000000000..b04ac08f7b4 --- /dev/null +++ b/qa/suites/rbd/cli/workloads/rbd_cli_migration.yaml @@ -0,0 +1,5 @@ +tasks: +- workunit: + clients: + client.0: + - rbd/cli_migration.sh diff --git a/qa/workunits/rbd/cli_migration.sh b/qa/workunits/rbd/cli_migration.sh new file mode 100755 index 00000000000..e1a4d2df8ce --- /dev/null +++ b/qa/workunits/rbd/cli_migration.sh @@ -0,0 +1,219 @@ +#!/usr/bin/env bash +set -ex + +. $(dirname $0)/../../standalone/ceph-helpers.sh + +TEMPDIR= +IMAGE1=image1 +IMAGE2=image2 +IMAGE3=image3 +IMAGES="${IMAGE1} ${IMAGE2} ${IMAGE3}" + +cleanup() { + cleanup_tempdir + remove_images +} + +setup_tempdir() { + TEMPDIR=`mktemp -d` +} + +cleanup_tempdir() { + rm -rf ${TEMPDIR} +} + +create_base_image() { + local image=$1 + + rbd create --size 1G ${image} + rbd bench --io-type write --io-pattern rand --io-size=4K --io-total 256M ${image} + rbd snap create ${image}@1 + rbd bench --io-type write --io-pattern rand --io-size=4K --io-total 64M ${image} + rbd snap create ${image}@2 + rbd bench --io-type write --io-pattern rand --io-size=4K --io-total 128M ${image} +} + +export_raw_image() { + local image=$1 + + rm -rf "${TEMPDIR}/${image}" + rbd export ${image} "${TEMPDIR}/${image}" +} + +export_base_image() { + local image=$1 + + export_raw_image "${image}" + export_raw_image "${image}@1" + export_raw_image "${image}@2" +} + +remove_image() { + local image=$1 + + (rbd migration abort $image || true) >/dev/null 2>&1 + (rbd snap purge $image || true) >/dev/null 2>&1 + (rbd rm $image || true) >/dev/null 2>&1 +} + +remove_images() { + for image in ${IMAGES} + do + remove_image ${image} + done +} + +compare_images() { + local src_image=$1 + local dst_image=$2 + + export_raw_image ${dst_image} + cmp "${TEMPDIR}/${src_image}" "${TEMPDIR}/${dst_image}" +} + +test_import_native_format() { + local base_image=$1 + local dest_image=$2 + + local pool_id=$(ceph osd pool ls detail --format xml | xmlstarlet sel -t -v "//pools/pool[pool_name='rbd']/pool_id") + cat > ${TEMPDIR}/spec.json < ${TEMPDIR}/spec.json < ${TEMPDIR}/spec.json <&1 | wc -l | grep -v '^0$' && echo "nonempty rbd pool, aborting! run this script on an empty test cluster only." && exit 1 + +setup_tempdir +trap 'cleanup $?' INT TERM EXIT + +create_base_image ${IMAGE1} +export_base_image ${IMAGE1} + +test_import_native_format ${IMAGE1} ${IMAGE2} +test_import_raw_format ${IMAGE1} ${IMAGE2} + +echo OK -- 2.47.3