From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
"open list:Block layer core" <qemu-block@nongnu.org>
Subject: [Qemu-devel] [PULL 4/8] iotest 147: add cases to test new @name parameter of nbd-server-add
Date: Fri, 26 Jan 2018 10:04:07 -0600 [thread overview]
Message-ID: <20180126160411.4033-5-eblake@redhat.com> (raw)
In-Reply-To: <20180126160411.4033-1-eblake@redhat.com>
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180119135719.24745-4-vsementsov@virtuozzo.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
---
tests/qemu-iotests/147 | 68 +++++++++++++++++++++++++++++++++++++---------
tests/qemu-iotests/147.out | 4 +--
2 files changed, 57 insertions(+), 15 deletions(-)
diff --git a/tests/qemu-iotests/147 b/tests/qemu-iotests/147
index 90f40ed2457..d2081df84b0 100755
--- a/tests/qemu-iotests/147
+++ b/tests/qemu-iotests/147
@@ -38,8 +38,8 @@ def flatten_sock_addr(crumpled_address):
class NBDBlockdevAddBase(iotests.QMPTestCase):
- def blockdev_add_options(self, address, export=None):
- options = { 'node-name': 'nbd-blockdev',
+ def blockdev_add_options(self, address, export, node_name):
+ options = { 'node-name': node_name,
'driver': 'raw',
'file': {
'driver': 'nbd',
@@ -50,23 +50,28 @@ class NBDBlockdevAddBase(iotests.QMPTestCase):
options['file']['export'] = export
return options
- def client_test(self, filename, address, export=None):
- bao = self.blockdev_add_options(address, export)
+ def client_test(self, filename, address, export=None,
+ node_name='nbd-blockdev', delete=True):
+ bao = self.blockdev_add_options(address, export, node_name)
result = self.vm.qmp('blockdev-add', **bao)
self.assert_qmp(result, 'return', {})
+ found = False
result = self.vm.qmp('query-named-block-nodes')
for node in result['return']:
- if node['node-name'] == 'nbd-blockdev':
+ if node['node-name'] == node_name:
+ found = True
if isinstance(filename, str):
self.assert_qmp(node, 'image/filename', filename)
else:
self.assert_json_filename_equal(node['image']['filename'],
filename)
break
+ self.assertTrue(found)
- result = self.vm.qmp('blockdev-del', node_name='nbd-blockdev')
- self.assert_qmp(result, 'return', {})
+ if delete:
+ result = self.vm.qmp('blockdev-del', node_name=node_name)
+ self.assert_qmp(result, 'return', {})
class QemuNBD(NBDBlockdevAddBase):
@@ -125,26 +130,63 @@ class BuiltinNBD(NBDBlockdevAddBase):
except OSError:
pass
- def _server_up(self, address):
+ def _server_up(self, address, export_name=None, export_name2=None):
result = self.server.qmp('nbd-server-start', addr=address)
self.assert_qmp(result, 'return', {})
- result = self.server.qmp('nbd-server-add', device='nbd-export')
+ if export_name is None:
+ result = self.server.qmp('nbd-server-add', device='nbd-export')
+ else:
+ result = self.server.qmp('nbd-server-add', device='nbd-export',
+ name=export_name)
self.assert_qmp(result, 'return', {})
+ if export_name2 is not None:
+ result = self.server.qmp('nbd-server-add', device='nbd-export',
+ name=export_name2)
+ self.assert_qmp(result, 'return', {})
+
+
def _server_down(self):
result = self.server.qmp('nbd-server-stop')
self.assert_qmp(result, 'return', {})
- def test_inet(self):
+ def do_test_inet(self, export_name=None):
address = { 'type': 'inet',
'data': {
'host': 'localhost',
'port': str(NBD_PORT)
} }
- self._server_up(address)
- self.client_test('nbd://localhost:%i/nbd-export' % NBD_PORT,
- flatten_sock_addr(address), 'nbd-export')
+ self._server_up(address, export_name)
+ export_name = export_name or 'nbd-export'
+ self.client_test('nbd://localhost:%i/%s' % (NBD_PORT, export_name),
+ flatten_sock_addr(address), export_name)
+ self._server_down()
+
+ def test_inet_default_export_name(self):
+ self.do_test_inet()
+
+ def test_inet_same_export_name(self):
+ self.do_test_inet('nbd-export')
+
+ def test_inet_different_export_name(self):
+ self.do_test_inet('shadow')
+
+ def test_inet_two_exports(self):
+ address = { 'type': 'inet',
+ 'data': {
+ 'host': 'localhost',
+ 'port': str(NBD_PORT)
+ } }
+ self._server_up(address, 'exp1', 'exp2')
+ self.client_test('nbd://localhost:%i/%s' % (NBD_PORT, 'exp1'),
+ flatten_sock_addr(address), 'exp1', 'node1', False)
+ self.client_test('nbd://localhost:%i/%s' % (NBD_PORT, 'exp2'),
+ flatten_sock_addr(address), 'exp2', 'node2', False)
+ result = self.vm.qmp('blockdev-del', node_name='node1')
+ self.assert_qmp(result, 'return', {})
+ result = self.vm.qmp('blockdev-del', node_name='node2')
+ self.assert_qmp(result, 'return', {})
self._server_down()
def test_inet6(self):
diff --git a/tests/qemu-iotests/147.out b/tests/qemu-iotests/147.out
index 3f8a935a082..dae404e2786 100644
--- a/tests/qemu-iotests/147.out
+++ b/tests/qemu-iotests/147.out
@@ -1,5 +1,5 @@
-......
+.........
----------------------------------------------------------------------
-Ran 6 tests
+Ran 9 tests
OK
--
2.14.3
next prev parent reply other threads:[~2018-01-26 17:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-26 16:04 [Qemu-devel] [PULL 0/8] NBD patches through 26 Jan Eric Blake
2018-01-26 16:04 ` [Qemu-devel] [PULL 1/8] qapi: add name parameter to nbd-server-add Eric Blake
2018-01-26 16:04 ` [Qemu-devel] [PULL 2/8] hmp: Add name parameter to nbd_server_add Eric Blake
2018-01-26 16:04 ` [Qemu-devel] [PULL 3/8] qapi: add nbd-server-remove Eric Blake
2018-01-26 16:04 ` Eric Blake [this message]
2018-01-26 16:04 ` [Qemu-devel] [PULL 5/8] iotests: implement QemuIoInteractive class Eric Blake
2018-01-26 16:04 ` [Qemu-devel] [PULL 6/8] iotest 205: new test for qmp nbd-server-remove Eric Blake
2018-02-05 9:24 ` Kevin Wolf
2018-02-05 12:48 ` Vladimir Sementsov-Ogievskiy
2018-01-26 16:04 ` [Qemu-devel] [PULL 7/8] hmp: Add nbd_server_remove to mirror QMP command Eric Blake
2018-01-26 16:04 ` [Qemu-devel] [PULL 8/8] nbd: implement bdrv_get_info callback Eric Blake
2018-01-29 9:59 ` [Qemu-devel] [PULL 0/8] NBD patches through 26 Jan Peter Maydell
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=20180126160411.4033-5-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/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).