[PATCH 06/10] nvme/039: create authenticated connections
Hannes Reinecke
hare at suse.de
Mon Dec 13 23:16:28 PST 2021
On 12/14/21 12:01 AM, Chaitanya Kulkarni wrote:
> On 11/22/21 11:49 PM, Hannes Reinecke wrote:
>> Signed-off-by: Hannes Reinecke <hare at suse.de>
>> ---
>> tests/nvme/039 | 83 ++++++++++++++++++++++++++++++++++++++++++++++
>> tests/nvme/039.out | 7 ++++
>> 2 files changed, 90 insertions(+)
>> create mode 100644 tests/nvme/039
>> create mode 100644 tests/nvme/039.out
>>
>> diff --git a/tests/nvme/039 b/tests/nvme/039
>> new file mode 100644
>> index 0000000..4fbe7de
>> --- /dev/null
>> +++ b/tests/nvme/039
>> @@ -0,0 +1,83 @@
>> +#!/bin/bash
>> +# SPDX-License-Identifier: GPL-3.0+
>> +# Copyright (C) 2021 Hannes Reinecke, SUSE Labs
>> +#
>> +# Create authenticated connections
>> +
>> +. tests/nvme/rc
>> +
>> +DESCRIPTION="Create authenticated connections"
>> +QUICK=1
>> +
>> +requires() {
>> + _nvme_requires
>> + _have_modules loop
>> + _require_nvme_trtype_is_fabrics
>> + _require_nvme_cli_auth
>> +}
>> +
>> +
>> +test() {
>> + local port
>> + local subsys="blktests-subsystem-1"
>> + local hostid="$(uuidgen)"
>> + local hostnqn="nqn.2014-08.org.nvmexpress:uuid:${hostid}"
>> + local scratch="/tmp/blktest-ns1.img"
>> + local hostkey
>> + local ctrldev
>> +
>> + echo "Running ${TEST_NAME}"
>> +
>> + hostkey="$(nvme gen-dhchap-key -n ${subsys} 2> /dev/null)"
>> + if [ $? -ne 0 ] ; then
>> + echo "nvme gen-dhchap-key command missing"
>> + return 1
>> + fi
>> +
>> + _setup_nvmet
>> +
>> + truncate -s 512M "${scratch}"
>> +
>> + port="$(_create_nvmet_port "${nvme_trtype}")"
>> +
>> + _create_nvmet_subsystem "${subsys}" "${scratch}"
>> + _add_nvmet_subsys_to_port "${port}" "${subsys}"
>> + _create_nvmet_host "${subsys}" "${hostnqn}" "${hostkey}"
>> +
>
> Starting from _setup_nvmet() to _create_nvmet_host() seems to be
> duplicated in most of the cases (39/40/41/42/43).
>
> Let's avoid the code duplication by creating a helper in nvme/rc ?
>
I deliberately did not create a single helper here, as I'm not a fan of
functions with thousands of arguments (we would need at least 5
arguments here).
And also it allows you to expand that by creating two ports to the same
subsystem etc.
So I'd rather keep it that way.
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare at suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
More information about the Linux-nvme
mailing list