summaryrefslogtreecommitdiff
path: root/tests/integration_tests/modules/test_user_events.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration_tests/modules/test_user_events.py')
-rw-r--r--tests/integration_tests/modules/test_user_events.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/tests/integration_tests/modules/test_user_events.py b/tests/integration_tests/modules/test_user_events.py
index a45cad72..ee8f05ae 100644
--- a/tests/integration_tests/modules/test_user_events.py
+++ b/tests/integration_tests/modules/test_user_events.py
@@ -31,9 +31,12 @@ def _add_dummy_bridge_to_netplan(client: IntegrationInstance):
@pytest.mark.gce
@pytest.mark.oci
@pytest.mark.openstack
+@pytest.mark.azure
@pytest.mark.not_xenial
def test_boot_event_disabled_by_default(client: IntegrationInstance):
log = client.read_from_file('/var/log/cloud-init.log')
+ if 'network config is disabled' in log:
+ pytest.skip("network config disabled. Test doesn't apply")
assert 'Applying network configuration' in log
assert 'dummy0' not in client.execute('ls /sys/class/net')
@@ -43,6 +46,12 @@ def test_boot_event_disabled_by_default(client: IntegrationInstance):
client.restart()
log2 = client.read_from_file('/var/log/cloud-init.log')
+ if 'cache invalid in datasource' in log2:
+ # Invalid cache will get cleared, meaning we'll create a new
+ # "instance" and apply networking config, so events aren't
+ # really relevant here
+ pytest.skip("Test only valid for existing instances")
+
# We attempt to apply network config twice on every boot.
# Ensure neither time works.
assert 2 == len(
@@ -62,25 +71,27 @@ def test_boot_event_disabled_by_default(client: IntegrationInstance):
def _test_network_config_applied_on_reboot(client: IntegrationInstance):
log = client.read_from_file('/var/log/cloud-init.log')
+ if 'network config is disabled' in log:
+ pytest.skip("network config disabled. Test doesn't apply")
assert 'Applying network configuration' in log
assert 'dummy0' not in client.execute('ls /sys/class/net')
_add_dummy_bridge_to_netplan(client)
client.execute('rm /var/log/cloud-init.log')
client.restart()
+
log = client.read_from_file('/var/log/cloud-init.log')
+ if 'cache invalid in datasource' in log:
+ # Invalid cache will get cleared, meaning we'll create a new
+ # "instance" and apply networking config, so events aren't
+ # really relevant here
+ pytest.skip("Test only valid for existing instances")
assert 'Event Allowed: scope=network EventType=boot' in log
assert 'Applying network configuration' in log
assert 'dummy0' not in client.execute('ls /sys/class/net')
-@pytest.mark.azure
-@pytest.mark.not_xenial
-def test_boot_event_enabled_by_default(client: IntegrationInstance):
- _test_network_config_applied_on_reboot(client)
-
-
USER_DATA = """\
#cloud-config
updates: