diff mbox series

[2/2] iotests: test mirroring qcow2 under raw format

Message ID 20190812181146.26121-3-vsementsov@virtuozzo.com (mailing list archive)
State New, archived
Headers show
Series deal with BDRV_BLOCK_RAW | expand

Commit Message

Vladimir Sementsov-Ogievskiy Aug. 12, 2019, 6:11 p.m. UTC
Check that it is fixed by previous commit

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 tests/qemu-iotests/263     | 46 ++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/263.out | 12 ++++++++++
 tests/qemu-iotests/group   |  1 +
 3 files changed, 59 insertions(+)
 create mode 100755 tests/qemu-iotests/263
 create mode 100644 tests/qemu-iotests/263.out

Comments

Kevin Wolf Aug. 13, 2019, 9:10 a.m. UTC | #1
Am 12.08.2019 um 20:11 hat Vladimir Sementsov-Ogievskiy geschrieben:
> Check that it is fixed by previous commit
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  tests/qemu-iotests/263     | 46 ++++++++++++++++++++++++++++++++++++++
>  tests/qemu-iotests/263.out | 12 ++++++++++
>  tests/qemu-iotests/group   |  1 +
>  3 files changed, 59 insertions(+)
>  create mode 100755 tests/qemu-iotests/263
>  create mode 100644 tests/qemu-iotests/263.out
> 
> diff --git a/tests/qemu-iotests/263 b/tests/qemu-iotests/263
> new file mode 100755
> index 0000000000..dbe38e6c6c
> --- /dev/null
> +++ b/tests/qemu-iotests/263
> @@ -0,0 +1,46 @@
> +#!/usr/bin/env python
> +#
> +# Test mirroring qcow2 under raw-format
> +#
> +# Copyright (c) 2019 Virtuozzo International GmbH.
> +#
> +# 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/>.
> +#
> +
> +import iotests
> +from iotests import qemu_img_create, qemu_io, filter_qemu_io, file_path, log
> +
> +iotests.verify_image_format(supported_fmts=['qcow2'])
> +
> +base, top, target = file_path('base', 'top', 'target')
> +size = 1024 * 1024
> +
> +qemu_img_create('-f', iotests.imgfmt, base, str(size))
> +log(filter_qemu_io(qemu_io('-f', iotests.imgfmt,
> +                           '-c', 'write -P 1 0 1M', base)))
> +qemu_img_create('-f', iotests.imgfmt, '-b', base, top, str(size))

Who deletes these files at the end of the test? (There's a reason why
all the other test cases uses 'with FilePath(...)'.)

Kevin
Vladimir Sementsov-Ogievskiy Aug. 13, 2019, 9:22 a.m. UTC | #2
13.08.2019 12:10, Kevin Wolf wrote:
> Am 12.08.2019 um 20:11 hat Vladimir Sementsov-Ogievskiy geschrieben:
>> Check that it is fixed by previous commit
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> ---
>>   tests/qemu-iotests/263     | 46 ++++++++++++++++++++++++++++++++++++++
>>   tests/qemu-iotests/263.out | 12 ++++++++++
>>   tests/qemu-iotests/group   |  1 +
>>   3 files changed, 59 insertions(+)
>>   create mode 100755 tests/qemu-iotests/263
>>   create mode 100644 tests/qemu-iotests/263.out
>>
>> diff --git a/tests/qemu-iotests/263 b/tests/qemu-iotests/263
>> new file mode 100755
>> index 0000000000..dbe38e6c6c
>> --- /dev/null
>> +++ b/tests/qemu-iotests/263
>> @@ -0,0 +1,46 @@
>> +#!/usr/bin/env python
>> +#
>> +# Test mirroring qcow2 under raw-format
>> +#
>> +# Copyright (c) 2019 Virtuozzo International GmbH.
>> +#
>> +# 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/>.
>> +#
>> +
>> +import iotests
>> +from iotests import qemu_img_create, qemu_io, filter_qemu_io, file_path, log
>> +
>> +iotests.verify_image_format(supported_fmts=['qcow2'])
>> +
>> +base, top, target = file_path('base', 'top', 'target')
>> +size = 1024 * 1024
>> +
>> +qemu_img_create('-f', iotests.imgfmt, base, str(size))
>> +log(filter_qemu_io(qemu_io('-f', iotests.imgfmt,
>> +                           '-c', 'write -P 1 0 1M', base)))
>> +qemu_img_create('-f', iotests.imgfmt, '-b', base, top, str(size))
> 
> Who deletes these files at the end of the test? (There's a reason why
> all the other test cases uses 'with FilePath(...)'.)
> 

