Thread (33 messages) 33 messages, 3 authors, 2022-06-06

Re: [PATCH 06/10] nvme/039: create authenticated connections

From: Chaitanya Kulkarni <hidden>
Date: 2021-12-14 07:36:46

On 12/13/21 11:16 PM, Hannes Reinecke wrote:
External email: Use caution opening links or attachments


On 12/14/21 12:01 AM, Chaitanya Kulkarni wrote:
quoted
On 11/22/21 11:49 PM, Hannes Reinecke wrote:
quoted
Signed-off-by: Hannes Reinecke <hare@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.
Right now there are 5 testcases, I'm sure we will endup adding
more testcases since in-band auth is a big chunk of code (thanks to
you :)), it will get duplicated, why maintain duplicated code ?

Regarding number of argument subsys, scratch variables have static 
values that are used in all the testcases (39,40,41,42,43).
Can we just move those to nvme/rc ? with that we'll only have to
pass 5-2=3 parameters to the helper which is pretty reasonable.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help