diff options
author | James Falcon <TheRealFalcon@users.noreply.github.com> | 2020-12-15 13:11:48 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-15 14:11:48 -0500 |
commit | ca49e27b21ccc65ec20a10fd8e085bec36d5bf3d (patch) | |
tree | f802fce24da8e0ca03a4335776685615656cb1ab /tests/integration_tests | |
parent | 2af3f6d7247d0ef0dd3d4c287c8d8e71fda5173a (diff) | |
download | vyos-cloud-init-ca49e27b21ccc65ec20a10fd8e085bec36d5bf3d.tar.gz vyos-cloud-init-ca49e27b21ccc65ec20a10fd8e085bec36d5bf3d.zip |
Some test_upgrade fixes (#726)
- workaround pad.lv/1908287 for restarting instances
- move wait param from launch_kwargs to launch call
- remove name param as it's not universally supported
- add platform to log names
Diffstat (limited to 'tests/integration_tests')
-rw-r--r-- | tests/integration_tests/test_upgrade.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/tests/integration_tests/test_upgrade.py b/tests/integration_tests/test_upgrade.py index 78fbc992..76ad055b 100644 --- a/tests/integration_tests/test_upgrade.py +++ b/tests/integration_tests/test_upgrade.py @@ -1,5 +1,6 @@ import logging import pytest +import time from pathlib import Path from tests.integration_tests.clouds import ImageSpecification, IntegrationCloud @@ -40,6 +41,19 @@ def _output_to_compare(instance, file_path, netcfg_path): f.write(instance.execute(command) + '\n') +def _restart(instance): + # work around pad.lv/1908287 + try: + instance.restart(raise_on_cloudinit_failure=True) + except OSError as e: + for _ in range(10): + time.sleep(5) + result = instance.execute('cloud-init status --wait --long') + if result.ok: + return + raise e + + @pytest.mark.sru_2020_11 def test_upgrade(session_cloud: IntegrationCloud): source = get_validated_source() @@ -50,9 +64,7 @@ def test_upgrade(session_cloud: IntegrationCloud): return # type checking doesn't understand that skip raises launch_kwargs = { - 'name': 'integration-upgrade-test', 'image_id': session_cloud._get_initial_image(), - 'wait': True, } image = ImageSpecification.from_os_image() @@ -60,7 +72,8 @@ def test_upgrade(session_cloud: IntegrationCloud): # Get the paths to write test logs output_dir = Path(session_cloud.settings.LOCAL_LOG_PATH) output_dir.mkdir(parents=True, exist_ok=True) - base_filename = 'test_upgrade_{os}_{{stage}}_{time}.log'.format( + base_filename = 'test_upgrade_{platform}_{os}_{{stage}}_{time}.log'.format( + platform=session_cloud.settings.PLATFORM, os=image.release, time=session_start_time, ) @@ -75,12 +88,12 @@ def test_upgrade(session_cloud: IntegrationCloud): netcfg_path = '/etc/network/interfaces.d/50-cloud-init.cfg' with session_cloud.launch( - launch_kwargs=launch_kwargs, user_data=USER_DATA + launch_kwargs=launch_kwargs, user_data=USER_DATA, wait=True, ) as instance: _output_to_compare(instance, before_path, netcfg_path) instance.install_new_cloud_init(source, take_snapshot=False) instance.execute('hostname something-else') - instance.restart(raise_on_cloudinit_failure=True) + _restart(instance) _output_to_compare(instance, after_path, netcfg_path) log.info('Wrote upgrade test logs to %s and %s', before_path, after_path) |