]> git.proxmox.com Git - ceph.git/blobdiff - ceph/qa/workunits/rbd/import_export.sh
update sources to 12.2.7
[ceph.git] / ceph / qa / workunits / rbd / import_export.sh
index 35509642ae5de5d821a7352065752b40a7c8abb7..3c85adc0f9515d09b5579b23e92283b59c13b8aa 100755 (executable)
@@ -74,70 +74,76 @@ cmp ${TMPDIR}/img ${TMPDIR}/img3
 
 rm ${TMPDIR}/img ${TMPDIR}/img2 ${TMPDIR}/img3
 
-# try with --export-format for snapshots
-dd if=/bin/dd of=${TMPDIR}/img bs=1k count=10 seek=100
-rbd import $RBD_CREATE_ARGS ${TMPDIR}/img testimg
-rbd snap create testimg@snap
-rbd export --export-format 2 testimg ${TMPDIR}/img_v2
-rbd import --export-format 2 ${TMPDIR}/img_v2 testimg_import
-rbd info testimg_import
-rbd info testimg_import@snap
-
-# compare the contents between testimg and testimg_import
-rbd export testimg_import ${TMPDIR}/img_import
-compare_files_and_ondisk_sizes ${TMPDIR}/img ${TMPDIR}/img_import
-
-rbd export testimg@snap ${TMPDIR}/img_snap
-rbd export testimg_import@snap ${TMPDIR}/img_snap_import
-compare_files_and_ondisk_sizes ${TMPDIR}/img_snap ${TMPDIR}/img_snap_import
-
-rm ${TMPDIR}/img_v2
-rm ${TMPDIR}/img_import
-rm ${TMPDIR}/img_snap
-rm ${TMPDIR}/img_snap_import
-
-rbd snap rm testimg_import@snap
-rbd remove testimg_import
-rbd snap rm testimg@snap
-rbd rm testimg
-
-# order
-rbd import --order 20 ${TMPDIR}/img testimg
-rbd export --export-format 2 testimg ${TMPDIR}/img_v2
-rbd import --export-format 2 ${TMPDIR}/img_v2 testimg_import
-rbd info testimg_import|grep order|awk '{print $2}'|grep 20
-
-rm ${TMPDIR}/img_v2
-
-rbd remove testimg_import
-rbd remove testimg
-
-# features
-rbd import --image-feature layering ${TMPDIR}/img testimg
-FEATURES_BEFORE=`rbd info testimg|grep features`
-rbd export --export-format 2 testimg ${TMPDIR}/img_v2
-rbd import --export-format 2 ${TMPDIR}/img_v2 testimg_import
-FEATURES_AFTER=`rbd info testimg_import|grep features`
-if [ "$FEATURES_BEFORE" != "$FEATURES_AFTER" ]; then
-  false
-fi
+if rbd help export | grep -q export-format; then
+    # try with --export-format for snapshots
+    dd if=/bin/dd of=${TMPDIR}/img bs=1k count=10 seek=100
+    rbd import $RBD_CREATE_ARGS ${TMPDIR}/img testimg
+    rbd snap create testimg@snap
+    rbd image-meta set testimg key1 value1
+    IMAGEMETA_BEFORE=`rbd image-meta list testimg`
+    rbd export --export-format 2 testimg ${TMPDIR}/img_v2
+    rbd import --export-format 2 ${TMPDIR}/img_v2 testimg_import
+    rbd info testimg_import
+    rbd info testimg_import@snap
+    IMAGEMETA_AFTER=`rbd image-meta list testimg_import`
+    [ "$IMAGEMETA_BEFORE" = "$IMAGEMETA_AFTER" ]
+
+    # compare the contents between testimg and testimg_import
+    rbd export testimg_import ${TMPDIR}/img_import
+    compare_files_and_ondisk_sizes ${TMPDIR}/img ${TMPDIR}/img_import
+
+    rbd export testimg@snap ${TMPDIR}/img_snap
+    rbd export testimg_import@snap ${TMPDIR}/img_snap_import
+    compare_files_and_ondisk_sizes ${TMPDIR}/img_snap ${TMPDIR}/img_snap_import
+
+    rm ${TMPDIR}/img_v2
+    rm ${TMPDIR}/img_import
+    rm ${TMPDIR}/img_snap
+    rm ${TMPDIR}/img_snap_import
+
+    rbd snap rm testimg_import@snap
+    rbd remove testimg_import
+    rbd snap rm testimg@snap
+    rbd rm testimg
+
+    # order
+    rbd import --order 20 ${TMPDIR}/img testimg
+    rbd export --export-format 2 testimg ${TMPDIR}/img_v2
+    rbd import --export-format 2 ${TMPDIR}/img_v2 testimg_import
+    rbd info testimg_import|grep order|awk '{print $2}'|grep 20
+    
+    rm ${TMPDIR}/img_v2
+
+    rbd remove testimg_import
+    rbd remove testimg
+
+    # features
+    rbd import --image-feature layering ${TMPDIR}/img testimg
+    FEATURES_BEFORE=`rbd info testimg|grep features`
+    rbd export --export-format 2 testimg ${TMPDIR}/img_v2
+    rbd import --export-format 2 ${TMPDIR}/img_v2 testimg_import
+    FEATURES_AFTER=`rbd info testimg_import|grep features`
+    if [ "$FEATURES_BEFORE" != "$FEATURES_AFTER" ]; then
+        false
+    fi
 
