Skip to content

Commit 7f76c1d

Browse files
authored
Merge branch 'main' into jirafix
2 parents 04de0e7 + 4e3cb17 commit 7f76c1d

44 files changed

Lines changed: 819 additions & 245 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONSTITUTION.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ All code MUST consider security implications.
7979
- Avoid running destructive commands without explicit user confirmation
8080
- Use detect-secrets and gitleaks pre-commit hooks to prevent secret leakage
8181
- Test code MUST NOT introduce vulnerabilities into the tested systems
82+
- JIRA ticket links are allowed in PRs and commit messages (our Jira is public)
83+
- Do NOT reference internal-only resources (Jenkins, Confluence, Slack threads) in code, PRs, or commit messages
84+
- Do NOT link embargoed or security-restricted (RH-employee-only) tickets
8285

83-
**Rationale**: Tests interact with production-like clusters; security lapses can have real consequences.
86+
**Rationale**: Tests interact with production-like clusters; security lapses can have real consequences. This is a public repository — only reference publicly accessible resources.
8487

8588
## Test Development Standards
8689

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ENV PATH="$PATH:$BIN_DIR"
1313

1414
# Install system dependencies using dnf
1515
RUN dnf update -y \
16-
&& dnf install -y python3 python3-pip ssh gnupg curl gpg wget vim httpd-tools rsync openssl openssl-devel\
16+
&& dnf install -y python3 python3-pip ssh gnupg curl gpg wget vim httpd-tools rsync openssl openssl-devel skopeo\
1717
&& dnf clean all \
1818
&& rm -rf /var/cache/dnf
1919

@@ -22,6 +22,10 @@ RUN curl -sSL "https://github.com/fullstorydev/grpcurl/releases/download/v1.9.2/
2222
&& tar xvf /tmp/grpcurl_1.2.tar.gz --no-same-owner \
2323
&& mv grpcurl /usr/bin/grpcurl
2424

25+
# Install cosign
26+
RUN curl -sSL "https://github.com/sigstore/cosign/releases/download/v2.4.2/cosign-linux-amd64" --output /usr/bin/cosign \
27+
&& chmod +x /usr/bin/cosign
28+
2529
RUN useradd -ms /bin/bash $USER
2630
USER $USER
2731
WORKDIR $HOME_DIR

OWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ approvers:
33
- fege
44
- jgarciao
55
- lugi0
6+
- mwaykole
67
reviewers:
78
- dbasunag
89
- fege
910
- jgarciao
1011
- lugi0
12+
- mwaykole

tests/llama_stack/conftest.py

Lines changed: 27 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pytest
77
from _pytest.fixtures import FixtureRequest
88
from kubernetes.dynamic import DynamicClient
9-
from llama_stack_client import LlamaStackClient
9+
from llama_stack_client import APIError, LlamaStackClient
1010
from llama_stack_client.types.vector_store import VectorStore
1111
from ocp_resources.data_science_cluster import DataScienceCluster
1212
from ocp_resources.deployment import Deployment
@@ -73,59 +73,6 @@
7373
distribution_name = generate_random_name(prefix="llama-stack-distribution")
7474

7575

