summaryrefslogtreecommitdiff
path: root/tests/unittests/test_curthooks.py
diff options
context:
space:
mode:
authorOlivier Gayot <[email protected]>2024-02-28 14:35:22 +0100
committerOlivier Gayot <[email protected]>2024-02-29 10:45:27 +0100
commit79d831871d32e396326106b5f05ba144e61badaa (patch)
tree8ddf130d98372d8e0f9fed61e0415af00afbd250 /tests/unittests/test_curthooks.py
parentc2cb445e6c5d311c543947812dc6555e0c2d8c80 (diff)
curthooks: nvmeotcp: check if network in initramfs is needed
To decide if we should bring up the network in the initramfs and then run `nvme connect-all` commands, we now look for mounpoints that have the `_netdev` option. Those are the ones that require the network to be up before mounting. If any of those mounpoints corresponds to something essential for booting (e.g., /, /usr, /var or alike), then we decide that the network is required in the initramfs. Signed-off-by: Olivier Gayot <[email protected]>
Diffstat (limited to 'tests/unittests/test_curthooks.py')
-rw-r--r--tests/unittests/test_curthooks.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/unittests/test_curthooks.py b/tests/unittests/test_curthooks.py
index 88d40fcf..61cad9f4 100644
--- a/tests/unittests/test_curthooks.py
+++ b/tests/unittests/test_curthooks.py
@@ -2243,6 +2243,69 @@ network:
]
self.assertEqual(expected, curthooks.nvmeotcp_get_ip_commands(cfg))
+ def test_nvmeotcp_need_network_in_initramfs__usr_is_netdev(self):
+ self.assertTrue(curthooks.nvmeotcp_need_network_in_initramfs({
+ "storage": {
+ "config": [
+ {
+ "type": "mount",
+ "path": "/usr",
+ "options": "default,_netdev",
+ }, {
+ "type": "mount",
+ "path": "/",
+ }, {
+ "type": "mount",
+ "path": "/boot",
+ },
+ ],
+ },
+ }))
+
+ def test_nvmeotcp_need_network_in_initramfs__rootfs_is_netdev(self):
+ self.assertTrue(curthooks.nvmeotcp_need_network_in_initramfs({
+ "storage": {
+ "config": [
+ {
+ "type": "mount",
+ "path": "/",
+ "options": "default,_netdev",
+ }, {
+ "type": "mount",
+ "path": "/boot",
+ },
+ ],
+ },
+ }))
+
+ def test_nvmeotcp_need_network_in_initramfs__only_home_is_netdev(self):
+ self.assertFalse(curthooks.nvmeotcp_need_network_in_initramfs({
+ "storage": {
+ "config": [
+ {
+ "type": "mount",
+ "path": "/home",
+ "options": "default,_netdev",
+ }, {
+ "type": "mount",
+ "path": "/",
+ },
+ ],
+ },
+ }))
+
+ def test_nvmeotcp_need_network_in_initramfs__empty_conf(self):
+ self.assertFalse(curthooks.nvmeotcp_need_network_in_initramfs({}))
+ self.assertFalse(curthooks.nvmeotcp_need_network_in_initramfs(
+ {"storage": False}))
+ self.assertFalse(curthooks.nvmeotcp_need_network_in_initramfs(
+ {"storage": {}}))
+ self.assertFalse(curthooks.nvmeotcp_need_network_in_initramfs({
+ "storage": {
+ "config": "disabled",
+ },
+ }))
+
class TestUefiFindGrubDeviceIds(CiTestCase):