-rm ${TMPDIR}/img_v2
+    rm ${TMPDIR}/img_v2
 
-rbd remove testimg_import
-rbd remove testimg
+    rbd remove testimg_import
+    rbd remove testimg
 
-# stripe
-rbd import --stripe-count 1000 --stripe-unit 4096 ${TMPDIR}/img testimg
-rbd export --export-format 2 testimg ${TMPDIR}/img_v2
-rbd import --export-format 2 ${TMPDIR}/img_v2 testimg_import
-rbd info testimg_import|grep "stripe unit"|awk '{print $3}'|grep 4096
-rbd info testimg_import|grep "stripe count"|awk '{print $3}'|grep 1000
+    # stripe
+    rbd import --stripe-count 1000 --stripe-unit 4096 ${TMPDIR}/img testimg
+    rbd export --export-format 2 testimg ${TMPDIR}/img_v2
+    rbd import --export-format 2 ${TMPDIR}/img_v2 testimg_import
+    rbd info testimg_import|grep "stripe unit"|grep -Ei '(4 KiB|4K|4096)'
+    rbd info testimg_import|grep "stripe count"|awk '{print $3}'|grep 1000
 
-rm ${TMPDIR}/img_v2
+    rm ${TMPDIR}/img_v2
 
-rbd remove testimg_import
-rbd remove testimg
+    rbd remove testimg_import
+    rbd remove testimg
+fi
 
 tiered=0
 if ceph osd dump | grep ^pool | grep "'rbd'" | grep tier; then
@@ -156,7 +162,7 @@ dd if=/dev/urandom bs=1M count=1 of=${TMPDIR}/sparse2; truncate ${TMPDIR}/sparse
 # 1M sparse, 1M data
 rbd rm sparse1 || true
 rbd import $RBD_CREATE_ARGS --order 20 ${TMPDIR}/sparse1
-rbd ls -l | grep sparse1 | grep -i '2048k'
+rbd ls -l | grep sparse1 | grep -Ei '(2 MiB|2M|2048k)'
 [ $tiered -eq 1 -o "$(objects sparse1)" = '1' ]
 
 # export, compare contents and on-disk size
@@ -168,7 +174,7 @@ rbd rm sparse1
 # 1M data, 1M sparse
 rbd rm sparse2 || true
 rbd import $RBD_CREATE_ARGS --order 20 ${TMPDIR}/sparse2
-rbd ls -l | grep sparse2 | grep -i '2048k'
+rbd ls -l | grep sparse2 | grep -Ei '(2 MiB|2M|2048k)'
 [ $tiered -eq 1 -o "$(objects sparse2)" = '0' ]
 rbd export sparse2 ${TMPDIR}/sparse2.out
 compare_files_and_ondisk_sizes ${TMPDIR}/sparse2 ${TMPDIR}/sparse2.out
@@ -179,7 +185,7 @@ rbd rm sparse2
 truncate ${TMPDIR}/sparse1 -s 10M
 # import from stdin just for fun, verify still sparse
 rbd import $RBD_CREATE_ARGS --order 20 - sparse1 < ${TMPDIR}/sparse1
-rbd ls -l | grep sparse1 | grep -i '10240k'
+rbd ls -l | grep sparse1 | grep -Ei '(10 MiB|10M|10240k)'
 [ $tiered -eq 1 -o "$(objects sparse1)" = '1' ]
 rbd export sparse1 ${TMPDIR}/sparse1.out
 compare_files_and_ondisk_sizes ${TMPDIR}/sparse1 ${TMPDIR}/sparse1.out
@@ -190,7 +196,7 @@ rbd rm sparse1
 dd if=/dev/urandom bs=2M count=1 of=${TMPDIR}/sparse2 oflag=append conv=notrunc
 # again from stding
 rbd import $RBD_CREATE_ARGS --order 20 - sparse2 < ${TMPDIR}/sparse2
-rbd ls -l | grep sparse2 | grep -i '4096k'
+rbd ls -l | grep sparse2 | grep -Ei '(4 MiB|4M|4096k)'
 [ $tiered -eq 1 -o "$(objects sparse2)" = '0 2 3' ]
 rbd export sparse2 ${TMPDIR}/sparse2.out
 compare_files_and_ondisk_sizes ${TMPDIR}/sparse2 ${TMPDIR}/sparse2.out