[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH V5 6/6] qemu-iotests: add test for qcow2 snapsho
From: |
Jeff Cody |
Subject: |
Re: [Qemu-devel] [PATCH V5 6/6] qemu-iotests: add test for qcow2 snapshot |
Date: |
Fri, 8 Nov 2013 15:50:45 -0500 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Tue, Nov 05, 2013 at 08:01:29AM +0800, 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 <address@hidden>
> ---
> tests/qemu-iotests/070 | 214
> ++++++++++++++++++++++++++++++++++++++
> tests/qemu-iotests/070.out | 35 ++++++
> tests/qemu-iotests/common.filter | 7 ++
> tests/qemu-iotests/group | 1 +
> 4 files changed, 257 insertions(+), 0 deletions(-)
> create mode 100755 tests/qemu-iotests/070
> create mode 100644 tests/qemu-iotests/070.out
>
> diff --git a/tests/qemu-iotests/070 b/tests/qemu-iotests/070
> new file mode 100755
> index 0000000..37ada84
> --- /dev/null
> +++ b/tests/qemu-iotests/070
> @@ -0,0 +1,214 @@
> +#!/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/>.
> +#
> address@hidden
> +
> +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
$TEST_DIR needs quoting (also in later uses in this file as well)
> +}
> +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
> +# bind the errno correctly and filter the output of image check and qemu-img,
> +# if you want to run it on other OS
> +_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
Both $BLKDB_TEST_IMG and $TEST_IMG need quoting (also in later uses in
this file)
> +_check_test_img 2>&1
> +
> +
> +# path 2: fail in update new L1 table
> +echo
> +echo "Path 2: fail in update new 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 2>&1 | _filter_number
> +$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
> +[set-state]
> +state = "1"
> +event = "snapshot_l1_update"
> +new_state = "2"
> +
> +[inject-error]
> +state = "2"
> +event = "refblock_update_part"
> +errno = "$errno"
> +immediately = "$imm"
> +once = "$once"
> +
> +[set-state]
> +state = "2"
> +event = "refblock_alloc"
> +new_state = "3"
> +EOF
> +
> +$QEMU_IMG snapshot -c snap1 $BLKDBG_TEST_IMG 2>&1 | _filter_number
> +$QEMU_IMG snapshot -l $TEST_IMG
> +_check_test_img 2>&1
> +
> +# path 4: fail in snapshot list allocation or its flush 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 or its flush"
> +
> +_make_test_img $SIZE
> +
> +cat > $TEST_DIR/blkdebug.conf <<EOF
> +[set-state]
> +state = "1"
> +event = "snapshot_l1_update"
> +new_state = "2"
> +
> +[inject-error]
> +state = "2"
> +event = "cluster_alloc"
> +errno = "$errno"
> +immediately = "$imm"
> +once = "$once"
> +EOF
> +
> +# fail directly or in flush, are both OK.
> +err=`$QEMU_IMG snapshot -c snap1 $BLKDBG_TEST_IMG 2>&1 | grep "Failed" |
> grep "allocation" | grep "list"`
> +if ! test -z "$err"
> +then
> + echo "Error happens as expected"
> +fi
> +$QEMU_IMG snapshot -l $TEST_IMG
> +_check_test_img 2>&1
> +
> +
> +# path 5: fail in snapshot list update
> +echo
> +echo "Path 5: 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 2>&1 | _filter_number
> +$QEMU_IMG snapshot -l $TEST_IMG
> +_check_test_img 2>&1
> +
> +# path 6: 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 7: fail in update qcow2 header, it would have leaked cluster since not
> +# discard the allocated ones for safe reason, see qcow2-snapshot.c.
> +echo
> +echo "Path 7: 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 2>&1 | _filter_number
> +$QEMU_IMG snapshot -l $TEST_IMG
> +_check_test_img 2>&1 | _filter_number
> +
> +# path 8: fail in overlap check before update L1 table for snapshot
> +# path 9: 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/070.out b/tests/qemu-iotests/070.out
> new file mode 100644
> index 0000000..1969e3f
> --- /dev/null
> +++ b/tests/qemu-iotests/070.out
> @@ -0,0 +1,35 @@
> +QA output created by 070
> +
> +Path 1: fail in allocation of L1 table
> +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
> +qemu-img: Could not create snapshot 'snap1': Failed in allocation of
> snapshot L1 table: Input/output error
> +No errors were found on the image.
> +
> +Path 2: fail in update new L1 table for snapshot
> +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
> +qemu-img: Could not create snapshot 'snap1': Failed in update of snapshot L1
> table at X with size X: 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': Failed in update of refcount
> for snapshot at X with size X: Input/output error
> +No errors were found on the image.
> +
> +Path 4: fail in snapshot list allocation or its flush
> +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
> +Error happens as expected
> +No errors were found on the image.
> +
> +Path 5: fail in snapshot list update
> +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
> +qemu-img: Could not create snapshot 'snap1': Failed in write of snapshot
> header at X with size X: Input/output error
> +No errors were found on the image.
> +
> +Path 7: fail in update qcow2 header
> +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824
> +qemu-img: Could not create snapshot 'snap1': Failed in update of image
> header at X with size X: Input/output error
> +Leaked cluster X refcount=X reference=X
> +
> +1 leaked clusters were found on the image.
> +This means waste of disk space, but no harm to data.
> +*** done
> diff --git a/tests/qemu-iotests/common.filter
> b/tests/qemu-iotests/common.filter
> index 8e7b1a4..e8eba65 100644
> --- a/tests/qemu-iotests/common.filter
> +++ b/tests/qemu-iotests/common.filter
> @@ -146,6 +146,13 @@ _filter_win32()
> sed -e 's/\r//g'
> }
>
> +# replace number with X
> +_filter_number()
> +{
> + sed -e 's/ \([0-9]\+\)/ X/g' \
> + -e 's/=\([0-9]\+\)/=X/g'
> +}
> +
> # sanitize qemu-io output
> _filter_qemu_io()
> {
> diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
> index c57ff35..b18b241 100644
> --- a/tests/qemu-iotests/group
> +++ b/tests/qemu-iotests/group
> @@ -75,3 +75,4 @@
> 067 rw auto
> 068 rw auto
> 069 rw auto
> +070 rw auto
> --
> 1.7.1
>
>
- [Qemu-devel] [PATCH V5 0/6] qcow2: rollback the modification on fail in snapshot creation, Wenchao Xia, 2013/11/05
- [Qemu-devel] [PATCH V5 3/6] qcow2: do not free clusters when fail in header update in qcow2_write_snapshots, Wenchao Xia, 2013/11/05
- [Qemu-devel] [PATCH V5 6/6] qemu-iotests: add test for qcow2 snapshot, Wenchao Xia, 2013/11/05
- [Qemu-devel] [PATCH V5 4/6] qcow2: cancel the modification on fail in qcow2_snapshot_create(), Wenchao Xia, 2013/11/05
- [Qemu-devel] [PATCH V5 2/6] qcow2: add error message in qcow2_write_snapshots(), Wenchao Xia, 2013/11/05
- [Qemu-devel] [PATCH V5 1/6] snapshot: add parameter *errp in snapshot create, Wenchao Xia, 2013/11/05
- [Qemu-devel] [PATCH V5 5/6] blkdebug: add debug events for snapshot, Wenchao Xia, 2013/11/05