From d424e2449a9d8cdd9057c21afd71cf14c2d28563 Mon Sep 17 00:00:00 2001 From: Rui Chang Date: Tue, 11 May 2021 17:27:23 +0800 Subject: [PATCH] test/json_config: Fix json_config test fail for multiple nvme disk config In json_config test, when there are multiple nvme disks, we see errors like: ERROR: expected event 'bdev_register:Nvme0n1p1' but got 'bdev_register:Nvme1n1' (whole event line: bdev_register:Nvme1n1:1) The reason is when there are multiple nvme disks in the system, when start nvmf_tgt, it will register all the disks in bdev, so there would be multiple bdev_register events for these disks before we run create_bdev_subsystem_config. So in create_bdev_subsystem_config we need add these events to expected events list first. Signed-off-by: Rui Chang Change-Id: Ice8f5464975e68ae63fec891ef18dbc7590a9ab5 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7858 Reviewed-by: Tomasz Zawadzki Reviewed-by: Michal Berger Reviewed-by: Changpeng Liu Reviewed-by: Ziye Yang Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins --- test/json_config/json_config.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/json_config/json_config.sh b/test/json_config/json_config.sh index 5dd95e0c6..396213469 100755 --- a/test/json_config/json_config.sh +++ b/test/json_config/json_config.sh @@ -150,6 +150,20 @@ function create_bdev_subsystem_config() { local expected_notifications=() + local event_line event ev_type ev_ctx + local rc="" + + # Before testing notifications generated by the operations in this function, we + # need add existing notification to the expected list first. Otherwise it would fail. + while read -r event_line; do + # remove ID + event="${event_line%:*}" + ev_type=${event%:*} + ev_ctx=${event#*:} + + expected_notifications+=(${ev_type}:${ev_ctx}) + done < <(tgt_rpc notify_get_notifications -i ${last_event_id} | jq -r '.[] | "\(.type):\(.ctx):\(.id)"') + if [[ $SPDK_TEST_BLOCKDEV -eq 1 ]]; then local lvol_store_base_bdev=Nvme0n1 if ! tgt_rpc get_bdevs --name ${lvol_store_base_bdev} > /dev/null; then @@ -174,7 +188,6 @@ function create_bdev_subsystem_config() { tgt_rpc bdev_malloc_create 16 4096 --name Malloc1 expected_notifications+=( - bdev_register:${lvol_store_base_bdev} bdev_register:${lvol_store_base_bdev}p1 bdev_register:${lvol_store_base_bdev}p0 bdev_register:Malloc3