file_path sets corresponding handling, it's alternative to FilePath
Kevin Wolf Aug. 13, 2019, 9:36 a.m. UTC | #3
Am 13.08.2019 um 11:22 hat Vladimir Sementsov-Ogievskiy geschrieben:
> 13.08.2019 12:10, Kevin Wolf wrote:
> > Am 12.08.2019 um 20:11 hat Vladimir Sementsov-Ogievskiy geschrieben:
> >> Check that it is fixed by previous commit
> >>
> >> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> >> ---
> >>   tests/qemu-iotests/263     | 46 ++++++++++++++++++++++++++++++++++++++
> >>   tests/qemu-iotests/263.out | 12 ++++++++++
> >>   tests/qemu-iotests/group   |  1 +
> >>   3 files changed, 59 insertions(+)
> >>   create mode 100755 tests/qemu-iotests/263
> >>   create mode 100644 tests/qemu-iotests/263.out
> >>
> >> diff --git a/tests/qemu-iotests/263 b/tests/qemu-iotests/263
> >> new file mode 100755
> >> index 0000000000..dbe38e6c6c
> >> --- /dev/null
> >> +++ b/tests/qemu-iotests/263
> >> @@ -0,0 +1,46 @@
> >> +#!/usr/bin/env python
> >> +#
> >> +# Test mirroring qcow2 under raw-format
> >> +#
> >> +# Copyright (c) 2019 Virtuozzo International GmbH.
> >> +#
> >> +# 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/>.
> >> +#
> >> +
> >> +import iotests
> >> +from iotests import qemu_img_create, qemu_io, filter_qemu_io, file_path, log
> >> +
> >> +iotests.verify_image_format(supported_fmts=['qcow2'])
> >> +
> >> +base, top, target = file_path('base', 'top', 'target')
> >> +size = 1024 * 1024
> >> +
> >> +qemu_img_create('-f', iotests.imgfmt, base, str(size))
> >> +log(filter_qemu_io(qemu_io('-f', iotests.imgfmt,
> >> +                           '-c', 'write -P 1 0 1M', base)))
> >> +qemu_img_create('-f', iotests.imgfmt, '-b', base, top, str(size))
> > 
> > Who deletes these files at the end of the test? (There's a reason why
> > all the other test cases uses 'with FilePath(...)'.)
> > 
> 
> file_path sets corresponding handling, it's alternative to FilePath

Ah, I see it uses atexit. Thanks, I didn't know this feature yet.

Kevin
diff mbox series

Patch

diff --git a/tests/qemu-iotests/263 b/tests/qemu-iotests/263
new file mode 100755
index 0000000000..dbe38e6c6c
--- /dev/null
+++ b/tests/qemu-iotests/263
@@ -0,0 +1,46 @@ 
+#!/usr/bin/env python
+#
+# Test mirroring qcow2 under raw-format
+#
+# Copyright (c) 2019 Virtuozzo International GmbH.
+#
+# 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/>.
+#
+
+import iotests
+from iotests import qemu_img_create, qemu_io, filter_qemu_io, file_path, log
+
+iotests.verify_image_format(supported_fmts=['qcow2'])
+
+base, top, target = file_path('base', 'top', 'target')
+size = 1024 * 1024
+
+qemu_img_create('-f', iotests.imgfmt, base, str(size))
+log(filter_qemu_io(qemu_io('-f', iotests.imgfmt,
+                           '-c', 'write -P 1 0 1M', base)))
+qemu_img_create('-f', iotests.imgfmt, '-b', base, top, str(size))
+
+vm = iotests.VM().add_drive(None, opts='driver=raw,size=' + str(size) +
+                            ',file.driver=qcow2,file.file.filename=' + top)
+vm.launch()
+
+vm.qmp_log('drive-mirror', device='drive0', target=target, sync='full',
+           filters=[iotests.filter_qmp_testfiles])
+log(vm.event_wait('BLOCK_JOB_READY'), filters=[iotests.filter_qmp_event])
+vm.qmp_log('block-job-complete', device='drive0')
+vm.shutdown()
+
+log(filter_qemu_io(qemu_io('-f', 'raw', '-c', 'read -P 1 0 1M', target)))
+
+log('-- finish --') # avoid extra new-line at the end of .out file
diff --git a/tests/qemu-iotests/263.out b/tests/qemu-iotests/263.out
new file mode 100644
index 0000000000..65e5c812c6
--- /dev/null
+++ b/tests/qemu-iotests/263.out
@@ -0,0 +1,12 @@ 
+wrote 1048576/1048576 bytes at offset 0
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+{"execute": "drive-mirror", "arguments": {"device": "drive0", "sync": "full", "target": "TEST_DIR/PID-target"}}
+{"return": {}}
+{"data": {"device": "drive0", "len": 1048576, "offset": 1048576, "speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
+{"execute": "block-job-complete", "arguments": {"device": "drive0"}}
+{"return": {}}
+read 1048576/1048576 bytes at offset 0
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+-- finish --
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index f13e5f2e23..186a0220e5 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -271,3 +271,4 @@ 
 254 rw backing quick
 255 rw quick
 256 rw quick
+263 rw quick