From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: armbru@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com,
eblake@redhat.com, mreitz@redhat.com, kwolf@redhat.com,
vsementsov@virtuozzo.com, den@openvz.org
Subject: [Qemu-devel] [PATCH v2 6/6] iotest 201: new test for qmp nbd-server-remove
Date: Thu, 7 Dec 2017 18:51:02 +0300 [thread overview]
Message-ID: <20171207155102.66622-7-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20171207155102.66622-1-vsementsov@virtuozzo.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
tests/qemu-iotests/201 | 130 +++++++++++++++++++++++++++++++++++++++++++++
tests/qemu-iotests/201.out | 5 ++
tests/qemu-iotests/group | 1 +
3 files changed, 136 insertions(+)
create mode 100644 tests/qemu-iotests/201
create mode 100644 tests/qemu-iotests/201.out
diff --git a/tests/qemu-iotests/201 b/tests/qemu-iotests/201
new file mode 100644
index 0000000000..28d0324195
--- /dev/null
+++ b/tests/qemu-iotests/201
@@ -0,0 +1,130 @@
+#!/usr/bin/env python
+#
+# Tests for qmp command nbd-server-remove.
+#
+# Copyright (c) 2017 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 os
+import sys
+import iotests
+import time
+from iotests import qemu_img, qemu_io, filter_qemu_io, QemuIoInteractive
+
+nbd_port = '10900'
+nbd_uri = 'nbd+tcp://localhost:' + nbd_port + '/exp'
+disk = os.path.join(iotests.test_dir, 'disk')
+
+class TestNbdServerRemove(iotests.QMPTestCase):
+ def setUp(self):
+ qemu_img('create', '-f', iotests.imgfmt, disk, '1M')
+
+ self.vm = iotests.VM().add_drive(disk)
+ self.vm.launch()
+
+ address = {
+ 'type': 'inet',
+ 'data': {
+ 'host': 'localhost',
+ 'port': nbd_port
+ }
+ }
+
+ result = self.vm.qmp('nbd-server-start', addr=address)
+ self.assert_qmp(result, 'return', {})
+ result = self.vm.qmp('nbd-server-add', device='drive0', name='exp')
+ self.assert_qmp(result, 'return', {})
+
+ def tearDown(self):
+ self.vm.shutdown()
+ os.remove(disk)
+
+ def remove_export(self, name, force=None):
+ if force is None:
+ result = self.vm.qmp('nbd-server-remove', name=name)
+ else:
+ result = self.vm.qmp('nbd-server-remove', name=name, force=force)
+ self.assert_qmp(result, 'return', {})
+
+ def assertExportNotFound(self, name):
+ result = self.vm.qmp('nbd-server-remove', name=name)
+ self.assert_qmp(result, 'error/desc', "Export 'exp' is not found")
+
+ def assertReadOk(self, qemu_io_output):
+ self.assertEqual(filter_qemu_io(qemu_io_output).strip(),
+ 'read 512/512 bytes at offset 0\n' +
+ '512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)')
+
+ def assertReadFailed(self, qemu_io_output):
+ self.assertEqual(filter_qemu_io(qemu_io_output).strip(),
+ 'read failed: Input/output error')
+
+ def assertConnectFailed(self, qemu_io_output):
+ self.assertEqual(filter_qemu_io(qemu_io_output).strip(),
+ "can't open device nbd+tcp://localhost:10900/exp: " +
+ "Requested export not available\nserver reported: " +
+ "export 'exp' not present")
+
+ def do_test_connect_after_remove(self, force=None):
+ args = ('-r', '-f', 'raw', '-c', 'read 0 512', nbd_uri)
+ self.assertReadOk(qemu_io(*args))
+ self.remove_export('exp', force)
+ self.assertExportNotFound('exp')
+ self.assertConnectFailed(qemu_io(*args))
+
+ def test_connect_after_remove_default(self):
+ self.do_test_connect_after_remove()
+
+ def test_connect_after_remove_safe(self):
+ self.do_test_connect_after_remove(False)
+
+ def test_connect_after_remove_force(self):
+ self.do_test_connect_after_remove(True)
+
+ def do_test_remove_during_connect(self, force=None):
+ qio = QemuIoInteractive('-r', '-f', 'raw', nbd_uri)
+ self.assertReadOk(qio.cmd('read 0 512'))
+ self.remove_export('exp', force)
+ if force:
+ self.assertReadFailed(qio.cmd('read 0 512'))
+ self.assertExportNotFound('exp')
+ else:
+ self.assertReadOk(qio.cmd('read 0 512'))
+ qio.close()
+ self.assertExportNotFound('exp')
+
+ def test_remove_during_connect_default(self):
+ self.do_test_remove_during_connect()
+
+ def test_remove_during_connect_safe(self):
+ self.do_test_remove_during_connect(False)
+
+ def test_remove_during_connect_force(self):
+ self.do_test_remove_during_connect(True)
+
+ def test_remove_during_connect_safe_force(self):
+ qio = QemuIoInteractive('-r', '-f', 'raw', nbd_uri)
+ self.assertReadOk(qio.cmd('read 0 512'))
+ self.remove_export('exp', False)
+ self.assertReadOk(qio.cmd('read 0 512'))
+ self.remove_export('exp', True)
+ self.assertExportNotFound('exp')
+ self.assertReadFailed(qio.cmd('read 0 512'))
+ qio.close()
+
+
+if __name__ == '__main__':
+ iotests.main()
diff --git a/tests/qemu-iotests/201.out b/tests/qemu-iotests/201.out
new file mode 100644
index 0000000000..2f7d3902f2
--- /dev/null
+++ b/tests/qemu-iotests/201.out
@@ -0,0 +1,5 @@
+.......
+----------------------------------------------------------------------
+Ran 7 tests
+
+OK
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index 3e688678dd..15df7678b3 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -197,3 +197,4 @@
197 rw auto quick
198 rw auto
200 rw auto
+201 rw auto quick
--
2.11.1
next prev parent reply other threads:[~2017-12-07 15:51 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-07 15:50 [Qemu-devel] [PATCH v2 0/6] nbd export qmp interface Vladimir Sementsov-Ogievskiy
2017-12-07 15:50 ` [Qemu-devel] [PATCH v2 1/6] nbd/server: add additional assert to nbd_export_put Vladimir Sementsov-Ogievskiy
2018-01-10 16:33 ` Eric Blake
2017-12-07 15:50 ` [Qemu-devel] [PATCH v2 2/6] qapi: add name parameter to nbd-server-add Vladimir Sementsov-Ogievskiy
2017-12-08 17:33 ` Dr. David Alan Gilbert
2017-12-09 9:28 ` Vladimir Sementsov-Ogievskiy
2018-01-09 19:06 ` Eric Blake
2018-01-10 16:01 ` Dr. David Alan Gilbert
2018-01-09 19:28 ` [Qemu-devel] [PATCH v2 2.5/6] hmp: Add name parameter to nbd_server_add Eric Blake
2018-01-11 17:59 ` Dr. David Alan Gilbert
2018-01-11 19:50 ` Eric Blake
2018-01-11 20:11 ` Dr. David Alan Gilbert
2018-01-09 19:05 ` [Qemu-devel] [PATCH v2 2/6] qapi: add name parameter to nbd-server-add Eric Blake
2017-12-07 15:50 ` [Qemu-devel] [PATCH v2 3/6] qapi: add nbd-server-remove Vladimir Sementsov-Ogievskiy
2018-01-09 19:52 ` Eric Blake
2018-01-12 9:47 ` Vladimir Sementsov-Ogievskiy
2018-01-15 15:09 ` Eric Blake
2018-01-15 17:47 ` Vladimir Sementsov-Ogievskiy
2018-01-17 13:36 ` Vladimir Sementsov-Ogievskiy
2018-01-17 15:23 ` Eric Blake
2018-01-17 15:51 ` Vladimir Sementsov-Ogievskiy
2018-01-17 16:03 ` Eric Blake
2018-01-17 16:39 ` Vladimir Sementsov-Ogievskiy
2018-01-26 15:05 ` Dr. David Alan Gilbert
2018-02-06 15:29 ` Vladimir Sementsov-Ogievskiy
2018-02-06 16:06 ` Eric Blake
2018-02-06 17:54 ` Vladimir Sementsov-Ogievskiy
2018-02-06 18:38 ` Dr. David Alan Gilbert
2018-02-07 7:14 ` Markus Armbruster
2017-12-07 15:51 ` [Qemu-devel] [PATCH v2 4/6] iotest 147: add cases to test new @name parameter of nbd-server-add Vladimir Sementsov-Ogievskiy
2018-01-09 20:21 ` Eric Blake
2017-12-07 15:51 ` [Qemu-devel] [PATCH v2 5/6] iotests: implement QemuIoInteractive class Vladimir Sementsov-Ogievskiy
2018-01-09 20:34 ` Eric Blake
2018-01-12 11:56 ` Vladimir Sementsov-Ogievskiy
2018-01-12 16:48 ` Eric Blake
2017-12-07 15:51 ` Vladimir Sementsov-Ogievskiy [this message]
2018-01-09 20:49 ` [Qemu-devel] [PATCH v2 6/6] iotest 201: new test for qmp nbd-server-remove Eric Blake
2018-01-12 11:43 ` Vladimir Sementsov-Ogievskiy
2018-01-12 16:54 ` Eric Blake
2018-01-15 14:40 ` Vladimir Sementsov-Ogievskiy
2018-01-15 15:05 ` Eric Blake
2018-01-15 18:28 ` Vladimir Sementsov-Ogievskiy
2017-12-21 11:52 ` [Qemu-devel] ping Re: [PATCH v2 0/6] nbd export qmp interface Vladimir Sementsov-Ogievskiy
2017-12-21 15:28 ` [Qemu-devel] " Markus Armbruster
2017-12-21 18:32 ` Eric Blake
2017-12-22 8:53 ` Vladimir Sementsov-Ogievskiy
2017-12-22 15:47 ` Eric Blake
-- strict thread matches above, loose matches on Subject: below --
2018-01-18 18:11 Vladimir Sementsov-Ogievskiy
2018-01-18 18:11 ` [Qemu-devel] [PATCH v2 6/6] iotest 201: new test for qmp nbd-server-remove Vladimir Sementsov-Ogievskiy
2018-01-18 22:43 ` Eric Blake
2018-01-19 10:22 ` Vladimir Sementsov-Ogievskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171207155102.66622-7-vsementsov@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=armbru@redhat.com \
--cc=den@openvz.org \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).