Add a new test case which forcefully removes the target and setup it again. Signed-off-by: Daniel Wagner <wagi@xxxxxxxxxx> --- tests/nvme/061 | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/nvme/061.out | 21 ++++++++++++ 2 files changed, 120 insertions(+) diff --git a/tests/nvme/061 b/tests/nvme/061 new file mode 100755 index 0000000000000000000000000000000000000000..b7a9ca216e6b71db209e80dc69dfd934618b54c2 --- /dev/null +++ b/tests/nvme/061 @@ -0,0 +1,99 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2025 Daniel Wagner, SUSE Labs +# +# Test if the host keeps running IO when the target is forcefully removed and +# recreated. + +. tests/nvme/rc + +DESCRIPTION="test teardown and setup fabrics target during I/O" +TIMED=1 + +requires() { + _nvme_requires + _have_loop + _have_fio + _require_nvme_trtype_is_fabrics +} + +set_conditions() { + _set_nvme_trtype "$@" +} + +nvmf_wait_for_state() { + local def_state_timeout=5 + local subsys_name="$1" + local state="$2" + local timeout="${3:-$def_state_timeout}" + local nvmedev + local state_file + local start_time + local end_time + + nvmedev=$(_find_nvme_dev "${subsys_name}") + state_file="/sys/class/nvme-fabrics/ctl/${nvmedev}/state" + + start_time=$(date +%s) + while ! grep -q "${state}" "${state_file}"; do + sleep 1 + end_time=$(date +%s) + if (( end_time - start_time > timeout )); then + echo "expected state \"${state}\" not " \ + "reached within ${timeout} seconds" + return 1 + fi + done + + return 0 +} + +test() { + echo "Running ${TEST_NAME}" + + _setup_nvmet + + local ns + + _nvmet_target_setup + + local connect_args="" + + if [[ "${nvme_trtype}" == "fc" ]]; then + connect_args="--ctrl-dev-loss 0" + fi + + _nvme_connect_subsys --keep-alive-tmo 1 --reconnect-delay 1 + + ns=$(_find_nvme_ns "${def_subsys_uuid}") + + _run_fio_rand_io --filename="/dev/${ns}" \ + --group_reporting \ + --time_based --runtime=1d &> /dev/null & + fio_pid=$! + sleep 1 + + nvmedev=$(_find_nvme_dev "${def_subsysnqn}") + state_file="/sys/class/nvme-fabrics/ctl/${nvmedev}/state" + for ((i = 0; i <= 5; i++)); do + echo "iteration $i" + + _nvmet_target_cleanup + + nvmf_wait_for_state "${def_subsysnqn}" "connecting" || return 1 + echo "state: $(cat $state_file)" + + _nvmet_target_setup + + nvmf_wait_for_state "${def_subsysnqn}" "live" || return 1 + echo "state: $(cat $state_file)" + done + + { kill "${fio_pid}"; wait; } &> /dev/null + + _nvme_disconnect_subsys + + _nvmet_target_cleanup + + echo "Test complete" +} diff --git a/tests/nvme/061.out b/tests/nvme/061.out new file mode 100644 index 0000000000000000000000000000000000000000..75516abdac005854c2be165005c076ef8891c518 --- /dev/null +++ b/tests/nvme/061.out @@ -0,0 +1,21 @@ +Running nvme/061 +iteration 0 +state: connecting +state: live +iteration 1 +state: connecting +state: live +iteration 2 +state: connecting +state: live +iteration 3 +state: connecting +state: live +iteration 4 +state: connecting +state: live +iteration 5 +state: connecting +state: live +disconnected 1 controller(s) +Test complete -- 2.48.1