From patchwork Wed Oct 16 16:28:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Shinkevich X-Patchwork-Id: 1178030 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46tdF92hQRz9sP3 for ; Thu, 17 Oct 2019 03:35:09 +1100 (AEDT) Received: from localhost ([::1]:45422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKmGR-0006WQ-75 for incoming@patchwork.ozlabs.org; Wed, 16 Oct 2019 12:35:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34115) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKmAf-0002X9-Sm for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:29:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKmAe-00083l-B1 for qemu-devel@nongnu.org; Wed, 16 Oct 2019 12:29:09 -0400 Received: from relay.sw.ru ([185.231.240.75]:51314) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iKmAe-00081Q-2w; Wed, 16 Oct 2019 12:29:08 -0400 Received: from [172.16.25.136] (helo=dhcp-172-16-25-136.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.2) (envelope-from ) id 1iKmAZ-0002B1-Av; Wed, 16 Oct 2019 19:29:03 +0300 From: Andrey Shinkevich To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [PATCH v4 4/4] tests/qemu-iotests: add case for block-stream compress Date: Wed, 16 Oct 2019 19:28:53 +0300 Message-Id: <1571243333-882302-5-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1571243333-882302-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1571243333-882302-1-git-send-email-andrey.shinkevich@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add a case to the iotest #030 that tests the 'compress' option for a block-stream job. Signed-off-by: Andrey Shinkevich --- tests/qemu-iotests/030 | 51 +++++++++++++++++++++++++++++++++++++++++++++- tests/qemu-iotests/030.out | 4 ++-- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index f3766f2..f0f0e26 100755 --- a/tests/qemu-iotests/030 +++ b/tests/qemu-iotests/030 @@ -21,7 +21,8 @@ import time import os import iotests -from iotests import qemu_img, qemu_io +from iotests import qemu_img, qemu_io, qemu_img_pipe +import json backing_img = os.path.join(iotests.test_dir, 'backing.img') mid_img = os.path.join(iotests.test_dir, 'mid.img') @@ -956,6 +957,54 @@ class TestSetSpeed(iotests.QMPTestCase): self.cancel_and_wait(resume=True) +class TestCompressed(iotests.QMPTestCase): + test_img_init_size = 0 + + def setUp(self): + qemu_img('create', '-f', iotests.imgfmt, backing_img, '1M') + qemu_img('create', '-f', iotests.imgfmt, '-o', + 'backing_file=%s' % backing_img, mid_img) + qemu_img('create', '-f', iotests.imgfmt, '-o', + 'backing_file=%s' % mid_img, test_img) + qemu_io('-c', 'write -P 0x1 0 512k', backing_img) + top = json.loads(qemu_img_pipe('info', '--output=json', test_img)) + self.test_img_init_size = top['actual-size'] + self.vm = iotests.VM().add_drive(test_img, "backing.node-name=mid," + + "backing.backing.node-name=base," + + "compress=on") + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + os.remove(test_img) + os.remove(mid_img) + os.remove(backing_img) + + def test_stream_compress(self): + self.assert_no_active_block_jobs() + + result = self.vm.qmp('block-stream', device='mid', job_id='stream-mid') + self.assert_qmp(result, 'return', {}) + + self.wait_until_completed(drive='stream-mid') + # Remove other 'JOB_STATUS_CHANGE' events for the job 'stream-mid' + self.vm.get_qmp_events(wait=True) + + result = self.vm.qmp('block-stream', device='drive0', + job_id='stream-top') + self.assert_qmp(result, 'return', {}) + + self.wait_until_completed(drive='stream-top') + self.vm.shutdown() + + top = json.loads(qemu_img_pipe('info', '--output=json', test_img)) + mid = json.loads(qemu_img_pipe('info', '--output=json', mid_img)) + base = json.loads(qemu_img_pipe('info', '--output=json', backing_img)) + + self.assertEqual(mid['actual-size'], base['actual-size']) + self.assertLess(top['actual-size'], mid['actual-size']) + self.assertLess(self.test_img_init_size, top['actual-size']) + if __name__ == '__main__': iotests.main(supported_fmts=['qcow2', 'qed'], supported_protocols=['file']) diff --git a/tests/qemu-iotests/030.out b/tests/qemu-iotests/030.out index 6d9bee1..af8dac1 100644 --- a/tests/qemu-iotests/030.out +++ b/tests/qemu-iotests/030.out @@ -1,5 +1,5 @@ -........................... +............................ ---------------------------------------------------------------------- -Ran 27 tests +Ran 28 tests OK