From patchwork Wed May 15 14:34:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 244094 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8204F2C0087 for ; Thu, 16 May 2013 00:36:24 +1000 (EST) Received: from localhost ([::1]:59846 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UccoY-0007zi-Gx for incoming@patchwork.ozlabs.org; Wed, 15 May 2013 10:36:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ucco6-0007vP-DH for qemu-devel@nongnu.org; Wed, 15 May 2013 10:36:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uccnz-00006k-N8 for qemu-devel@nongnu.org; Wed, 15 May 2013 10:35:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1989) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uccnz-00006b-4G for qemu-devel@nongnu.org; Wed, 15 May 2013 10:35:47 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4FEZ1t0005444 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 15 May 2013 10:35:02 -0400 Received: from localhost (dhcp-64-106.muc.redhat.com [10.32.64.106]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r4FEZ0id017305; Wed, 15 May 2013 10:35:01 -0400 From: Stefan Hajnoczi To: Date: Wed, 15 May 2013 16:34:36 +0200 Message-Id: <1368628476-19622-9-git-send-email-stefanha@redhat.com> In-Reply-To: <1368628476-19622-1-git-send-email-stefanha@redhat.com> References: <1368628476-19622-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Fam Zheng , dietmar@proxmox.com, imain@redhat.com, Stefan Hajnoczi , Paolo Bonzini , xiawenc@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v3 8/8] qemu-iotests: test 'drive-backup' transaction in 055 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Ensure that the 'drive-backup' transaction works and check that a transaction abort works properly. Signed-off-by: Stefan Hajnoczi --- tests/qemu-iotests/055 | 118 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/055.out | 4 +- 2 files changed, 120 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/055 b/tests/qemu-iotests/055 index bc2eebf..d61993f 100755 --- a/tests/qemu-iotests/055 +++ b/tests/qemu-iotests/055 @@ -226,5 +226,123 @@ class TestSetSpeed(DriveBackupTestCase): self.cancel_and_wait() +class TestSingleTransaction(DriveBackupTestCase): + image_len = 120 * 1024 * 1024 # MB + + def setUp(self): + qemu_img('create', '-f', iotests.imgfmt, test_img, str(TestSingleDrive.image_len)) + self.vm = iotests.VM().add_drive(test_img) + self.vm.launch() + + def tearDown(self): + self.vm.shutdown() + os.remove(test_img) + try: + os.remove(target_img) + except OSError: + pass + + def test_complete(self): + self.assert_no_active_backups() + + result = self.vm.qmp('transaction', actions=[{ + 'type': 'drive-backup', + 'data': { 'device': 'drive0', + 'target': target_img }, + } + ]) + self.assert_qmp(result, 'return', {}) + + self.complete_and_wait() + self.vm.shutdown() + self.assertTrue(self.compare_images(test_img, target_img), + 'target image does not match source after backup') + + def test_cancel(self): + self.assert_no_active_backups() + + result = self.vm.qmp('transaction', actions=[{ + 'type': 'drive-backup', + 'data': { 'device': 'drive0', + 'target': target_img }, + } + ]) + self.assert_qmp(result, 'return', {}) + + self.cancel_and_wait() + + def test_pause(self): + self.assert_no_active_backups() + + result = self.vm.qmp('transaction', actions=[{ + 'type': 'drive-backup', + 'data': { 'device': 'drive0', + 'target': target_img }, + } + ]) + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('block-job-pause', device='drive0') + self.assert_qmp(result, 'return', {}) + + time.sleep(1) + result = self.vm.qmp('query-block-jobs') + offset = self.dictpath(result, 'return[0]/offset') + + time.sleep(1) + result = self.vm.qmp('query-block-jobs') + self.assert_qmp(result, 'return[0]/offset', offset) + + result = self.vm.qmp('block-job-resume', device='drive0') + self.assert_qmp(result, 'return', {}) + + self.complete_and_wait() + self.vm.shutdown() + self.assertTrue(self.compare_images(test_img, target_img), + 'target image does not match source after backup') + + def test_medium_not_found(self): + result = self.vm.qmp('transaction', actions=[{ + 'type': 'drive-backup', + 'data': { 'device': 'ide1-cd0', + 'target': target_img }, + } + ]) + self.assert_qmp(result, 'error/class', 'GenericError') + + def test_image_not_found(self): + result = self.vm.qmp('transaction', actions=[{ + 'type': 'drive-backup', + 'data': { 'device': 'drive0', + 'mode': 'existing', + 'target': target_img }, + } + ]) + self.assert_qmp(result, 'error/class', 'GenericError') + + def test_device_not_found(self): + result = self.vm.qmp('transaction', actions=[{ + 'type': 'drive-backup', + 'data': { 'device': 'nonexistent', + 'mode': 'existing', + 'target': target_img }, + } + ]) + self.assert_qmp(result, 'error/class', 'DeviceNotFound') + + def test_abort(self): + result = self.vm.qmp('transaction', actions=[{ + 'type': 'drive-backup', + 'data': { 'device': 'nonexistent', + 'mode': 'existing', + 'target': target_img }, + }, { + 'type': 'Abort', + 'data': {}, + } + ]) + self.assert_qmp(result, 'error/class', 'GenericError') + self.assert_no_active_backups() + if __name__ == '__main__': iotests.main(supported_fmts=['raw', 'qcow2']) diff --git a/tests/qemu-iotests/055.out b/tests/qemu-iotests/055.out index 594c16f..96961ed 100644 --- a/tests/qemu-iotests/055.out +++ b/tests/qemu-iotests/055.out @@ -1,5 +1,5 @@ -........ +............... ---------------------------------------------------------------------- -Ran 8 tests +Ran 15 tests OK