From 746a75a083d9c2f1285b8fc876bf5f27b3392c5f Mon Sep 17 00:00:00 2001 From: Chad Smith Date: Mon, 9 Sep 2024 21:53:48 -0600 Subject: [PATCH] tests: add OS_IMAGE_TYPE setting to allow for minimal tests Allow setting CLOUD_INIT_OS_IMAGE_TYPE="mimimal" to support running the full integration test suite against Ubuntu minimal images. Required for SC-1750: Daily jenkins ubuntu minimal test runner for Ubuntu Focal, Jammy and Noble releases. --- integration-requirements.txt | 2 +- tests/integration_tests/clouds.py | 5 +++++ tests/integration_tests/conftest.py | 12 ++++++++++-- tests/integration_tests/integration_settings.py | 11 +++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/integration-requirements.txt b/integration-requirements.txt index a34b63e70727..c1a8336b0dfd 100644 --- a/integration-requirements.txt +++ b/integration-requirements.txt @@ -2,7 +2,7 @@ # PyPI requirements for cloud-init integration testing # https://cloudinit.readthedocs.io/en/latest/topics/integration_tests.html # -pycloudlib>=1!6.7.0,<1!8 +pycloudlib>=1!9.1.0,<1!10 # Avoid breaking change in `testpaths` treatment forced # test/unittests/conftest.py to be loaded by our integration-tests tox env diff --git a/tests/integration_tests/clouds.py b/tests/integration_tests/clouds.py index 82acde409e2d..345d1545887a 100644 --- a/tests/integration_tests/clouds.py +++ b/tests/integration_tests/clouds.py @@ -275,6 +275,11 @@ class _LxdIntegrationCloud(IntegrationCloud): instance_tag: str cloud_instance: _BaseLXD + def _get_initial_image(self, **kwargs) -> str: + return super()._get_initial_image( + image_type=self._image_type, **kwargs + ) + def _get_or_set_profile_list(self, release): return None diff --git a/tests/integration_tests/conftest.py b/tests/integration_tests/conftest.py index 8ba5a81b2b5b..0efb31c1daaf 100644 --- a/tests/integration_tests/conftest.py +++ b/tests/integration_tests/conftest.py @@ -12,6 +12,7 @@ from typing import Dict, Generator, Iterator, List, Type import pytest +from pycloudlib.cloud import ImageType from pycloudlib.lxd.instance import LXDInstance from tests.integration_tests import integration_settings @@ -80,8 +81,15 @@ def session_cloud() -> Generator[IntegrationCloud, None, None]: f"{integration_settings.PLATFORM} is an invalid PLATFORM " f"specified in settings. Must be one of {list(platforms.keys())}" ) - - cloud = platforms[integration_settings.PLATFORM]() + image_types = [member.value for member in ImageType.__members__.values()] + try: + image_type = ImageType(integration_settings.OS_IMAGE_TYPE) + except ValueError: + raise ValueError( + f"{integration_settings.OS_IMAGE_TYPE} is an invalid OS_IMAGE_TYPE" + f" specified in settings. Must be one of {image_types}" + ) + cloud = platforms[integration_settings.PLATFORM](image_type=image_type) cloud.emit_settings_to_log() yield cloud cloud.destroy() diff --git a/tests/integration_tests/integration_settings.py b/tests/integration_tests/integration_settings.py index 368943c0d1cf..ce8ec94e4c0d 100644 --- a/tests/integration_tests/integration_settings.py +++ b/tests/integration_tests/integration_settings.py @@ -39,6 +39,17 @@ # to this format internally; in this case, to "None::ubuntu::focal::20.04".) OS_IMAGE = "focal" + +# Determines unique image type or flavor to exercise if the cloud supports +# image-type lookup for daily_image and released_images. +# +# One of the following: +# - generic +# - minimal +# - Pro +# - Pro FIPS +OS_IMAGE_TYPE = "generic" + # Populate if you want to use a pre-launched instance instead of # creating a new one. The exact contents will be platform dependent EXISTING_INSTANCE_ID: Optional[str] = None