Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add OS_IMAGE_TYPE setting to allow for minimal tests #5682

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# One of the following:
# One of the following pycloudlib.cloud.ImageType values:

This should sufficiently add context per brett's comment below

# - generic
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do these names come from? I assume that this is a pycloudlib construct? Can we please include a pointer to wherever in pycloudlib this is documented to ease future maintenance of this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These come from the ImageType enum in pycloudlib. (pycloudlib.cloud.ImageType)

# - minimal
# - Pro
# - Pro FIPS
OS_IMAGE_TYPE = "generic"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We keep talking about additional OS support, and this one comes across as being Ubuntu-specific in a way that might encourage a bunch of OS-specific fields to proliferate across various OSes. We could try to encode this into OS_IMAGE, but I'm also wondering if it might be time for a new abstraction for all the various ways of specifying an image (e.g., differentiating amd64/arm is on the horizon too).

I think I'm ok with this now, but if we have to add another dimension to our image specification, I think we need a better solution.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheRealFalcon: from the looks of other distribution vendors , there are similar alternative "offers" such as BYOS (bring your own subscription) images, HA and minimal images. I wonder if it is worth representing an optional "::offering" segment in
OS_IMAGE of the format
<image_id>[::<os>::<release>::<version>[::<offer-name>]]

This way we'd still have the ability to configure a known offer stream of images for Ubuntu, without bloating integration-settings.py options with yet another config param.

In the absence of offer-name, we'd assume generic, otherwise any string could be provided. From Ubuntu perspective, we could provide (generic|minimal|Pro|Pro FIPS). In the future, other vendors could provide BYOS, minimal, OSA(openshift app), etc.

For other distro support, I think we may have to rethink how we use pycloudlib.cloud.ImageType and maybe rename that OfferType to better align with how clouds label separate product images from vendors.


# 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
Loading