diff mbox

[V3,7/7] qemu-iotests: add test for qcow2 snapshot

Message ID 1378695482-29805-8-git-send-email-xiawenc@linux.vnet.ibm.com
State New
Headers show

Commit Message

Wayne Xia Sept. 9, 2013, 2:58 a.m. UTC
This test will focus on the low level procedure of qcow2 snapshot
operations, now it covers only the create operation. Overlap error
paths are not checked since no good way to trigger those errors.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 tests/qemu-iotests/063     |  229 ++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/063.out |   37 +++++++
 tests/qemu-iotests/group   |    1 +
 3 files changed, 267 insertions(+), 0 deletions(-)
 create mode 100755 tests/qemu-iotests/063
 create mode 100644 tests/qemu-iotests/063.out

Comments

Eric Blake Sept. 30, 2013, 10:28 p.m. UTC | #1
On 09/08/2013 08:58 PM, Wenchao Xia wrote:
> This test will focus on the low level procedure of qcow2 snapshot
> operations, now it covers only the create operation. Overlap error
> paths are not checked since no good way to trigger those errors.
> 
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
>  tests/qemu-iotests/063     |  229 ++++++++++++++++++++++++++++++++++++++++++++
>  tests/qemu-iotests/063.out |   37 +++++++
>  tests/qemu-iotests/group   |    1 +
>  3 files changed, 267 insertions(+), 0 deletions(-)
>  create mode 100755 tests/qemu-iotests/063
>  create mode 100644 tests/qemu-iotests/063.out
> 

> +# only test qcow2
> +_supported_fmt qcow2
> +_supported_proto generic
> +_supported_os Linux
> +
> +IMGOPTS="compat=1.1"
> +
> +CLUSTER_SIZE=65536
> +
> +SIZE=1G
> +
> +BLKDBG_TEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG"
> +
> +errno=5

Not all platforms have errno 5 tied to EIO; but then again, you filtered
this test to run only on Linux.  Is it possible to be a bit more
generic, though?

At any rate, more tests are always good.  I didn't read very closely;
but I also didn't see anything obviously wrong with the patch, and it is
self-validating whether the testsuite still passes after applying it.
So feel free to add:

Reviewed-by: Eric Blake <eblake@redhat.com>
Wayne Xia Oct. 14, 2013, 7:48 a.m. UTC | #2
于 2013/10/1 6:28, Eric Blake 写道:
> On 09/08/2013 08:58 PM, Wenchao Xia wrote:
>> This test will focus on the low level procedure of qcow2 snapshot
>> operations, now it covers only the create operation. Overlap error
>> paths are not checked since no good way to trigger those errors.
>>
>> Signed-off-by: Wenchao Xia<xiawenc@linux.vnet.ibm.com>
>> ---
>>   tests/qemu-iotests/063     |  229 ++++++++++++++++++++++++++++++++++++++++++++
>>   tests/qemu-iotests/063.out |   37 +++++++
>>   tests/qemu-iotests/group   |    1 +
>>   3 files changed, 267 insertions(+), 0 deletions(-)
>>   create mode 100755 tests/qemu-iotests/063
>>   create mode 100644 tests/qemu-iotests/063.out
>>
>> +# only test qcow2
>> +_supported_fmt qcow2
>> +_supported_proto generic
>> +_supported_os Linux
>> +
>> +IMGOPTS="compat=1.1"
>> +
>> +CLUSTER_SIZE=65536
>> +
>> +SIZE=1G
>> +
>> +BLKDBG_TEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG"
>> +
>> +errno=5
> Not all platforms have errno 5 tied to EIO; but then again, you filtered
> this test to run only on Linux.  Is it possible to be a bit more
> generic, though?
>
   I think the test can be made more generic, but it is a bit hard for 
me to find out
what number should be used on all platform now. Instead, I'd like to add 
a comments
here:"bind the errno correctly if you want run this case on other platform".

