Skip to content

Commit cdc72f5

Browse files
committed
chore: ensure tests can run against live cluster
AI-assisted: Claude Code (Opus 4.6) Signed-off-by: Debarati Basu-Nag <dbasunag@redhat.com>
1 parent ef92b8a commit cdc72f5

5 files changed

Lines changed: 33 additions & 9 deletions

File tree

catalog/clients/python/tests/mcp_servers/test_filtering.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@
88
3. Run: pytest --e2e tests/mcp_servers/test_filtering.py
99
"""
1010

11+
import os
12+
1113
import pytest
1214

1315
from model_catalog import CatalogAPIClient, CatalogAPIError, CatalogNotFoundError
1416

17+
_KIND_CLUSTER = os.getenv("KIND_CLUSTER", "True").lower() in ("true", "1", "yes")
18+
1519

1620
class TestMCPServerFiltering:
1721
"""Test suite for MCP server filterQuery functionality."""
@@ -36,6 +40,7 @@ class TestMCPServerFiltering:
3640
1,
3741
{"calculator"},
3842
id="boolean_flags",
43+
marks=pytest.mark.skipif(not _KIND_CLUSTER, reason="Non-KinD environments have additional MCP sources"),
3944
),
4045
pytest.param(
4146
"license='MIT' AND (provider='Math Community' OR provider='Weather Community')",

catalog/clients/python/tests/mcp_servers/test_named_queries.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@ def test_named_query_execution(
3535
self,
3636
api_client: CatalogAPIClient,
3737
suppress_ssl_warnings: None,
38+
kind_cluster: bool,
3839
named_query: str,
3940
expected_security_indicators: dict[str, bool],
4041
):
4142
"""TC-API-011: Test executing a named query filters servers by security indicators."""
4243
response = api_client.get_mcp_servers(named_query=named_query)
4344
items = response.get("items", [])
44-
assert len(items) == 1, f"Expected 1 server matching '{named_query}', got {len(items)}"
45-
assert items[0]["name"] == "calculator"
45+
if kind_cluster:
46+
assert len(items) == 1, f"Expected 1 server matching '{named_query}', got {len(items)}"
47+
assert items[0]["name"] == "calculator"
4648

4749
security_indicators = items[0].get("securityIndicators", {})
4850
for prop_name, expected_value in expected_security_indicators.items():

catalog/clients/python/tests/mcp_servers/test_servers.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ def test_mcp_servers_loaded(
2323
api_client: CatalogAPIClient,
2424
suppress_ssl_warnings: None,
2525
test_mcp_catalog_data: dict,
26+
kind_cluster: bool,
2627
):
2728
"""Test that all expected MCP servers are loaded with required fields."""
2829
response = api_client.get_mcp_servers()
2930
items = response.get("items", [])
3031
actual_names = {server["name"] for server in items}
31-
expected_names = {server["name"] for server in test_mcp_catalog_data["mcp_servers"]}
32-
assert actual_names == expected_names
32+
if kind_cluster:
33+
expected_names = {server["name"] for server in test_mcp_catalog_data["mcp_servers"]}
34+
assert actual_names == expected_names
3335

3436
for server in items:
3537
missing = MCP_SERVER_REQUIRED_FIELDS - server.keys()
@@ -40,12 +42,16 @@ def test_mcp_server_providers(
4042
api_client: CatalogAPIClient,
4143
suppress_ssl_warnings: None,
4244
test_mcp_catalog_data: dict,
45+
kind_cluster: bool,
4346
):
4447
"""Test that MCP server providers match expected values."""
4548
response = api_client.get_mcp_servers()
46-
actual_providers = {s["name"]: s["provider"] for s in response["items"]}
47-
expected_providers = {s["name"]: s["provider"] for s in test_mcp_catalog_data["mcp_servers"]}
48-
assert actual_providers == expected_providers
49+
actual_providers = {server["name"]: server["provider"] for server in response["items"]}
50+
expected_providers = {server["name"]: server["provider"] for server in test_mcp_catalog_data["mcp_servers"]}
51+
if kind_cluster:
52+
assert actual_providers == expected_providers
53+
else:
54+
assert set(expected_providers.items()).issubset(set(actual_providers.items()))
4955

5056
def test_mcp_server_get_by_id(
5157
self,
@@ -67,13 +73,16 @@ def test_mcp_server_pagination(
6773
api_client: CatalogAPIClient,
6874
suppress_ssl_warnings: None,
6975
test_mcp_catalog_data: dict,
76+
kind_cluster: bool,
7077
):
7178
"""Test pagination by iterating all servers with pageSize=1."""
7279
expected_names = {server["name"] for server in test_mcp_catalog_data["mcp_servers"]}
7380
collected_names: set[str] = set()
7481
next_token = None
7582

76-
for _ in range(len(expected_names) + 1):
83+
# Use a safe upper bound: on non-KinD environments there may be more servers
84+
max_pages = len(expected_names) + 1 if kind_cluster else 100
85+
for _ in range(max_pages):
7786
response = api_client.get_mcp_servers(page_size=1, next_page_token=next_token)
7887
items = response.get("items", [])
7988
assert len(items) == 1, f"Expected exactly 1 item per page, got {len(items)}"
@@ -86,7 +95,10 @@ def test_mcp_server_pagination(
8695
if not next_token:
8796
break
8897

89-
assert collected_names == expected_names
98+
if kind_cluster:
99+
assert collected_names == expected_names
100+
else:
101+
assert expected_names.issubset(collected_names)
90102

91103
def test_filter_by_name(
92104
self,

catalog/clients/python/tests/models/test_artifacts.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ def test_artifacts_sorting_by_id(
447447
self,
448448
api_client: CatalogAPIClient,
449449
model_with_artifacts: tuple[str, str],
450+
suppress_ssl_warnings: None,
450451
order_by: str,
451452
sort_order: str,
452453
) -> None:
@@ -475,6 +476,7 @@ def test_artifacts_sorting_by_custom_property(
475476
self,
476477
api_client: CatalogAPIClient,
477478
model_with_artifacts: tuple[str, str],
479+
suppress_ssl_warnings: None,
478480
order_by: str,
479481
sort_order: str,
480482
) -> None:
@@ -496,6 +498,7 @@ def test_sorting_by_non_existing_property_falls_back_to_id(
496498
self,
497499
api_client: CatalogAPIClient,
498500
model_with_artifacts: tuple[str, str],
501+
suppress_ssl_warnings: None
499502
) -> None:
500503
"""Test that sorting by a non-existing property falls back to ID ASC."""
501504
source_id, model_name = model_with_artifacts

catalog/clients/python/tests/models/test_filter_query.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def test_search_models_by_filter_query(
3131
pattern matching, equality on JSON array property (tasks),
3232
and AND logic combining all conditions.
3333
"""
34+
if not kind_cluster:
35+
pytest.skip(reason="Specific configuration is not applied on a live cluster")
3436
sizes = ("7B", "13B")
3537
filter_query = "size IN ('7B','13B') AND name ILIKE '%test%' AND tasks = 'text-generation'"
3638

0 commit comments

Comments
 (0)