summaryrefslogtreecommitdiff
path: root/tests/integration_tests/datasources/test_network_dependency.py
diff options
context:
space:
mode:
authorJames Falcon <james.falcon@canonical.com>2021-11-02 11:11:26 -0500
committerGitHub <noreply@github.com>2021-11-02 11:11:26 -0500
commitd54e23bf61bb61af9aef3b30f41084d93961b7e3 (patch)
tree0f2a77f068da7f3cb6db2b0096b1074675dcc5ed /tests/integration_tests/datasources/test_network_dependency.py
parent773765346ba543987aa64a1119fa760f0b1cbb6f (diff)
downloadvyos-cloud-init-d54e23bf61bb61af9aef3b30f41084d93961b7e3.tar.gz
vyos-cloud-init-d54e23bf61bb61af9aef3b30f41084d93961b7e3.zip
testing: Remove calls to 'install_new_cloud_init' (#1092)
In our integration tests, a few tests were modifying the environment and then calling 'install_new_cloud_init'. This is problematic because it updates the environment for all future tests. Other instances of 'install_new_cloud_init' aren't problematic because they aren't modifying the underlying environment.
Diffstat (limited to 'tests/integration_tests/datasources/test_network_dependency.py')
-rw-r--r--tests/integration_tests/datasources/test_network_dependency.py33
1 files changed, 11 insertions, 22 deletions
diff --git a/tests/integration_tests/datasources/test_network_dependency.py b/tests/integration_tests/datasources/test_network_dependency.py
index 2e5e3121..24e71f9d 100644
--- a/tests/integration_tests/datasources/test_network_dependency.py
+++ b/tests/integration_tests/datasources/test_network_dependency.py
@@ -1,41 +1,30 @@
import pytest
-from tests.integration_tests.clouds import IntegrationCloud
-from tests.integration_tests.conftest import get_validated_source
+from tests.integration_tests.instances import IntegrationInstance
-def _setup_custom_image(session_cloud: IntegrationCloud):
- """Like `setup_image` in conftest.py, but with customized content."""
- source = get_validated_source(session_cloud)
- if not source.installs_new_version():
- return
- client = session_cloud.launch()
-
+def _customize_envionment(client: IntegrationInstance):
# Insert our "disable_network_activation" file here
client.write_to_file(
'/etc/cloud/cloud.cfg.d/99-disable-network-activation.cfg',
'disable_network_activation: true\n',
)
-
- client.install_new_cloud_init(source)
- # Even if we're keeping instances, we don't want to keep this
- # one around as it was just for image creation
- client.destroy()
+ client.execute('cloud-init clean --logs')
+ client.restart()
# This test should be able to work on any cloud whose datasource specifies
# a NETWORK dependency
@pytest.mark.gce
@pytest.mark.ubuntu # Because netplan
-def test_network_activation_disabled(session_cloud: IntegrationCloud):
+def test_network_activation_disabled(client: IntegrationInstance):
"""Test that the network is not activated during init mode."""
- _setup_custom_image(session_cloud)
- with session_cloud.launch() as client:
- result = client.execute('systemctl status google-guest-agent.service')
- if not result.ok:
- raise AssertionError('google-guest-agent is not active:\n%s',
- result.stdout)
- log = client.read_from_file('/var/log/cloud-init.log')
+ _customize_envionment(client)
+ result = client.execute('systemctl status google-guest-agent.service')
+ if not result.ok:
+ raise AssertionError(
+ 'google-guest-agent is not active:\n%s', result.stdout)
+ log = client.read_from_file('/var/log/cloud-init.log')
assert "Running command ['netplan', 'apply']" not in log