summaryrefslogtreecommitdiff
path: root/tests/integration_tests
diff options
context:
space:
mode:
authorJames Falcon <TheRealFalcon@users.noreply.github.com>2021-01-26 11:25:04 -0600
committerGitHub <noreply@github.com>2021-01-26 12:25:04 -0500
commita9c904dc6438c908cd5341312311dfbbb18c81d2 (patch)
tree6d15e0b32a4a7f7160811225b1449ab4782cbb28 /tests/integration_tests
parent1527efa740ce7e66d9506ea62b0b8010d71a4104 (diff)
downloadvyos-cloud-init-a9c904dc6438c908cd5341312311dfbbb18c81d2.tar.gz
vyos-cloud-init-a9c904dc6438c908cd5341312311dfbbb18c81d2.zip
Remove 'remove-raise-on-failure' calls from integration_tests (#788)
pycloudlib no longer raises exceptions when cloud-init fails to start, and the API has been updated accordingly. Changes have been made to integration tests accordingly
Diffstat (limited to 'tests/integration_tests')
-rw-r--r--tests/integration_tests/bugs/test_gh570.py3
-rw-r--r--tests/integration_tests/bugs/test_lp1900837.py3
-rw-r--r--tests/integration_tests/clouds.py14
-rw-r--r--tests/integration_tests/instances.py13
-rw-r--r--tests/integration_tests/modules/test_power_state_change.py4
-rw-r--r--tests/integration_tests/test_upgrade.py7
6 files changed, 17 insertions, 27 deletions
diff --git a/tests/integration_tests/bugs/test_gh570.py b/tests/integration_tests/bugs/test_gh570.py
index b8866edd..534cfb9a 100644
--- a/tests/integration_tests/bugs/test_gh570.py
+++ b/tests/integration_tests/bugs/test_gh570.py
@@ -34,5 +34,6 @@ def test_nocloud_seedfrom_vendordata(client: IntegrationInstance):
VENDOR_DATA,
)
client.execute('cloud-init clean --logs')
- client.restart(raise_on_cloudinit_failure=True)
+ client.restart()
+ assert client.execute('cloud-init status').ok
assert 'seeded_vendordata_test_file' in client.execute('ls /var/tmp')
diff --git a/tests/integration_tests/bugs/test_lp1900837.py b/tests/integration_tests/bugs/test_lp1900837.py
index 395cace0..fcc2b751 100644
--- a/tests/integration_tests/bugs/test_lp1900837.py
+++ b/tests/integration_tests/bugs/test_lp1900837.py
@@ -22,7 +22,8 @@ class TestLogPermissionsNotResetOnReboot:
assert "600" == _get_log_perms(client)
# Reboot
- client.restart(raise_on_cloudinit_failure=True)
+ client.restart()
+ assert client.execute('cloud-init status').ok
# Check that permissions are not reset on reboot
assert "600" == _get_log_perms(client)
diff --git a/tests/integration_tests/clouds.py b/tests/integration_tests/clouds.py
index 63240d17..9eebb10a 100644
--- a/tests/integration_tests/clouds.py
+++ b/tests/integration_tests/clouds.py
@@ -135,7 +135,7 @@ class IntegrationCloud(ABC):
pycloudlib_instance = self.cloud_instance.launch(**launch_kwargs)
return pycloudlib_instance
- def launch(self, user_data=None, launch_kwargs=None, wait=True,
+ def launch(self, user_data=None, launch_kwargs=None,
settings=integration_settings):
if launch_kwargs is None:
launch_kwargs = {}
@@ -147,13 +147,9 @@ class IntegrationCloud(ABC):
self.settings.EXISTING_INSTANCE_ID
)
return
- if 'wait' in launch_kwargs:
- raise Exception("Specify 'wait' directly to launch, "
- "not in 'launch_kwargs'")
kwargs = {
'image_id': self.image_id,
'user_data': user_data,
- 'wait': False,
}
kwargs.update(launch_kwargs)
log.info(
@@ -163,11 +159,9 @@ class IntegrationCloud(ABC):
)
pycloudlib_instance = self._perform_launch(kwargs)
- if wait:
- pycloudlib_instance.wait(raise_on_cloudinit_failure=False)
log.info('Launched instance: %s', pycloudlib_instance)
instance = self.get_instance(pycloudlib_instance, settings)
- if wait:
+ if kwargs.get('wait', True):
# If we aren't waiting, we can't rely on command execution here
log.info(
'cloud-init version: %s',
@@ -277,7 +271,7 @@ class _LxdIntegrationCloud(IntegrationCloud):
def _perform_launch(self, launch_kwargs):
launch_kwargs['inst_type'] = launch_kwargs.pop('instance_type', None)
- launch_kwargs.pop('wait')
+ wait = launch_kwargs.pop('wait', True)
release = launch_kwargs.pop('image_id')
try:
@@ -293,7 +287,7 @@ class _LxdIntegrationCloud(IntegrationCloud):
)
if self.settings.CLOUD_INIT_SOURCE == 'IN_PLACE':
self._mount_source(pycloudlib_instance)
- pycloudlib_instance.start(wait=False)
+ pycloudlib_instance.start(wait=wait)
return pycloudlib_instance
diff --git a/tests/integration_tests/instances.py b/tests/integration_tests/instances.py
index 4321ce07..0d1e1aef 100644
--- a/tests/integration_tests/instances.py
+++ b/tests/integration_tests/instances.py
@@ -56,18 +56,13 @@ class IntegrationInstance:
def destroy(self):
self.instance.delete()
- def restart(self, raise_on_cloudinit_failure=False):
+ def restart(self):
"""Restart this instance (via cloud mechanism) and wait for boot.
- This wraps pycloudlib's `BaseInstance.restart` to pass
- `raise_on_cloudinit_failure=False` to `BaseInstance.wait`, mirroring
- our launch behaviour.
+ This wraps pycloudlib's `BaseInstance.restart`
"""
- self.instance.restart(wait=False)
- log.info("Instance restarted; waiting for boot")
- self.instance.wait(
- raise_on_cloudinit_failure=raise_on_cloudinit_failure
- )
+ log.info("Restarting instance and waiting for boot")
+ self.instance.restart()
def execute(self, command, *, use_sudo=True) -> Result:
if self.instance.username == 'root' and use_sudo is False:
diff --git a/tests/integration_tests/modules/test_power_state_change.py b/tests/integration_tests/modules/test_power_state_change.py
index 844dccfa..32dfc86d 100644
--- a/tests/integration_tests/modules/test_power_state_change.py
+++ b/tests/integration_tests/modules/test_power_state_change.py
@@ -27,13 +27,13 @@ def _detect_reboot(instance: IntegrationInstance):
# detecting the first boot or second boot, so we also check
# the logs to ensure we've booted twice. If the logs show we've
# only booted once, wait until we've booted twice
- instance.instance.wait(raise_on_cloudinit_failure=False)
+ instance.instance.wait()
for _ in range(600):
try:
log = instance.read_from_file('/var/log/cloud-init.log')
boot_count = log.count("running 'init-local'")
if boot_count == 1:
- instance.instance.wait(raise_on_cloudinit_failure=False)
+ instance.instance.wait()
elif boot_count > 1:
break
except Exception:
diff --git a/tests/integration_tests/test_upgrade.py b/tests/integration_tests/test_upgrade.py
index 660d363f..233a574b 100644
--- a/tests/integration_tests/test_upgrade.py
+++ b/tests/integration_tests/test_upgrade.py
@@ -43,15 +43,14 @@ def _output_to_compare(instance, file_path, netcfg_path):
def _restart(instance):
# work around pad.lv/1908287
- try:
- instance.restart(raise_on_cloudinit_failure=True)
- except OSError as e:
+ instance.restart()
+ if not instance.execute('cloud-init status --wait --long').ok:
for _ in range(10):
time.sleep(5)
result = instance.execute('cloud-init status --wait --long')
if result.ok:
return
- raise e
+ raise Exception("Cloud-init didn't finish starting up")
@pytest.mark.sru_2020_11