test/spdkcli: Wait long enough for the nvme ctrl to be gone

Some nvmes need more time to attach|detach to|from, hence having a
static sleep is not ideal depending on what type of the nvme was
picked up for the test. Instead, simply wait until the list of
nvme ctrls is empty after the cleanup.

Change-Id: I2fc2630020436d0e1f6b01a5ce60aea56e7bf8ec
Signed-off-by: Michal Berger <michal.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17559
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
This commit is contained in:
Michal Berger 2023-04-12 15:33:10 +02:00 committed by David Ko
parent 20e5d5388e
commit f714562f5a
2 changed files with 9 additions and 2 deletions

View File

@ -45,3 +45,7 @@ function check_match() {
$rootdir/test/app/match/match $testdir/match_files/${MATCH_FILE}.match
rm -f $testdir/match_files/${MATCH_FILE}
}
function wait_for_all_nvme_ctrls_to_detach() {
while (($(rpc_cmd bdev_nvme_get_controllers | jq '.|length') != 0)); do :; done
}

View File

@ -131,8 +131,11 @@ $spdkcli_job "'load_config $testdir/config.json'
"
check_match
$spdk_clear_config_py clear_config
# FIXME: remove this sleep when NVMe driver will be fixed to wait for reset to complete
sleep 2
# Make sure we wait long enough for the nvme ctrl to disappear, otherwise
# we are at risk of hitting -EPERM while loading bdev configuration.
xtrace_disable_per_cmd wait_for_all_nvme_ctrls_to_detach
$spdkcli_job "'load_subsystem_config $testdir/config_bdev.json'
'load_subsystem_config $testdir/config_vhost_scsi.json'
'load_subsystem_config $testdir/config_vhost_blk.json'