44from typing import Self
55
66from ocp_resources .config_map import ConfigMap
7- from tests .model_registry .model_catalog .utils import (
8- assert_source_error_state_message ,
9- )
107from tests .model_registry .model_catalog .huggingface .utils import assert_accessible_models_via_catalog_api
118from tests .model_registry .utils import execute_get_command
129from kubernetes .dynamic .exceptions import ResourceNotFoundError
3835 - "jonburdo/public-test-model-1"
3936 - "jonburdo/private-test-model-1"
4037 - "jonburdo/gated-test-model-1"
38+ labels:
39+ - { SOURCE_ID }
4140"""
4241 },
4342 id = "test_mixed_accessible_and_inaccessible_models" ,
5251class TestHuggingFaceSourceErrorValidation :
5352 """Test cases for RHOAIENG-47934 - Partial model fetching errors should not affect other models."""
5453
55- def test_source_error_state_and_message (
54+ def test_source_state_and_message (
5655 self : Self ,
5756 updated_catalog_config_map : ConfigMap ,
5857 model_catalog_rest_url : list [str ],
@@ -65,25 +64,24 @@ def test_source_error_state_and_message(
6564 1. The source is in error state due to private model fetch failure
6665 2. The error message contains the specific failed models
6766 """
67+ LOGGER .info (f"Testing source state for source with failed models: { INACCESSIBLE_MODELS } " )
6868 # Construct expected error message with failed models
69- failed_models_str = ", " .join (INACCESSIBLE_MODELS )
7069 expected_error_message = (
7170 "Failed to fetch some models, ensure models exist and are accessible with "
72- f"given credentials. Failed models: [{ failed_models_str } ]"
71+ f"given credentials. Failed models: [{ ', ' . join ( INACCESSIBLE_MODELS ) } ]"
7372 )
74-
75- LOGGER .info (f"Testing source error state for failed models: { INACCESSIBLE_MODELS } " )
76-
77- assert_source_error_state_message (
78- model_catalog_rest_url = model_catalog_rest_url ,
79- model_registry_rest_headers = model_registry_rest_headers ,
80- expected_error_message = expected_error_message ,
81- source_id = SOURCE_ID ,
73+ results = execute_get_command (
74+ url = f"{ model_catalog_rest_url [0 ]} sources" ,
75+ headers = model_registry_rest_headers ,
76+ )["items" ]
77+ # pick the relevant source first by id:
78+ matched_source = [result for result in results if result ["id" ] == SOURCE_ID ]
79+ assert matched_source , f"Matched expected source not found: { results } "
80+ assert matched_source [0 ]["status" ] == "partially-available"
81+ assert expected_error_message in matched_source [0 ]["error" ], (
82+ f"Expected error: { expected_error_message } not found in { matched_source [0 ]['error' ]} "
8283 )
8384
84- @pytest .mark .xfail (
85- reason = "RHOAIENG-49162: API call using source_label does not find models, when source is in error state"
86- )
8785 def test_accessible_models_catalog_api_source_id (
8886 self : Self ,
8987 updated_catalog_config_map : ConfigMap ,
0 commit comments