summaryrefslogtreecommitdiff
path: root/tests/unittests/test_curthooks.py
diff options
context:
space:
mode:
authorOlivier Gayot <[email protected]>2024-02-27 19:45:07 +0100
committerOlivier Gayot <[email protected]>2024-02-29 10:45:27 +0100
commit8992f50269deb65bffc1d287ea31db4fcd06b25d (patch)
tree7fdfbb79d666d8515c27feff4025634fc4e08cc3 /tests/unittests/test_curthooks.py
parentf41ff8a622bcba6473c9470fb54d3ad4c4df8b2e (diff)
curthooks: nvmeotcp: run nvme connect-all commands in the initramfs
If the network is required in the initramfs for NVMe over TCP, we now execute a set of `nvme connect-all` commands as required by the NVMe over TCP configuration. Signed-off-by: Olivier Gayot <[email protected]>
Diffstat (limited to 'tests/unittests/test_curthooks.py')
-rw-r--r--tests/unittests/test_curthooks.py91
1 files changed, 91 insertions, 0 deletions
diff --git a/tests/unittests/test_curthooks.py b/tests/unittests/test_curthooks.py
index a0d60c4e..8c39f6a8 100644
--- a/tests/unittests/test_curthooks.py
+++ b/tests/unittests/test_curthooks.py
@@ -2093,6 +2093,97 @@ class TestCurthooksNVMeOverTCP(CiTestCase):
},
}))
+ def test_nvmeotcp_get_nvme_commands__no_nvme_controller(self):
+ self.assertFalse(curthooks.nvmeotcp_get_nvme_commands({
+ "storage": {
+ "config": [
+ {"type": "partition"},
+ {"type": "mount"},
+ {"type": "disk"},
+ ],
+ },
+ }))
+
+ def test_nvmeotcp_get_nvme_commands__pcie_controller(self):
+ self.assertFalse(curthooks.nvmeotcp_get_nvme_commands({
+ "storage": {
+ "config": [
+ {"type": "nvme_controller", "transport": "pcie"},
+ ],
+ },
+ }))
+
+ def test_nvmeotcp_get_nvme_commands__tcp_controller(self):
+ expected = [(
+ "nvme", "connect-all",
+ "--transport", "tcp",
+ "--traddr", "1.2.3.4",
+ "--trsvcid", "1111",
+ ),
+ ]
+
+ result = curthooks.nvmeotcp_get_nvme_commands({
+ "storage": {
+ "config": [
+ {
+ "type": "nvme_controller",
+ "transport": "tcp",
+ "tcp_addr": "1.2.3.4",
+ "tcp_port": "1111",
+ },
+ ],
+ },
+ })
+ self.assertEqual(expected, result)
+
+ def test_nvmeotcp_get_nvme_commands__three_nvme_controllers(self):
+ expected = [(
+ "nvme", "connect-all",
+ "--transport", "tcp",
+ "--traddr", "1.2.3.4",
+ "--trsvcid", "1111",
+ ), (
+ "nvme", "connect-all",
+ "--transport", "tcp",
+ "--traddr", "4.5.6.7",
+ "--trsvcid", "1212",
+ ),
+ ]
+
+ result = curthooks.nvmeotcp_get_nvme_commands({
+ "storage": {
+ "config": [
+ {
+ "type": "nvme_controller",
+ "transport": "tcp",
+ "tcp_addr": "1.2.3.4",
+ "tcp_port": "1111",
+ }, {
+ "type": "nvme_controller",
+ "transport": "tcp",
+ "tcp_addr": "4.5.6.7",
+ "tcp_port": "1212",
+ }, {
+ "type": "nvme_controller",
+ "transport": "pcie",
+ },
+ ],
+ },
+ })
+ self.assertEqual(expected, result)
+
+ def test_nvmeotcp_get_nvme_commands__empty_conf(self):
+ self.assertFalse(curthooks.nvmeotcp_get_nvme_commands({}))
+ self.assertFalse(curthooks.nvmeotcp_get_nvme_commands(
+ {"storage": False}))
+ self.assertFalse(curthooks.nvmeotcp_get_nvme_commands(
+ {"storage": {}}))
+ self.assertFalse(curthooks.nvmeotcp_get_nvme_commands({
+ "storage": {
+ "config": "disabled",
+ },
+ }))
+
class TestUefiFindGrubDeviceIds(CiTestCase):