diff options
author | Daniel Watkins <oddbloke@ubuntu.com> | 2020-12-09 18:11:18 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-09 18:11:18 -0500 |
commit | 05216aa37e1fad32433dbea102dc3ceae7d8565d (patch) | |
tree | cc705070832bbba8f0776bfa43041bb631d8a4da /tests/integration_tests/conftest.py | |
parent | 17ca02e10623b12065532b26de9cefcccee0062c (diff) | |
download | vyos-cloud-init-05216aa37e1fad32433dbea102dc3ceae7d8565d.tar.gz vyos-cloud-init-05216aa37e1fad32433dbea102dc3ceae7d8565d.zip |
integration_tests: add test for LP: #1898997 (#713)
integration_tests: add test for LP: #1898997
This introduces the `lxd_config_dict` mark, used to specify a
free-form configuration dict to LXD for tests which only run there; and
the `not_xenial` and `not_bionic` marks, used to skip tests on
xenial/bionic via a basic release skipping mechanism.
This also bumps the pycloudlib commit we depend upon, as
the latest commit includes the changes required for LXD network config
to work.
(The `lxd_config_dict` change further complicated `_client`, so a minor
refactoring is applied.)
Diffstat (limited to 'tests/integration_tests/conftest.py')
-rw-r--r-- | tests/integration_tests/conftest.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/tests/integration_tests/conftest.py b/tests/integration_tests/conftest.py index 53ca5fb5..50b300c4 100644 --- a/tests/integration_tests/conftest.py +++ b/tests/integration_tests/conftest.py @@ -1,5 +1,6 @@ # This file is part of cloud-init. See LICENSE file for license information. import datetime +import functools import logging import pytest import os @@ -18,6 +19,7 @@ from tests.integration_tests.clouds import ( LxdContainerCloud, LxdVmCloud, OciCloud, + _LxdIntegrationCloud, ) from tests.integration_tests.instances import ( CloudInitSource, @@ -74,6 +76,10 @@ def pytest_runtest_setup(item): if 'unstable' in test_marks and not integration_settings.RUN_UNSTABLE: pytest.skip('Test marked unstable. Manually remove mark to run it') + current_release = image.release + if "not_{}".format(current_release) in test_marks: + pytest.skip("Cannot run on release {}".format(current_release)) + # disable_subp_usage is defined at a higher level, but we don't # want it applied here @@ -184,14 +190,21 @@ def _client(request, fixture_utils, session_cloud: IntegrationCloud): Launch the dynamic IntegrationClient instance using any provided userdata, yield to the test, then cleanup """ - user_data = fixture_utils.closest_marker_first_arg_or( - request, 'user_data', None) - name = fixture_utils.closest_marker_first_arg_or( - request, 'instance_name', None + getter = functools.partial( + fixture_utils.closest_marker_first_arg_or, request, default=None ) + user_data = getter('user_data') + name = getter('instance_name') + lxd_config_dict = getter('lxd_config_dict') + launch_kwargs = {} if name is not None: - launch_kwargs = {"name": name} + launch_kwargs["name"] = name + if lxd_config_dict is not None: + if not isinstance(session_cloud, _LxdIntegrationCloud): + pytest.skip("lxd_config_dict requires LXD") + launch_kwargs["config_dict"] = lxd_config_dict + with session_cloud.launch( user_data=user_data, launch_kwargs=launch_kwargs ) as instance: |