Skip to content

Commit e451977

Browse files
authored
test: add verification for namedQueries (#943)
1 parent 0078a00 commit e451977

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

tests/model_registry/model_catalog/test_filter_options_endpoint.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,62 @@ def test_comprehensive_coverage_against_database(
153153
assert False, failure_msg
154154

155155
LOGGER.info("Comprehensive database coverage validation passed - API matches database exactly")
156+
157+
@pytest.mark.parametrize(
158+
"user_token_for_api_calls,",
159+
[
160+
pytest.param(
161+
{},
162+
id="test_named_queries_admin_user",
163+
),
164+
pytest.param(
165+
{"user_type": "test"},
166+
id="test_named_queries_non_admin_user",
167+
),
168+
pytest.param(
169+
{"user_type": "sa_user"},
170+
id="test_named_queries_service_account",
171+
),
172+
],
173+
indirect=["user_token_for_api_calls"],
174+
)
175+
def test_named_queries_in_filter_options(
176+
self: Self,
177+
enabled_model_catalog_config_map: ConfigMap,
178+
model_catalog_rest_url: list[str],
179+
user_token_for_api_calls: str,
180+
test_idp_user: UserTestSession,
181+
):
182+
"""
183+
Test for: RHOAIENG-38836
184+
Validate that namedQueries field is present in filter_options response.
185+
Validates that default-performance-filters named query exists with expected properties.
186+
"""
187+
default_performance_filters = "default-performance-filters"
188+
url = f"{model_catalog_rest_url[0]}models/filter_options"
189+
LOGGER.info(f"Testing namedQueries in filter_options endpoint: {url}")
190+
191+
response = execute_get_command(
192+
url=url,
193+
headers=get_rest_headers(token=user_token_for_api_calls),
194+
)
195+
196+
named_queries = response.get("namedQueries", {})
197+
assert named_queries, "Named queries should be present in the response"
198+
199+
default_perf_filters = named_queries.get(default_performance_filters, {})
200+
assert default_perf_filters, f"Named query '{default_performance_filters}' should be present"
201+
202+
# Validate expected properties are present in the named query
203+
expected_properties = {
204+
"artifacts.requests_per_second.double_value",
205+
"artifacts.ttft_p90.double_value",
206+
"artifacts.use_case.string_value",
207+
}
208+
209+
assert expected_properties == default_perf_filters.keys(), (
210+
f"default-performance-filters should contain exactly {expected_properties}, "
211+
f"but got {default_perf_filters.keys()}"
212+
)
213+
214+
LOGGER.info("Named queries validation passed successfully")

0 commit comments

Comments
 (0)