summaryrefslogtreecommitdiff
path: root/tests/unittests/cmd
diff options
context:
space:
mode:
authorJames Falcon <james.falcon@canonical.com>2021-10-27 09:43:34 -0500
committerGitHub <noreply@github.com>2021-10-27 08:43:34 -0600
commit1d01da5d9916d97ef463ba61a36b3f98f8911419 (patch)
tree1022c172c252082a02f89d0e54a42221dabc1851 /tests/unittests/cmd
parent75b26b0afbb14cf613fe3b08c8bed050dec0b874 (diff)
downloadvyos-cloud-init-1d01da5d9916d97ef463ba61a36b3f98f8911419.tar.gz
vyos-cloud-init-1d01da5d9916d97ef463ba61a36b3f98f8911419.zip
Add "install hotplug" module (SC-476) (#1069)
This commit removes automatically installing udev rules for hotplug and adds a module to install them instead. Automatically including the udev rules and checking if hotplug was enabled consumed too many resources in certain circumstances. Moving the rules to a module ensures we don't spend extra extra cycles on hotplug if hotplug functionality isn't desired. LP: #1946003
Diffstat (limited to 'tests/unittests/cmd')
-rw-r--r--tests/unittests/cmd/devel/test_hotplug_hook.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/tests/unittests/cmd/devel/test_hotplug_hook.py b/tests/unittests/cmd/devel/test_hotplug_hook.py
index 63d2490e..e1c64e2f 100644
--- a/tests/unittests/cmd/devel/test_hotplug_hook.py
+++ b/tests/unittests/cmd/devel/test_hotplug_hook.py
@@ -30,6 +30,11 @@ def mocks():
return_value=FAKE_MAC
)
+ update_event_enabled = mock.patch(
+ 'cloudinit.stages.update_event_enabled',
+ return_value=True,
+ )
+
m_network_state = mock.MagicMock(spec=NetworkState)
parse_net = mock.patch(
'cloudinit.cmd.devel.hotplug_hook.parse_net_config_data',
@@ -45,6 +50,7 @@ def mocks():
sleep = mock.patch('time.sleep')
read_sys_net.start()
+ update_event_enabled.start()
parse_net.start()
select_activator.start()
m_sleep = sleep.start()
@@ -57,6 +63,7 @@ def mocks():
)
read_sys_net.stop()
+ update_event_enabled.stop()
parse_net.stop()
select_activator.stop()
sleep.stop()
@@ -122,13 +129,16 @@ class TestHotplug:
def test_update_event_disabled(self, mocks, caplog):
init = mocks.m_init
- init.update_event_enabled.return_value = False
- handle_hotplug(
- hotplug_init=init,
- devpath='/dev/fake',
- udevaction='remove',
- subsystem='net'
- )
+ with mock.patch(
+ 'cloudinit.stages.update_event_enabled',
+ return_value=False
+ ):
+ handle_hotplug(
+ hotplug_init=init,
+ devpath='/dev/fake',
+ udevaction='remove',
+ subsystem='net'
+ )
assert 'hotplug not enabled for event of type' in caplog.text
init.datasource.update_metadata_if_supported.assert_not_called()
mocks.m_activator.bring_up_interface.assert_not_called()