Skip to content

Commit

Permalink
test/nvme: add test for basic ANA support
Browse files Browse the repository at this point in the history
Add a test for basic ANA support by creating 4 paths, run a fio
process to generate load, and then switch port states to check
if I/O continues uninterrupted.

Signed-off-by: Hannes Reinecke <[email protected]>
  • Loading branch information
hreinecke committed Oct 2, 2024
1 parent 79b9031 commit 36e7580
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
97 changes: 97 additions & 0 deletions tests/nvme/054
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0+
# Copyright (C) 2024 Hannes Reinecke (SUSE) <[email protected]>
#
# Test nvme fabrics controller ANA failover during I/O

. tests/nvme/rc

DESCRIPTION="test nvme fabrics controller ANA failover during I/O"

requires() {
_nvme_requires
_have_loop
_have_fio
_require_nvme_trtype_is_fabrics
}

set_conditions() {
_set_nvme_trtype "$@"
}

failback() {
local portno=0

for port in "$@"; do
if (( portno == 0 )); then
_setup_nvmet_port_ana "${port}" 1 "optimized"
elif (( portno == 1 )); then
_setup_nvmet_port_ana "${port}" 1 "non-optimized"
else
_setup_nvmet_port_ana "${port}" 1 "inaccessible"
fi
portno=$(( portno + 1 ))
done
}

failover() {
local portno=0

for port in "$@"; do
if (( portno == 2 )); then
_setup_nvmet_port_ana "${port}" 1 "optimized"
elif (( portno == 3 )); then
_setup_nvmet_port_ana "${port}" 1 "non-optimized"
else
_setup_nvmet_port_ana "${port}" 1 "inaccessible"
fi
portno=$(( portno + 1))
done
}

test() {
echo "Running ${TEST_NAME}"

_setup_nvmet

local subsysnqn="${def_subsysnqn}"
local nvmedev
local fio_pid
local ns
local ports
local ctrls

_nvmet_target_setup --ports 4

_get_nvmet_ports "${subsysnqn}" ports
failback "${ports[@]}"

_nvme_connect_subsys

# start fio job
ns=$(_find_nvme_ns "$def_subsys_uuid")
_run_fio_verify_io --filename="/dev/${ns}" \
--group_reporting --ramp-time=5 \
--time_based --runtime=1m &> "$FULL" &
fio_pid=$!
sleep 5

# switch port status
echo "ANA failover"
failover "${ports[@]}"

sleep 10

# switch back to original state
echo "ANA failback"
failback "${ports[@]}"

sleep 10

{ kill "${fio_pid}"; wait; } &> /dev/null

_nvme_disconnect_subsys
_nvmet_target_cleanup

echo "Test complete"
}
5 changes: 5 additions & 0 deletions tests/nvme/054.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Running nvme/054
ANA failover
ANA failback
disconnected 4 controller(s)
Test complete

0 comments on commit 36e7580

Please sign in to comment.