summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJames Falcon <therealfalcon@gmail.com>2021-08-13 15:34:16 -0500
committerGitHub <noreply@github.com>2021-08-13 15:34:16 -0500
commit65607405aed2fb5e7797bb181dc947025c10f346 (patch)
tree2b01bb7804682a5c16bcd2bfda81efb3c610bcf1 /tests
parentf516a7d37c1654addc02485e681b4358d7e7c0db (diff)
downloadvyos-cloud-init-65607405aed2fb5e7797bb181dc947025c10f346.tar.gz
vyos-cloud-init-65607405aed2fb5e7797bb181dc947025c10f346.zip
Only invoke hotplug socket when functionality is enabled (#952)
Alters hotplug hook to have a query mechanism checking if the functionality is enabled. This allows us to avoid using the hotplug socket and service when hotplug is disabled.
Diffstat (limited to 'tests')
-rw-r--r--tests/integration_tests/modules/test_hotplug.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/integration_tests/modules/test_hotplug.py b/tests/integration_tests/modules/test_hotplug.py
index b683566f..a42d1c8c 100644
--- a/tests/integration_tests/modules/test_hotplug.py
+++ b/tests/integration_tests/modules/test_hotplug.py
@@ -48,7 +48,7 @@ def test_hotplug_add_remove(client: IntegrationInstance):
# Add new NIC
added_ip = client.instance.add_network_interface()
- _wait_till_hotplug_complete(client)
+ _wait_till_hotplug_complete(client, expected_runs=2)
ips_after_add = _get_ip_addr(client)
new_addition = [ip for ip in ips_after_add if ip.ip4 == added_ip][0]
@@ -63,7 +63,7 @@ def test_hotplug_add_remove(client: IntegrationInstance):
# Remove new NIC
client.instance.remove_network_interface(added_ip)
- _wait_till_hotplug_complete(client, expected_runs=2)
+ _wait_till_hotplug_complete(client, expected_runs=4)
ips_after_remove = _get_ip_addr(client)
assert len(ips_after_remove) == len(ips_before)
assert added_ip not in [ip.ip4 for ip in ips_after_remove]
@@ -72,6 +72,10 @@ def test_hotplug_add_remove(client: IntegrationInstance):
config = yaml.safe_load(netplan_cfg)
assert new_addition.interface not in config['network']['ethernets']
+ assert 'enabled' == client.execute(
+ 'cloud-init devel hotplug-hook -s net query'
+ )
+
@pytest.mark.openstack
def test_no_hotplug_in_userdata(client: IntegrationInstance):
@@ -83,7 +87,7 @@ def test_no_hotplug_in_userdata(client: IntegrationInstance):
client.instance.add_network_interface()
_wait_till_hotplug_complete(client)
log = client.read_from_file('/var/log/cloud-init.log')
- assert 'hotplug not enabled for event of type network' in log
+ assert "Event Denied: scopes=['network'] EventType=hotplug" in log
ips_after_add = _get_ip_addr(client)
if len(ips_after_add) == len(ips_before) + 1:
@@ -92,3 +96,7 @@ def test_no_hotplug_in_userdata(client: IntegrationInstance):
assert new_ip.state == 'DOWN'
else:
assert len(ips_after_add) == len(ips_before)
+
+ assert 'disabled' == client.execute(
+ 'cloud-init devel hotplug-hook -s net query'
+ )