> At any rate, more tests are always good.  I didn't read very closely;
> but I also didn't see anything obviously wrong with the patch, and it is
> self-validating whether the testsuite still passes after applying it.
> So feel free to add:
>
> Reviewed-by: Eric Blake<eblake@redhat.com>
>
diff mbox

Patch

diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063
new file mode 100755
index 0000000..f3f6e16
--- /dev/null
+++ b/tests/qemu-iotests/063
@@ -0,0 +1,229 @@ 
+#!/bin/bash
+#
+# qcow2 internal snapshot test
+#
+# Copyright (C) 2013 IBM, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+owner=xiawenc@linux.vnet.ibm.com
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+
+_cleanup()
+{
+    _cleanup_test_img
+    rm $TEST_DIR/blkdebug.conf
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+. ./common.pattern
+
+# only test qcow2
+_supported_fmt qcow2
+_supported_proto generic
+_supported_os Linux
+
+IMGOPTS="compat=1.1"
+
+CLUSTER_SIZE=65536
+
+SIZE=1G
+
+BLKDBG_TEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG"
+
+errno=5
+
+once=on
+
+imm=off
+
+
+# Start test, note that the injected errors are related to qcow2's snapshot
+# logic closely, see qcow2-snapshot.c for more details.
+
+# path 1: fail in L1 table allocation for snapshot
+echo
+echo "Path 1: fail in allocation of L1 table"
+
+_make_test_img $SIZE
+
+cat > $TEST_DIR/blkdebug.conf <<EOF
+[inject-error]
+event = "cluster_alloc"
+errno = "$errno"
+immediately = "$imm"
+once = "$once"
+EOF
+
+$QEMU_IMG snapshot -c snap1 $BLKDBG_TEST_IMG
+$QEMU_IMG snapshot -l $TEST_IMG
+_check_test_img 2>&1
+
+
+# path 2: fail in update new L1 table
+echo
+echo "Path 2: fail in overlap check before update L1 table for snapshot"
+
+_make_test_img $SIZE
+
+cat > $TEST_DIR/blkdebug.conf <<EOF
+[inject-error]
+event = "snapshot_l1_update"
+errno = "$errno"
+immediately = "$imm"
+once = "$once"
+EOF
+
+$QEMU_IMG snapshot -c snap1 $BLKDBG_TEST_IMG
+$QEMU_IMG snapshot -l $TEST_IMG
+_check_test_img 2>&1
+
+# path 3: fail in update refcount block before write snapshot list
+echo
+echo "Path 3: fail in update refcount block before write snapshot list"
+
+_make_test_img $SIZE
+
+cat > $TEST_DIR/blkdebug.conf <<EOF
+[inject-error]
+event = "refblock_alloc"
+errno = "$errno"
+immediately = "$imm"
+once = "$once"
+EOF
+
+$QEMU_IMG snapshot -c snap1 $BLKDBG_TEST_IMG
+$QEMU_IMG snapshot -l $TEST_IMG
+_check_test_img 2>&1
+
+# path 4: fail in snapshot list allocation, it is possible
+# qcow2_alloc_clusters() not fail immediately since cache hit, but in any
+# case, no error should be found in image check.
+echo
+echo "Path 4: fail in snapshot list allocation"
+
+_make_test_img $SIZE
+
+cat > $TEST_DIR/blkdebug.conf <<EOF
+[set-state]
+state = "1"
+event = "cluster_alloc"
+new_state = "2"
+
+[inject-error]
+state = "2"
+event = "cluster_alloc"
+errno = "$errno"
+immediately = "$imm"
+once = "$once"
+EOF
+
+$QEMU_IMG snapshot -c snap1 $BLKDBG_TEST_IMG
+$QEMU_IMG snapshot -l $TEST_IMG
+_check_test_img 2>&1
+
+# path 5: fail in flush after snapshot list allocation, flush is related with
+# cache status, if no cache available then the flush may not trigger a error
+# in bdrv_flush(), but no error should be found in image check.
+echo
+echo "Path 5: fail in flush after snapshot list allocation"
+
+_make_test_img $SIZE
+
+cat > $TEST_DIR/blkdebug.conf <<EOF
+[set-state]
+state = "1"
+event = "cluster_alloc"
+new_state = "2"
+
+[set-state]
+state = "2"
+event = "cluster_alloc"
+new_state = "3"
+
+[inject-error]
+state = "3"
+event = "flush_to_os"
+errno = "$errno"
+immediately = "$imm"
+once = "$once"
+
+[set-state]
+state = "3"
+event = "flush_to_os"
+new_state = "4"
+EOF
+
+$QEMU_IMG snapshot -c snap1 $BLKDBG_TEST_IMG
+$QEMU_IMG snapshot -l $TEST_IMG
+_check_test_img 2>&1
+
+# path 6: fail in snapshot list update
+echo
+echo "Path 6: fail in snapshot list update"
+
+_make_test_img $SIZE
+
+cat > $TEST_DIR/blkdebug.conf <<EOF
+[inject-error]
+event = "snapshot_list_update"
+errno = "$errno"
+immediately = "$imm"
+once = "$once"
+EOF
+
+$QEMU_IMG snapshot -c snap1 $BLKDBG_TEST_IMG
+$QEMU_IMG snapshot -l $TEST_IMG
+_check_test_img 2>&1
+
+# path 7: fail in flush after snapshot list update, no good way to trigger it,
+# since the cache is empty and makes flush do nothing in that call, so leave
+# this path not tested
+
+# path 8: fail in update qcow2 header
+echo
+echo "Path 8: fail in update qcow2 header"
+
+_make_test_img $SIZE
+
+cat > $TEST_DIR/blkdebug.conf <<EOF
+[inject-error]
+event = "snapshot_header_update"
+errno = "$errno"
+immediately = "$imm"
+once = "$once"
+EOF
+
+$QEMU_IMG snapshot -c snap1 $BLKDBG_TEST_IMG
+$QEMU_IMG snapshot -l $TEST_IMG
+_check_test_img 2>&1
+
+# path 9: fail in overlap check before update L1 table for snapshot
+# path 10: fail in overlap check before update snapshot list
+# Since those clusters are allocated at runtime, there is no good way to
+# make them overlap in this script, so skip those two paths now.
+
+# success, all done
+echo "*** done"
+rm -f $seq.full
+status=0
diff --git a/tests/qemu-iotests/063.out b/tests/qemu-iotests/063.out
new file mode 100644
index 0000000..c387bfa
--- /dev/null
+++ b/tests/qemu-iotests/063.out
@@ -0,0 +1,37 @@ 
+QA output created by 063
+
+Path 1: fail in allocation of L1 table
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
+qemu-img: Could not create snapshot 'snap1': -5 (Input/output error)
+No errors were found on the image.
+
+Path 2: fail in overlap check before update L1 table for snapshot
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
+qemu-img: Could not create snapshot 'snap1': -5 (Input/output error)
+No errors were found on the image.
+
+Path 3: fail in update refcount block before write snapshot list
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
+qemu-img: Could not create snapshot 'snap1': -5 (Input/output error)
+No errors were found on the image.
+
+Path 4: fail in snapshot list allocation
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
+qemu-img: Could not create snapshot 'snap1': -5 (Input/output error)
+No errors were found on the image.
+
+Path 5: fail in flush after snapshot list allocation
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
+qemu-img: Could not create snapshot 'snap1': -5 (Input/output error)
+No errors were found on the image.
+
+Path 6: fail in snapshot list update
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
+qemu-img: Could not create snapshot 'snap1': -5 (Input/output error)
+No errors were found on the image.
+
+Path 8: fail in update qcow2 header
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
+qemu-img: Could not create snapshot 'snap1': -5 (Input/output error)
+No errors were found on the image.
+*** done
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index b696242..316b1dd 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -66,3 +66,4 @@ 
 059 rw auto
 060 rw auto
 062 rw auto
+063 rw auto