2017-03-08 02:32:39 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-11-02 15:49:40 +00:00
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
# Copyright (C) 2017 Intel Corporation
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
2017-03-08 02:32:39 +00:00
|
|
|
testdir=$(readlink -f $(dirname $0))
|
|
|
|
rootdir=$(readlink -f $testdir/../../..)
|
2018-02-27 22:14:08 +00:00
|
|
|
source $rootdir/test/common/autotest_common.sh
|
2017-03-08 02:32:39 +00:00
|
|
|
source $rootdir/test/nvmf/common.sh
|
|
|
|
|
2021-08-12 11:39:58 +00:00
|
|
|
loops=5
|
2017-03-08 02:32:39 +00:00
|
|
|
|
2020-05-07 11:27:06 +00:00
|
|
|
function jcount() {
|
|
|
|
local filter=$1
|
|
|
|
jq "$filter" | wc -l
|
2019-07-28 11:43:47 +00:00
|
|
|
}
|
|
|
|
|
2020-05-07 11:27:06 +00:00
|
|
|
function jsum() {
|
|
|
|
local filter=$1
|
|
|
|
jq "$filter" | awk '{s+=$1}END{print s}'
|
2019-07-28 11:43:47 +00:00
|
|
|
}
|
|
|
|
|
2019-05-16 19:38:53 +00:00
|
|
|
nvmftestinit
|
2020-04-28 15:08:33 +00:00
|
|
|
nvmfappstart -m 0xF
|
2018-08-14 18:05:15 +00:00
|
|
|
|
2019-07-28 11:43:47 +00:00
|
|
|
stats=$($rpc_py nvmf_get_stats)
|
|
|
|
# Expect 4 poll groups (from CPU mask) and no transports yet
|
|
|
|
[ "4" -eq $(jcount .poll_groups[].name <<< "$stats") ]
|
|
|
|
[ "null" == $(jq .poll_groups[0].transports[0] <<< "$stats") ]
|
|
|
|
|
2019-07-15 04:42:41 +00:00
|
|
|
$rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192
|
2017-03-08 02:32:39 +00:00
|
|
|
|
2019-07-28 11:43:47 +00:00
|
|
|
stats=$($rpc_py nvmf_get_stats)
|
|
|
|
# Expect no QPs
|
|
|
|
[ "0" -eq $(jsum .poll_groups[].admin_qpairs <<< "$stats") ]
|
|
|
|
[ "0" -eq $(jsum .poll_groups[].io_qpairs <<< "$stats") ]
|
|
|
|
# Transport statistics is currently implemented for RDMA only
|
|
|
|
if [ 'rdma' == $TEST_TRANSPORT ]; then
|
2020-05-07 11:27:06 +00:00
|
|
|
# Expect RDMA transport and some devices
|
|
|
|
[ "1" -eq $(jcount .poll_groups[0].transports[].trtype <<< "$stats") ]
|
|
|
|
transport_type=$(jq -r .poll_groups[0].transports[0].trtype <<< "$stats")
|
|
|
|
[ "${transport_type,,}" == "${TEST_TRANSPORT,,}" ]
|
|
|
|
[ "0" -lt $(jcount .poll_groups[0].transports[0].devices[].name <<< "$stats") ]
|
2019-07-28 11:43:47 +00:00
|
|
|
fi
|
|
|
|
|
2017-06-27 18:26:19 +00:00
|
|
|
MALLOC_BDEV_SIZE=64
|
|
|
|
MALLOC_BLOCK_SIZE=512
|
|
|
|
|
2019-08-09 11:15:35 +00:00
|
|
|
$rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc1
|
2017-03-08 02:32:39 +00:00
|
|
|
|
2018-01-23 22:03:38 +00:00
|
|
|
# Disallow host NQN and make sure connect fails
|
2019-12-19 14:17:49 +00:00
|
|
|
$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s $NVMF_SERIAL
|
2019-05-15 23:44:27 +00:00
|
|
|
$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc1
|
2018-01-23 22:03:38 +00:00
|
|
|
$rpc_py nvmf_subsystem_allow_any_host -d nqn.2016-06.io.spdk:cnode1
|
2019-06-03 16:34:31 +00:00
|
|
|
$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT
|
2018-01-23 22:03:38 +00:00
|
|
|
|
|
|
|
# This connect should fail - the host NQN is not allowed
|
2022-11-22 12:48:37 +00:00
|
|
|
NOT $NVME_CONNECT -t $TEST_TRANSPORT -n nqn.2016-06.io.spdk:cnode1 -q nqn.2016-06.io.spdk:host1 -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
|
2018-01-23 22:03:38 +00:00
|
|
|
|
|
|
|
# Add the host NQN and verify that the connect succeeds
|
|
|
|
$rpc_py nvmf_subsystem_add_host nqn.2016-06.io.spdk:cnode1 nqn.2016-06.io.spdk:host1
|
2022-11-22 12:48:37 +00:00
|
|
|
$NVME_CONNECT -t $TEST_TRANSPORT -n nqn.2016-06.io.spdk:cnode1 -q nqn.2016-06.io.spdk:host1 -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
|
2019-12-19 14:17:49 +00:00
|
|
|
waitforserial "$NVMF_SERIAL"
|
2018-01-23 22:03:38 +00:00
|
|
|
nvme disconnect -n nqn.2016-06.io.spdk:cnode1
|
2021-08-26 19:39:07 +00:00
|
|
|
waitforserial_disconnect "$NVMF_SERIAL"
|
2018-01-23 22:03:38 +00:00
|
|
|
|
|
|
|
# Remove the host and verify that the connect fails
|
|
|
|
$rpc_py nvmf_subsystem_remove_host nqn.2016-06.io.spdk:cnode1 nqn.2016-06.io.spdk:host1
|
2022-11-22 12:48:37 +00:00
|
|
|
NOT $NVME_CONNECT -t $TEST_TRANSPORT -n nqn.2016-06.io.spdk:cnode1 -q nqn.2016-06.io.spdk:host1 -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
|
2018-01-23 22:03:38 +00:00
|
|
|
|
|
|
|
# Allow any host and verify that the connect succeeds
|
|
|
|
$rpc_py nvmf_subsystem_allow_any_host -e nqn.2016-06.io.spdk:cnode1
|
2022-11-22 12:48:37 +00:00
|
|
|
$NVME_CONNECT -t $TEST_TRANSPORT -n nqn.2016-06.io.spdk:cnode1 -q nqn.2016-06.io.spdk:host1 -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
|
2019-12-19 14:17:49 +00:00
|
|
|
waitforserial "$NVMF_SERIAL"
|
2018-01-23 22:03:38 +00:00
|
|
|
nvme disconnect -n nqn.2016-06.io.spdk:cnode1
|
2021-08-26 19:39:07 +00:00
|
|
|
waitforserial_disconnect "$NVMF_SERIAL"
|
2018-01-23 22:03:38 +00:00
|
|
|
|
2019-09-23 10:17:30 +00:00
|
|
|
$rpc_py nvmf_delete_subsystem nqn.2016-06.io.spdk:cnode1
|
2018-03-21 06:16:23 +00:00
|
|
|
|
|
|
|
# do frequent add delete of namespaces with different nsid.
|
2021-08-12 11:39:58 +00:00
|
|
|
for i in $(seq 1 $loops); do
|
2019-12-19 14:17:49 +00:00
|
|
|
$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -s $NVMF_SERIAL
|
2019-06-03 16:34:31 +00:00
|
|
|
$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT
|
2019-05-15 23:44:27 +00:00
|
|
|
$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc1 -n 5
|
|
|
|
$rpc_py nvmf_subsystem_allow_any_host nqn.2016-06.io.spdk:cnode1
|
2022-11-22 12:48:37 +00:00
|
|
|
$NVME_CONNECT -t $TEST_TRANSPORT -n nqn.2016-06.io.spdk:cnode1 -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
|
2018-03-21 06:16:23 +00:00
|
|
|
|
2019-12-19 14:17:49 +00:00
|
|
|
waitforserial "$NVMF_SERIAL"
|
2019-05-15 23:44:27 +00:00
|
|
|
|
|
|
|
nvme disconnect -n nqn.2016-06.io.spdk:cnode1
|
2021-08-26 19:39:07 +00:00
|
|
|
waitforserial_disconnect "$NVMF_SERIAL"
|
2019-05-15 23:44:27 +00:00
|
|
|
|
|
|
|
$rpc_py nvmf_subsystem_remove_ns nqn.2016-06.io.spdk:cnode1 5
|
2019-09-23 10:17:30 +00:00
|
|
|
$rpc_py nvmf_delete_subsystem nqn.2016-06.io.spdk:cnode1
|
2018-03-21 06:16:23 +00:00
|
|
|
|
|
|
|
done
|
|
|
|
|
2017-03-08 02:32:39 +00:00
|
|
|
# do frequent add delete.
|
2021-08-12 11:39:58 +00:00
|
|
|
for i in $(seq 1 $loops); do
|
2019-12-19 14:17:49 +00:00
|
|
|
$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -s $NVMF_SERIAL
|
2019-06-03 16:34:31 +00:00
|
|
|
$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT
|
2019-05-15 23:44:27 +00:00
|
|
|
$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc1
|
|
|
|
$rpc_py nvmf_subsystem_allow_any_host nqn.2016-06.io.spdk:cnode1
|
|
|
|
|
|
|
|
$rpc_py nvmf_subsystem_remove_ns nqn.2016-06.io.spdk:cnode1 1
|
|
|
|
|
2019-09-23 10:17:30 +00:00
|
|
|
$rpc_py nvmf_delete_subsystem nqn.2016-06.io.spdk:cnode1
|
2017-03-08 02:32:39 +00:00
|
|
|
done
|
|
|
|
|
2019-07-28 11:43:47 +00:00
|
|
|
stats=$($rpc_py nvmf_get_stats)
|
|
|
|
# Expect some admin and IO qpairs
|
|
|
|
[ "0" -lt $(jsum .poll_groups[].admin_qpairs <<< "$stats") ]
|
|
|
|
[ "0" -lt $(jsum .poll_groups[].io_qpairs <<< "$stats") ]
|
|
|
|
# Transport statistics is currently implemented for RDMA only
|
|
|
|
if [ 'rdma' == $TEST_TRANSPORT ]; then
|
2020-05-07 11:27:06 +00:00
|
|
|
# Expect non-zero completions and request latencies accumulated
|
|
|
|
[ "0" -lt $(jsum .poll_groups[].transports[].devices[].completions <<< "$stats") ]
|
|
|
|
[ "0" -lt $(jsum .poll_groups[].transports[].devices[].request_latency <<< "$stats") ]
|
2019-07-28 11:43:47 +00:00
|
|
|
fi
|
|
|
|
|
2017-03-08 02:32:39 +00:00
|
|
|
trap - SIGINT SIGTERM EXIT
|
|
|
|
|
2019-05-16 19:38:53 +00:00
|
|
|
nvmftestfini
|