diff --git a/tests/loop.nix b/tests/loop.nix index 2997748..3ebca30 100644 --- a/tests/loop.nix +++ b/tests/loop.nix @@ -70,6 +70,10 @@ node.fail("test -e /sys/kernel/config/nvmet/subsystems/${subnqn}/namespaces/1") node.fail("nvmet namespace remove ${subnqn} 1") + node.succeed("nvmet port remove-subsystem 1 ${subnqn}") + assert "${subnqn}" not in node.succeed("nvmet port list-subsystems 1") + node.fail("test -e /sys/kernel/config/nvmet/ports/1/subsystems/${subnqn}") + node.succeed("nvmet subsystem remove ${subnqn}") node.fail("test -e /sys/kernel/config/nvmet/subsystems/${subnqn}") node.fail("nvmet subsystem remove ${subnqn}") diff --git a/tests/rdma.nix b/tests/rdma.nix index 6f673aa..4269f16 100644 --- a/tests/rdma.nix +++ b/tests/rdma.nix @@ -33,12 +33,12 @@ }; testScript = let subnqn = "nqn.2023-11.sh.tty:nvmetcfg-test-loop"; + initiator1 = "nqn.2024-02.sh.tty:nvmetcfg-client1"; + initiator2 = "nqn.2024-02.sh.tty:nvmetcfg-client2"; in '' start_all() target.wait_for_unit("default.target") - target.succeed("ip a") - # Set up the loop device. target.succeed("fallocate -l 1G /root/test.img") target.succeed("losetup /dev/loop0 /root/test.img") @@ -47,6 +47,20 @@ target.succeed("nvmet subsystem add ${subnqn}") assert "${subnqn}" in target.succeed("nvmet subsystem list") target.succeed("test -d /sys/kernel/config/nvmet/subsystems/${subnqn}") + + target.succeed("nvmet subsystem add-host ${subnqn} ${initiator1}") + target.succeed("test -d /sys/kernel/config/nvmet/hosts/${initiator1}") + target.succeed("test -d /sys/kernel/config/nvmet/subsystems/${subnqn}/allowed_hosts/${initiator1}") + assert "${initiator1}" in target.succeed("nvmet subsystem list-hosts ${subnqn}") + target.succeed("nvmet subsystem add-host ${subnqn} ${initiator2}") + target.succeed("test -d /sys/kernel/config/nvmet/hosts/${initiator2}") + target.succeed("test -d /sys/kernel/config/nvmet/subsystems/${subnqn}/allowed_hosts/${initiator2}") + assert "${initiator2}" in target.succeed("nvmet subsystem list-hosts ${subnqn}") + target.succeed("nvmet subsystem remove-host ${subnqn} ${initiator1}") + target.fail("test -e /sys/kernel/config/nvmet/hosts/${initiator1}") + target.fail("test -e /sys/kernel/config/nvmet/subsystems/${subnqn}/allowed_hosts/${initiator1}") + assert "${initiator1}" not in target.succeed("nvmet subsystem list-hosts ${subnqn}") + target.succeed("nvmet subsystem show") target.succeed("nvmet namespace add ${subnqn} 1 /dev/loop0") @@ -86,14 +100,19 @@ assert target.succeed("cat /root/state.yml") == target.succeed("cat /root/state-after.yml") # Test the target on the initiator. - initiator.wait_for_unit("default.target") - assert "${subnqn}" in initiator.succeed("nvme discover -t rdma -a target -s 4420") + clientnqn = initiator.succeed("nvme show-hostnqn") + target.succeed("nvmet subsystem add-host ${subnqn} " + clientnqn) + assert "${subnqn}" in initiator.succeed("nvme discover -t rdma -a target -s 4420 -q " + clientnqn) # Cleanup. target.succeed("nvmet namespace remove ${subnqn} 1") target.fail("test -e /sys/kernel/config/nvmet/subsystems/${subnqn}/namespaces/1") target.fail("nvmet namespace remove ${subnqn} 1") + target.succeed("nvmet port remove-subsystem 1 ${subnqn}") + assert "${subnqn}" not in target.succeed("nvmet port list-subsystems 1") + target.fail("test -e /sys/kernel/config/nvmet/ports/1/subsystems/${subnqn}") + target.succeed("nvmet subsystem remove ${subnqn}") target.fail("test -e /sys/kernel/config/nvmet/subsystems/${subnqn}") target.fail("nvmet subsystem remove ${subnqn}") @@ -102,6 +121,9 @@ target.fail("test -e /sys/kernel/config/nvmet/ports/1") target.fail("nvmet port remove 1") + target.fail("test -e /sys/kernel/config/nvmet/hosts/${initiator2}") + target.fail("test -e /sys/kernel/config/nvmet/subsystems/${subnqn}/allowed_hosts/${initiator2}") + # Export coverage. target.succeed("llvm-profdata merge --sparse -o /tmp/nvmetcfg.profdata /tmp/nvmetcfg-*.profraw") target.succeed("llvm-cov export -format=lcov -instr-profile=/tmp/nvmetcfg.profdata " + diff --git a/tests/tcp.nix b/tests/tcp.nix index 2f91004..ab5655b 100644 --- a/tests/tcp.nix +++ b/tests/tcp.nix @@ -28,6 +28,8 @@ }; testScript = let subnqn = "nqn.2023-11.sh.tty:nvmetcfg-test-loop"; + initiator1 = "nqn.2024-02.sh.tty:nvmetcfg-client1"; + initiator2 = "nqn.2024-02.sh.tty:nvmetcfg-client2"; in '' start_all() target.wait_for_unit("default.target") @@ -40,6 +42,20 @@ target.succeed("nvmet subsystem add ${subnqn}") assert "${subnqn}" in target.succeed("nvmet subsystem list") target.succeed("test -d /sys/kernel/config/nvmet/subsystems/${subnqn}") + + target.succeed("nvmet subsystem add-host ${subnqn} ${initiator1}") + target.succeed("test -d /sys/kernel/config/nvmet/hosts/${initiator1}") + target.succeed("test -d /sys/kernel/config/nvmet/subsystems/${subnqn}/allowed_hosts/${initiator1}") + assert "${initiator1}" in target.succeed("nvmet subsystem list-hosts ${subnqn}") + target.succeed("nvmet subsystem add-host ${subnqn} ${initiator2}") + target.succeed("test -d /sys/kernel/config/nvmet/hosts/${initiator2}") + target.succeed("test -d /sys/kernel/config/nvmet/subsystems/${subnqn}/allowed_hosts/${initiator2}") + assert "${initiator2}" in target.succeed("nvmet subsystem list-hosts ${subnqn}") + target.succeed("nvmet subsystem remove-host ${subnqn} ${initiator1}") + target.fail("test -e /sys/kernel/config/nvmet/hosts/${initiator1}") + target.fail("test -e /sys/kernel/config/nvmet/subsystems/${subnqn}/allowed_hosts/${initiator1}") + assert "${initiator1}" not in target.succeed("nvmet subsystem list-hosts ${subnqn}") + target.succeed("nvmet subsystem show") target.succeed("nvmet namespace add ${subnqn} 1 /dev/loop0") @@ -80,13 +96,19 @@ # Test the target on the initiator. initiator.wait_for_unit("default.target") - assert "${subnqn}" in initiator.succeed("nvme discover -t tcp -a target -s 4420") + clientnqn = initiator.succeed("nvme show-hostnqn") + target.succeed("nvmet subsystem add-host ${subnqn} " + clientnqn) + assert "${subnqn}" in initiator.succeed("nvme discover -t tcp -a target -s 4420 -q " + clientnqn) # Cleanup. target.succeed("nvmet namespace remove ${subnqn} 1") target.fail("test -e /sys/kernel/config/nvmet/subsystems/${subnqn}/namespaces/1") target.fail("nvmet namespace remove ${subnqn} 1") + target.succeed("nvmet port remove-subsystem 1 ${subnqn}") + assert "${subnqn}" not in target.succeed("nvmet port list-subsystems 1") + target.fail("test -e /sys/kernel/config/nvmet/ports/1/subsystems/${subnqn}") + target.succeed("nvmet subsystem remove ${subnqn}") target.fail("test -e /sys/kernel/config/nvmet/subsystems/${subnqn}") target.fail("nvmet subsystem remove ${subnqn}") @@ -95,6 +117,9 @@ target.fail("test -e /sys/kernel/config/nvmet/ports/1") target.fail("nvmet port remove 1") + target.fail("test -e /sys/kernel/config/nvmet/hosts/${initiator2}") + target.fail("test -e /sys/kernel/config/nvmet/subsystems/${subnqn}/allowed_hosts/${initiator2}") + # Export coverage. target.succeed("llvm-profdata merge --sparse -o /tmp/nvmetcfg.profdata /tmp/nvmetcfg-*.profraw") target.succeed("llvm-cov export -format=lcov -instr-profile=/tmp/nvmetcfg.profdata " +