Commit d34d8172 authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

test/nvmf: Hook get_notification_count() into waitforcondition()



Just to make sure notifications check is not racy.

Change-Id: I35b620a53f5792ded713fab9cb4e09cd620bbbeb
Signed-off-by: default avatarMichal Berger <michal.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22694


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 574d258e
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -75,6 +75,11 @@ function get_notification_count() {
	notify_id=$((notify_id + notification_count))
}

function is_notification_count_eq() {
	expected_count=$1
	waitforcondition 'get_notification_count && ((notification_count == expected_count))'
}

[[ "$(get_subsystem_names)" == "" ]]
[[ "$(get_bdev_list)" == "" ]]

@@ -91,8 +96,7 @@ $rpc_py nvmf_subsystem_add_ns ${NQN}0 null0
$rpc_py nvmf_subsystem_add_listener ${NQN}0 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT
[[ "$(get_subsystem_names)" == "" ]]
[[ "$(get_bdev_list)" == "" ]]
get_notification_count
[[ $notification_count == 0 ]]
is_notification_count_eq 0

# Discovery hostnqn is added, so now the host should see the subsystem, with a single path for the
# port of the single listener on the target.
@@ -101,15 +105,13 @@ $rpc_py nvmf_subsystem_add_host ${NQN}0 $HOST_NQN
waitforcondition '[[ "$(get_subsystem_names)" == "nvme0" ]]'
waitforcondition '[[ "$(get_bdev_list)" == "nvme0n1" ]]'
waitforcondition '[[ "$(get_subsystem_paths nvme0)" == "$NVMF_PORT" ]]'
get_notification_count
[[ $notification_count == 1 ]]
is_notification_count_eq 1

# Adding a namespace isn't a discovery function, but do it here anyways just to confirm we see a new bdev.
$rpc_py nvmf_subsystem_add_ns ${NQN}0 null1
# Wait a bit to make sure the discovery service has a chance to detect the changes
waitforcondition '[[ "$(get_bdev_list)" == "nvme0n1 nvme0n2" ]]'
get_notification_count
[[ $notification_count == 1 ]]
is_notification_count_eq 1

# Add a second path to the same subsystem.  This shouldn't change the list of subsystems or bdevs, but
# we should see a second path on the nvme0 subsystem now.
@@ -118,8 +120,7 @@ $rpc_py nvmf_subsystem_add_listener ${NQN}0 -t $TEST_TRANSPORT -a $NVMF_FIRST_TA
waitforcondition '[[ "$(get_subsystem_names)" == "nvme0" ]]'
waitforcondition '[[ "$(get_bdev_list)" == "nvme0n1 nvme0n2" ]]'
waitforcondition '[[ "$(get_subsystem_paths nvme0)" == "$NVMF_PORT $NVMF_SECOND_PORT" ]]'
get_notification_count
[[ $notification_count == 0 ]]
is_notification_count_eq 0

# Remove the listener for the first port.  The subsystem and bdevs should stay, but we should see
# the path to that first port disappear.
@@ -128,15 +129,13 @@ $rpc_py nvmf_subsystem_remove_listener ${NQN}0 -t $TEST_TRANSPORT -a $NVMF_FIRST
waitforcondition '[[ "$(get_subsystem_names)" == "nvme0" ]]'
waitforcondition '[[ "$(get_bdev_list)" == "nvme0n1 nvme0n2" ]]'
waitforcondition '[[ "$(get_subsystem_paths nvme0)" == "$NVMF_SECOND_PORT" ]]'
get_notification_count
[[ $notification_count == 0 ]]
is_notification_count_eq 0

$rpc_py -s $HOST_SOCK bdev_nvme_stop_discovery -b nvme
# Wait a bit to make sure the discovery service has a chance to detect the changes
waitforcondition '[[ "$(get_subsystem_names)" == "" ]]'
waitforcondition '[[ "$(get_bdev_list)" == "" ]]'
get_notification_count
[[ $notification_count == 2 ]]
is_notification_count_eq 2

# Make sure that it's not possible to start two discovery services with the same name
$rpc_py -s $HOST_SOCK bdev_nvme_start_discovery -b nvme -t $TEST_TRANSPORT \