]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test: Adding testing of shard with incorrect size
authorDavid Zafman <dzafman@redhat.com>
Wed, 29 Jul 2015 03:27:16 +0000 (20:27 -0700)
committerDavid Zafman <dzafman@redhat.com>
Thu, 27 Aug 2015 21:03:22 +0000 (14:03 -0700)
Signed-off-by: David Zafman <dzafman@redhat.com>
src/test/erasure-code/test-erasure-eio.sh

index 769ff1f6c3e44809bd1246469d95b0b7e3e0777c..7a1c0c0c171d7b99ab44900d0a1726eaf93dae36 100755 (executable)
@@ -164,6 +164,38 @@ function rados_get_data_eio() {
     rados_put_get $dir $poolname $objname 1 $recovery || return 1
 }
 
+function rados_get_data_bad_size() {
+    local dir=$1
+    shift
+    local shard_id=$1
+    shift
+    local bytes=$1
+    shift
+    local mode=${1:-set}
+
+    # inject eio to speificied shard
+    #
+    local poolname=pool-jerasure
+    local objname=obj-size-$$-$shard_id-$bytes
+    local -a initial_osds=($(get_osds $poolname $objname))
+    local osd_id=${initial_osds[$shard_id]}
+    local last=$((${#initial_osds[@]} - 1))
+    rados_put $dir $poolname $objname || return 1
+    if [ "$mode" = "add" ];
+    then
+      objectstore_tool $dir $osd_id $objname get-bytes $dir/CORRUPT || return 1
+      dd if=/dev/urandom bs=$bytes count=1 >> $dir/CORRUPT
+    elif [ "$bytes" = "0" ];
+    then
+      touch $dir/CORRUPT
+    else
+      dd if=/dev/urandom bs=$bytes count=1 of=$dir/CORRUPT
+    fi
+    objectstore_tool $dir $osd_id $objname set-bytes $dir/CORRUPT || return 1
+    rm -f $dir/CORRUPT
+    rados_get $dir $poolname $objname 1 || return 1
+}
+
 #
 # These two test cases try to validate the following behavior:
 #  For object on EC pool, if there is one shard having read error (
@@ -193,6 +225,32 @@ function TEST_rados_get_subread_eio_shard_1() {
     delete_pool $poolname
 }
 
+function TEST_rados_get_bad_size_shard_0() {
+    local dir=$1
+    setup_osds false || return 1
+
+    local poolname=pool-jerasure
+    create_erasure_coded_pool $poolname || return 1
+    local shard_id=0
+    rados_get_data_bad_size $dir $shard_id 10 || return 1
+    rados_get_data_bad_size $dir $shard_id 0 || return 1
+    rados_get_data_bad_size $dir $shard_id 256 add || return 1
+    delete_pool $poolname
+}
+
+function TEST_rados_get_bad_size_shard_1() {
+    local dir=$1
+    setup_osds false || return 1
+
+    local poolname=pool-jerasure
+    create_erasure_coded_pool $poolname || return 1
+    local shard_id=1
+    rados_get_data_bad_size $dir $shard_id 10 || return 1
+    rados_get_data_bad_size $dir $shard_id 0 || return 1
+    rados_get_data_bad_size $dir $shard_id 256 add || return 1
+    delete_pool $poolname
+}
+
 : <<'DISABLED_TESTS'
 # this test case is aimed to test the fix of https://github.com/ceph/ceph/pull/2952
 # this test case can test both client read and recovery read on EIO