Skip to content

Commit

Permalink
tests: add OS_IMAGE_TYPE setting to allow for minimal tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
blackboxsw committed Sep 10, 2024
1 parent 82efd3e commit 746a75a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion integration-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tests/integration_tests/clouds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 10 additions & 2 deletions tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
11 changes: 11 additions & 0 deletions tests/integration_tests/integration_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 746a75a

Please sign in to comment.