test/json: Fix json tests for NVMe with multiple namespaces

Currently json tests try to remove NVMe controller for
each NVMe bdev, but with NVMe that has multiple namepsaces
it actually tries to remove same controller multiple times.
This patch fixes that issue.

Signed-off-by: Maciej Szwed <maciej.szwed@intel.com>
Change-Id: I555cb2a9aa78fd4cc700ddda0f5c1026329a2d3a
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/461561
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Maciej Szwed 2019-07-22 08:04:51 +02:00 committed by Darek Stojaczyk
parent 3fe300609e
commit b7408943d1

View File

@ -30,23 +30,8 @@ def get_bdev_name(bdev):
return bdev_name return bdev_name
def delete_subbdevs(args, bdev, rpc_bdevs):
ret_value = False
bdev_name = get_bdev_name(bdev)
if bdev_name and 'method' in bdev:
construct_method = bdev['method']
if construct_method == 'construct_nvme_bdev':
for rpc_bdev in rpc_bdevs:
if bdev_name in rpc_bdev['name'] and rpc_bdev['product_name'] == "NVMe disk":
args.client.call('delete_nvme_controller', {'name': "%s" % rpc_bdev['name'].split('n')[0]})
ret_value = True
return ret_value
def get_bdev_destroy_method(bdev): def get_bdev_destroy_method(bdev):
destroy_method_map = {'construct_nvme_bdev': "delete_nvme_controller", destroy_method_map = {'construct_malloc_bdev': "delete_malloc_bdev",
'construct_malloc_bdev': "delete_malloc_bdev",
'construct_null_bdev': "delete_null_bdev", 'construct_null_bdev': "delete_null_bdev",
'construct_rbd_bdev': "delete_rbd_bdev", 'construct_rbd_bdev': "delete_rbd_bdev",
'construct_pmem_bdev': "delete_pmem_bdev", 'construct_pmem_bdev': "delete_pmem_bdev",
@ -71,14 +56,16 @@ def get_bdev_destroy_method(bdev):
def clear_bdev_subsystem(args, bdev_config): def clear_bdev_subsystem(args, bdev_config):
rpc_bdevs = args.client.call("get_bdevs") rpc_bdevs = args.client.call("get_bdevs")
for bdev in bdev_config: for bdev in bdev_config:
if delete_subbdevs(args, bdev, rpc_bdevs):
continue
bdev_name_key = get_bdev_name_key(bdev) bdev_name_key = get_bdev_name_key(bdev)
bdev_name = get_bdev_name(bdev) bdev_name = get_bdev_name(bdev)
destroy_method = get_bdev_destroy_method(bdev) destroy_method = get_bdev_destroy_method(bdev)
if destroy_method: if destroy_method:
args.client.call(destroy_method, {bdev_name_key: bdev_name}) args.client.call(destroy_method, {bdev_name_key: bdev_name})
nvme_controllers = args.client.call("get_nvme_controllers")
for ctrlr in nvme_controllers:
args.client.call('delete_nvme_controller', {'name': ctrlr['name']})
''' Disable and reset hotplug ''' ''' Disable and reset hotplug '''
rpc.bdev.set_bdev_nvme_hotplug(args.client, False) rpc.bdev.set_bdev_nvme_hotplug(args.client, False)