Skip to content

Commit fc9260a

Browse files
committed
feat: Skip llama-stack tests if OpenShift < 4.17
Signed-off-by: Jorge Garcia Oncins <jgarciao@redhat.com>
1 parent daffb16 commit fc9260a

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

tests/llama_stack/conftest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
from utilities.constants import DscComponents, Timeout
2020
from utilities.data_science_cluster_utils import update_components_in_dsc
2121
from tests.llama_stack.constants import (
22+
LLS_OPENSHIFT_MINIMAL_VERSION,
2223
ModelInfo,
2324
)
25+
from utilities.infra import get_openshift_version
2426

2527

2628
LOGGER = get_logger(name=__name__)
@@ -216,6 +218,19 @@ def _get_llama_stack_distribution_deployment(
216218
yield deployment
217219

218220

221+
@pytest.fixture(scope="session", autouse=True)
222+
def skip_llama_stack_if_not_supported_openshift_version(admin_client: DynamicClient) -> None:
223+
"""Skip llama-stack tests if OpenShift version is not supported (< 4.17) by llama-stack-operator"""
224+
version = get_openshift_version(admin_client=admin_client)
225+
if version < LLS_OPENSHIFT_MINIMAL_VERSION:
226+
message = (
227+
f"Skipping llama-stack tests, as llama-stack-operator is not supported "
228+
f"on OpenShift {version} ({LLS_OPENSHIFT_MINIMAL_VERSION} or newer required)"
229+
)
230+
LOGGER.info(message)
231+
pytest.skip(reason=message)
232+
233+
219234
@pytest.fixture(scope="class")
220235
def unprivileged_llama_stack_distribution_deployment(
221236
unprivileged_client: DynamicClient,

tests/llama_stack/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from enum import Enum
33
from typing import List, NamedTuple, TypedDict
44
from llama_stack_client.types import Model
5+
from semver import VersionInfo
6+
import semver
57

68

79
class LlamaStackProviders:
@@ -26,6 +28,7 @@ class ModelInfo(NamedTuple):
2628

2729

2830
LLS_CORE_POD_FILTER: str = "app=llama-stack"
31+
LLS_OPENSHIFT_MINIMAL_VERSION: VersionInfo = semver.VersionInfo.parse("4.17.0")
2932

3033

3134
class TurnExpectation(TypedDict):

utilities/infra.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
)
2424
from ocp_resources.catalog_source import CatalogSource
2525
from ocp_resources.cluster_service_version import ClusterServiceVersion
26+
from ocp_resources.cluster_version import ClusterVersion
2627
from ocp_resources.config_map import ConfigMap
2728
from ocp_resources.config_imageregistry_operator_openshift_io import Config
2829
from ocp_resources.console_cli_download import ConsoleCLIDownload
@@ -611,6 +612,16 @@ def get_openshift_token() -> str:
611612
return run_command(command=shlex.split("oc whoami -t"))[1].strip()
612613

613614

615+
@cache
616+
def get_openshift_version(admin_client: DynamicClient) -> Version:
617+
"""Get the OpenShift cluster version."""
618+
cluster_version = ClusterVersion(client=admin_client, name="version")
619+
if not cluster_version:
620+
raise MissingResourceError("ClusterVersion not found")
621+
622+
return Version.parse(version=str(cluster_version.instance.status.desired.version))
623+
624+
614625
def get_kserve_storage_initialize_image(client: DynamicClient) -> str:
615626
"""
616627
Get the image used to storage-initializer.

0 commit comments

Comments
 (0)