Skip to content

Commit ea6f9ff

Browse files
Artemon-linepre-commit-ci[bot]
authored andcommitted
RHOAIENG-33693: Add LlamaStack image validation tests and related fixture (opendatahub-io#618)
* Add LlamaStack image validation tests and related fixture - Introduced a new fixture to retrieve the LlamaStack operator pod by label. - Added tests to verify that LlamaStack component images meet specified requirements, including image source and format. - Updated constants to include a label filter for the LlamaStack operator pod. * Add LlamaStack image validation tests and related fixture - Introduced a new fixture to retrieve the LlamaStack operator pod by label. - Added tests to verify that LlamaStack component images meet specified requirements, including image source and format. - Updated constants to include a label filter for the LlamaStack operator pod. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * refactor: update LlamaStack test fixtures and constants - Renamed the LlamaStack distribution fixture for clarity. - Updated the pod label filter constant to reflect the core pod. - Modified the image validation test to use the new pod fixture name. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * refactor: fix review suggestions * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 8a019af commit ea6f9ff

4 files changed

Lines changed: 69 additions & 1 deletion

File tree

tests/llama_stack/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def llama_stack_distribution(
107107
) -> Generator[LlamaStackDistribution, None, None]:
108108
with create_llama_stack_distribution(
109109
client=admin_client,
110-
name="llama-stack-distribution",
110+
name="test-lama-stack-distribution",
111111
namespace=model_namespace.name,
112112
replicas=1,
113113
server=llama_stack_server_config,

tests/llama_stack/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class Eval(str, Enum):
1616
TRUSTYAI_LMEVAL = "trustyai_lmeval"
1717

1818

19+
LLS_CORE_POD_FILTER: str = "app=llama-stack"
20+
21+
1922
@dataclass
2023
class TorchTuneTestExpectation:
2124
"""Test expectation for TorchTune documentation questions."""
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from typing import Generator, Any
2+
3+
import pytest
4+
from kubernetes.dynamic import DynamicClient
5+
6+
from ocp_resources.pod import Pod
7+
from tests.llama_stack.constants import LLS_CORE_POD_FILTER
8+
from utilities.general import wait_for_pods_by_labels
9+
10+
11+
@pytest.fixture(scope="class")
12+
def lls_pods(admin_client: DynamicClient, model_namespace) -> Generator[Pod, Any, Any]:
13+
"""Get the LLS core deployment pod."""
14+
yield wait_for_pods_by_labels(
15+
admin_client=admin_client,
16+
namespace=model_namespace.name,
17+
label_selector=LLS_CORE_POD_FILTER,
18+
expected_num_pods=1,
19+
)[0]
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from typing import Self, Set
2+
3+
from kubernetes.dynamic import DynamicClient
4+
from ocp_resources.pod import Pod
5+
import pytest
6+
from simple_logger.logger import get_logger
7+
8+
from utilities.general import validate_container_images
9+
10+
11+
LOGGER = get_logger(name=__name__)
12+
13+
14+
@pytest.mark.usefixtures("llama_stack_distribution")
15+
@pytest.mark.parametrize(
16+
"model_namespace",
17+
[
18+
pytest.param(
19+
{"name": "test-llamastack-image-validation"},
20+
)
21+
],
22+
indirect=True,
23+
)
24+
@pytest.mark.rawdeployment
25+
@pytest.mark.downstream_only
26+
class TestLLSImages:
27+
"""
28+
Tests to verify that LLS (LlamaStack) Distribution image meets the requirements:
29+
1. Images are hosted in registry.redhat.io
30+
2. Images use sha256 digest instead of tags
31+
3. Images are listed in the CSV's relatedImages section
32+
"""
33+
34+
@pytest.mark.smoke
35+
def test_verify_lls_operator_images(
36+
self: Self,
37+
admin_client: DynamicClient,
38+
lls_pods: Pod,
39+
related_images_refs: Set[str],
40+
):
41+
validation_errors = []
42+
for pod in [lls_pods]:
43+
validation_errors.extend(validate_container_images(pod=pod, valid_image_refs=related_images_refs))
44+
45+
if validation_errors:
46+
pytest.fail("\n".join(validation_errors))

0 commit comments

Comments
 (0)