76-
def _cleanup_s3_files(
77-
bucket_name: str,
78-
endpoint_url: str,
79-
region: str,
80-
access_key_id: str,
81-
secret_access_key: str,
82-
) -> None:
83-
"""
84-
Clean up files from S3 bucket that were uploaded during tests.
85-
86-
Args:
87-
bucket_name: S3 bucket name
88-
endpoint_url: S3 endpoint URL
89-
region: S3 region
90-
access_key_id: AWS access key ID
91-
secret_access_key: AWS secret access key
92-
"""
93-
94-
try:
95-
import boto3
96-
from botocore.exceptions import ClientError
97-
98-
s3_client = boto3.client(
99-
service_name="s3",
100-
endpoint_url=endpoint_url,
101-
aws_access_key_id=access_key_id,
102-
aws_secret_access_key=secret_access_key,
103-
region_name=region,
104-
)
105-
106-
response = s3_client.list_objects_v2(Bucket=bucket_name)
107-
108-
if "Contents" not in response:
109-
LOGGER.info("No files found to clean up from S3")
110-
return
111-
112-
# We only want to delete files that start with "file-"
113-
for obj in response["Contents"]:
114-
key = obj["Key"]
115-
if key.startswith("file-"):
116-
s3_client.delete_object(Bucket=bucket_name, Key=key)
117-
LOGGER.debug(f"Deleted file from S3: {key}")
118-
119-
response = s3_client.list_objects_v2(Bucket=bucket_name)
120-
121-
if "Contents" not in response:
122-
LOGGER.info("No files found to clean up from S3")
123-
return
124-
125-
except ClientError as e:
126-
LOGGER.warning(f"Failed to clean up S3 files: {e}")
127-
128-
12976
@pytest.fixture(scope="class")
13077
def enabled_llama_stack_operator(dsc_resource: DataScienceCluster) -> Generator[DataScienceCluster, Any, Any]:
13178
with update_components_in_dsc(
@@ -385,11 +332,6 @@ def unprivileged_llama_stack_distribution(
385332
enabled_llama_stack_operator: DataScienceCluster,
386333
request: FixtureRequest,
387334
llama_stack_server_config: dict[str, Any],
388-
ci_s3_bucket_name: str,
389-
ci_s3_bucket_endpoint: str,
390-
ci_s3_bucket_region: str,
391-
aws_access_key_id: str,
392-
aws_secret_access_key: str,
393335
unprivileged_llama_stack_distribution_secret: Secret,
394336
unprivileged_postgres_deployment: Deployment,
395337
unprivileged_postgres_service: Service,
@@ -406,25 +348,6 @@ def unprivileged_llama_stack_distribution(
406348
lls_dist.wait_for_status(status=LlamaStackDistribution.Status.READY, timeout=600)
407349
yield lls_dist
408350

409-
try:
410-
env_vars = llama_stack_server_config.get("containerSpec", {}).get("env", [])
411-
enable_s3 = any(env.get("name") == "ENABLE_S3" and env.get("value") == "s3" for env in env_vars)
412-
413-
if enable_s3:
414-
try:
415-
_cleanup_s3_files(
416-
bucket_name=ci_s3_bucket_name,
417-
endpoint_url=ci_s3_bucket_endpoint,
418-
region=ci_s3_bucket_region,
419-
access_key_id=aws_access_key_id,
420-
secret_access_key=aws_secret_access_key,
421-
)
422-
except Exception as e: # noqa: BLE001
423-
LOGGER.warning(f"Failed to clean up S3 files: {e}")
424-
425-
except Exception as e: # noqa: BLE001
426-
LOGGER.warning(f"Failed to clean up S3 files: {e}")
427-
428351

429352
@pytest.fixture(scope="class")
430353
def llama_stack_distribution(
@@ -433,11 +356,6 @@ def llama_stack_distribution(
433356
enabled_llama_stack_operator: DataScienceCluster,
434357
request: FixtureRequest,
435358
llama_stack_server_config: dict[str, Any],
436-
ci_s3_bucket_name: str,
437-
ci_s3_bucket_endpoint: str,
438-
ci_s3_bucket_region: str,
439-
aws_access_key_id: str,
440-
aws_secret_access_key: str,
441359
llama_stack_distribution_secret: Secret,
442360
postgres_deployment: Deployment,
443361
postgres_service: Service,
@@ -453,25 +371,6 @@ def llama_stack_distribution(
453371
lls_dist.wait_for_status(status=LlamaStackDistribution.Status.READY, timeout=600)
454372
yield lls_dist
455373

456-
try:
457-
env_vars = llama_stack_server_config.get("containerSpec", {}).get("env", [])
458-
enable_s3 = any(env.get("name") == "ENABLE_S3" and env.get("value") == "s3" for env in env_vars)
459-
460-
if enable_s3:
461-
try:
462-
_cleanup_s3_files(
463-
bucket_name=ci_s3_bucket_name,
464-
endpoint_url=ci_s3_bucket_endpoint,
465-
region=ci_s3_bucket_region,
466-
access_key_id=aws_access_key_id,
467-
secret_access_key=aws_secret_access_key,
468-
)
469-
except Exception as e: # noqa: BLE001
470-
LOGGER.warning(f"Failed to clean up S3 files: {e}")
471-
472-
except Exception as e: # noqa: BLE001
473-
LOGGER.warning(f"Failed to clean up S3 files: {e}")
474-
475374

476375
def _get_llama_stack_distribution_deployment(
477376
client: DynamicClient,
@@ -642,11 +541,37 @@ def _create_llama_stack_client(
642541
http_client=http_client,
643542
)
644543
wait_for_llama_stack_client_ready(client=client)
544+
existing_file_ids = {f.id for f in client.files.list().data}
545+
645546
yield client
547+
548+
_cleanup_files(client=client, existing_file_ids=existing_file_ids)
646549
finally:
647550
http_client.close()
648551

649552

553+
def _cleanup_files(client: LlamaStackClient, existing_file_ids: set[str]) -> None:
554+
"""Delete files created during test execution via the LlamaStack files API.
555+
556+
Only deletes files whose IDs were not present before the test ran,
557+
avoiding interference with other test sessions.
558+
559+
Args:
560+
client: The LlamaStackClient used during the test
561+
existing_file_ids: File IDs that existed before the test started
562+
"""
563+
try:
564+
for file in client.files.list().data:
565+
if file.id not in existing_file_ids:
566+
try:
567+
client.files.delete(file_id=file.id)
568+
LOGGER.debug(f"Deleted file: {file.id}")
569+
except APIError as e:
570+
LOGGER.warning(f"Failed to delete file {file.id}: {e}")
571+
except APIError as e:
572+
LOGGER.warning(f"Failed to clean up files: {e}")
573+
574+
650575
@pytest.fixture(scope="class")
651576
def unprivileged_llama_stack_client(
652577
unprivileged_llama_stack_test_route: Route,

tests/model_registry/mcp_servers/config/test_invalid_yaml.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
)
3838
@pytest.mark.usefixtures("mcp_invalid_yaml_configmap_patch")
3939
class TestMCPServerInvalidYAML:
40-
"""RHOAIENG-51582: Tests for graceful handling of invalid YAML sources (TC-LOAD-007, TC-LOAD-008)."""
40+
"""
41+
Tests for graceful handling of invalid YAML sources (TC-LOAD-007, TC-LOAD-008)."""
4142

4243
def test_valid_servers_loaded_despite_invalid_source(
4344
self: Self,

tests/model_registry/mcp_servers/config/test_multi_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
@pytest.mark.usefixtures("mcp_multi_source_configmap_patch")
1515
class TestMCPServerMultiSource:
16-
"""RHOAIENG-51582: Tests for loading MCP servers from multiple YAML sources (TC-LOAD-002)."""
16+
"""Tests for loading MCP servers from multiple YAML sources (TC-LOAD-002)."""
1717

1818
def test_all_servers_from_multiple_sources_loaded(
1919
self: Self,

tests/model_registry/mcp_servers/config/test_named_queries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
@pytest.mark.usefixtures("mcp_servers_configmap_patch")
1313
class TestMCPServerNamedQueries:
14-
"""RHOAIENG-52375: Tests for MCP server named query functionality."""
14+
"""Tests for MCP server named query functionality."""
1515

1616
@pytest.mark.parametrize(
1717
"named_query, expected_custom_properties",

tests/model_registry/mcp_servers/search/test_filtering.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
@pytest.mark.usefixtures("mcp_servers_configmap_patch")
1313
class TestMCPServerFiltering:
14-
"""RHOAIENG-51584: Tests for MCP server filterQuery functionality."""
14+
"""Tests for MCP server filterQuery functionality."""
1515

1616
@pytest.mark.parametrize(
1717
"filter_query, expected_count, expected_name, field_check",
@@ -24,6 +24,7 @@ class TestMCPServerFiltering:
2424
id="by_provider",
2525
),
2626
pytest.param("tags='math'", 1, CALCULATOR_SERVER_NAME, None, id="by_tags"),
27+
pytest.param("license='BSD 3-Clause'", 1, "file-manager", ("license", "BSD 3-Clause"), id="by_license"),
2728
],
2829
)
2930
def test_filter_by_field(
@@ -35,7 +36,7 @@ def test_filter_by_field(
3536
expected_name: str,
3637
field_check: tuple[str, str] | None,
3738
):
38-
"""TC-API-003, TC-API-005: Test filtering MCP servers by provider and tags."""
39+
"""TC-API-003, TC-API-005, TC-API-009: Test filtering MCP servers by provider, tags, and license."""
3940
response = execute_get_command(
4041
url=f"{mcp_catalog_rest_urls[0]}mcp_servers",
4142
headers=model_registry_rest_headers,

tests/model_registry/mcp_servers/search/test_ordering.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010

1111
@pytest.mark.usefixtures("mcp_servers_configmap_patch")
1212
class TestMCPServerOrdering:
13-
"""RHOAIENG-51584: Tests for MCP server ordering functionality."""
13+
"""Tests for MCP server ordering functionality."""
1414

15-
@pytest.mark.xfail(reason="RHOAIENG-52448: sortOrder/orderBy not working, fix in PR #2367")
1615
@pytest.mark.parametrize(
1716
"sort_order",
1817
[

tests/model_registry/mcp_servers/test_data_integrity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
@pytest.mark.usefixtures("mcp_servers_configmap_patch")
1717
class TestMCPServerLoading:
18-
"""RHOAIENG-51582: Tests for loading MCP servers from YAML into the catalog (TC-LOAD-001)."""
18+
"""Tests for loading MCP servers from YAML into the catalog (TC-LOAD-001)."""
1919

2020
def test_mcp_servers_loaded(
2121
self: Self,

0 commit comments

Comments
 (0)