Commit 23ab1115 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

test/nvmf: referral test cleanup



Removed a couple of unused variables, removed the check for nvme-cli
(the test *should* fail if it's not available), and replaced $rpc_py ->
rpc_cmd.  Also, in addition to RPCs, nvme-cli is used to retrieve the
discovery log page to ensure it's properly formatted.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I1d46fc6c31e0411f6d7513484186c74a408e80da
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20900


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 552f6517
Loading
Loading
Loading
Loading
+23 −25
Original line number Diff line number Diff line
@@ -8,46 +8,44 @@ rootdir=$(readlink -f $testdir/../../..)
source $rootdir/test/common/autotest_common.sh
source $rootdir/test/nvmf/common.sh

NULL_BDEV_SIZE=102400
NULL_BLOCK_SIZE=512
NVMF_REFERRAL_IP_1=127.0.0.2
NVMF_REFERRAL_IP_2=127.0.0.3
NVMF_REFERRAL_IP_3=127.0.0.4
NVMF_PORT_REFERRAL=4430

if ! hash nvme; then
	echo "nvme command not found; skipping referrals test"
	exit 0
get_referral_ips() {
	if [[ "$1" == "rpc" ]]; then
		# shellcheck disable=SC2005
		echo $(rpc_cmd nvmf_discovery_get_referrals | jq -r '.[].address.traddr' | sort)
	elif [[ "$1" == "nvme" ]]; then
		# shellcheck disable=SC2005
		echo $(nvme discover "${NVME_HOST[@]}" -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s 8009 -o json \
			| jq -r '.records[] | select(.subtype != "current discovery subsystem").traddr' \
			| sort)
	fi

function get_referral_ips() {
	$rpc_py nvmf_discovery_get_referrals | jq -r '.[].address.traddr' | sort | xargs
}

nvmftestinit
nvmfappstart -m 0xF

$rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192
rpc_cmd nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192
rpc_cmd nvmf_subsystem_add_listener -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s 8009 discovery

# Add a referral to another discovery service
$rpc_py nvmf_discovery_add_referral -t $TEST_TRANSPORT -a $NVMF_REFERRAL_IP_1 -s $NVMF_PORT_REFERRAL
$rpc_py nvmf_discovery_add_referral -t $TEST_TRANSPORT -a $NVMF_REFERRAL_IP_2 -s $NVMF_PORT_REFERRAL
$rpc_py nvmf_discovery_add_referral -t $TEST_TRANSPORT -a $NVMF_REFERRAL_IP_3 -s $NVMF_PORT_REFERRAL
rpc_cmd nvmf_discovery_add_referral -t $TEST_TRANSPORT -a $NVMF_REFERRAL_IP_1 -s $NVMF_PORT_REFERRAL
rpc_cmd nvmf_discovery_add_referral -t $TEST_TRANSPORT -a $NVMF_REFERRAL_IP_2 -s $NVMF_PORT_REFERRAL
rpc_cmd nvmf_discovery_add_referral -t $TEST_TRANSPORT -a $NVMF_REFERRAL_IP_3 -s $NVMF_PORT_REFERRAL

if [ "$($rpc_py nvmf_discovery_get_referrals | jq 'length')" != "3" ]; then
	echo "nvmf_discovery_add_referral RPC didn't properly create referrals." && false
fi
(($(rpc_cmd nvmf_discovery_get_referrals | jq 'length') == 3))
[[ $(get_referral_ips "rpc") == "$NVMF_REFERRAL_IP_1 $NVMF_REFERRAL_IP_2 $NVMF_REFERRAL_IP_3" ]]
[[ $(get_referral_ips "nvme") == "$NVMF_REFERRAL_IP_1 $NVMF_REFERRAL_IP_2 $NVMF_REFERRAL_IP_3" ]]

[[ $(get_referral_ips) == "$NVMF_REFERRAL_IP_1 $NVMF_REFERRAL_IP_2 $NVMF_REFERRAL_IP_3" ]]
rpc_cmd nvmf_discovery_remove_referral -t $TEST_TRANSPORT -a $NVMF_REFERRAL_IP_1 -s $NVMF_PORT_REFERRAL
rpc_cmd nvmf_discovery_remove_referral -t $TEST_TRANSPORT -a $NVMF_REFERRAL_IP_2 -s $NVMF_PORT_REFERRAL
rpc_cmd nvmf_discovery_remove_referral -t $TEST_TRANSPORT -a $NVMF_REFERRAL_IP_3 -s $NVMF_PORT_REFERRAL

$rpc_py nvmf_discovery_remove_referral -t $TEST_TRANSPORT -a $NVMF_REFERRAL_IP_1 -s $NVMF_PORT_REFERRAL
$rpc_py nvmf_discovery_remove_referral -t $TEST_TRANSPORT -a $NVMF_REFERRAL_IP_2 -s $NVMF_PORT_REFERRAL
$rpc_py nvmf_discovery_remove_referral -t $TEST_TRANSPORT -a $NVMF_REFERRAL_IP_3 -s $NVMF_PORT_REFERRAL

if [ "$($rpc_py nvmf_discovery_get_referrals | jq 'length')" != "0" ]; then
	echo "nvmf_discovery_remove_referral RPC didn't properly remove referrals." && false
fi
(($(rpc_cmd nvmf_discovery_get_referrals | jq 'length') == 0))
[[ $(get_referral_ips "nvme") == "" ]]

trap - SIGINT SIGTERM EXIT

nvmftestfini