|
14 | 14 | class TestSourcesEndpoint: |
15 | 15 | """Test class for the model catalog sources endpoint.""" |
16 | 16 |
|
| 17 | + @pytest.mark.smoke |
| 18 | + def test_available_source_status( |
| 19 | + self, |
| 20 | + enabled_model_catalog_config_map: ConfigMap, |
| 21 | + model_catalog_rest_url: list[str], |
| 22 | + model_registry_rest_headers: dict[str, str], |
| 23 | + ): |
| 24 | + """ |
| 25 | + RHOAIENG-41849: Test that the sources endpoint returns no error for available sources. |
| 26 | + """ |
| 27 | + response = execute_get_command(url=f"{model_catalog_rest_url[0]}sources", headers=model_registry_rest_headers) |
| 28 | + items = response.get("items", []) |
| 29 | + assert items, "Sources not found" |
| 30 | + for item in items: |
| 31 | + validate_source_status(catalog=item, expected_status="available") |
| 32 | + error_value = item["error"] |
| 33 | + assert error_value is None or error_value == "", ( |
| 34 | + f"Source '{item.get('id')}' should not have error, got: {error_value}" |
| 35 | + ) |
| 36 | + |
| 37 | + LOGGER.info( |
| 38 | + f"Available catalog verified - ID: {item.get('id')}, Status: {item.get('status')}, Error: {error_value}" |
| 39 | + ) |
| 40 | + |
17 | 41 | @pytest.mark.parametrize("disabled_catalog_source", ["redhat_ai_models"], indirect=True) |
18 | | - @pytest.mark.sanity |
19 | | - def test_sources_endpoint_status_and_error_fields( |
| 42 | + def test_disabled_source_status( |
20 | 43 | self, |
21 | 44 | enabled_model_catalog_config_map: ConfigMap, |
22 | 45 | disabled_catalog_source: str, |
23 | 46 | model_catalog_rest_url: list[str], |
24 | 47 | model_registry_rest_headers: dict[str, str], |
25 | 48 | ): |
26 | 49 | """ |
27 | | - RHOAIENG-41243: Sources endpoint should return both enabled and disabled sources. |
28 | | - RHOAIENG-41849: Sources should have status and error fields with correct values. |
| 50 | + RHOAIENG-41849: |
| 51 | + This test disables an existing catalog and verifies: |
| 52 | + - status field is "disabled" |
| 53 | + - error field is null or empty |
29 | 54 | """ |
30 | 55 | catalog_id = disabled_catalog_source |
31 | 56 |
|
32 | 57 | response = execute_get_command(url=f"{model_catalog_rest_url[0]}sources", headers=model_registry_rest_headers) |
33 | 58 | items = response.get("items", []) |
34 | 59 |
|
35 | | - # Verify response contains multiple sources |
36 | | - assert items, "Expected sources to be returned" |
37 | | - |
38 | | - # Split sources by status |
39 | | - enabled_sources = [item for item in items if item.get("status") == "available"] |
40 | | - disabled_sources = [item for item in items if item.get("status") == "disabled"] |
41 | | - |
42 | | - # Verify we have both enabled and disabled sources |
43 | | - assert enabled_sources, "Expected at least one enabled source" |
44 | | - assert disabled_sources, "Expected at least one disabled source" |
45 | | - assert len(enabled_sources) + len(disabled_sources) == len(items), ( |
46 | | - "All sources should have either 'available' or 'disabled' status" |
47 | | - ) |
48 | | - |
49 | | - # Validate all enabled sources have correct status and no error |
50 | | - for source in enabled_sources: |
51 | | - validate_source_status(catalog=source, expected_status="available") |
52 | | - error_value = source["error"] |
53 | | - assert error_value is None or error_value == "", ( |
54 | | - f"Enabled source '{source.get('id')}' should not have error, got: {error_value}" |
55 | | - ) |
56 | | - |
57 | | - # Find and validate the specific disabled catalog from fixture |
58 | | - disabled_catalog = next((item for item in disabled_sources if item.get("id") == catalog_id), None) |
| 60 | + # Find the disabled catalog |
| 61 | + disabled_catalog = next((item for item in items if item.get("id") == catalog_id), None) |
59 | 62 | assert disabled_catalog is not None, f"Disabled catalog '{catalog_id}' not found in sources" |
60 | 63 |
|
61 | | - # Validate status and error fields for disabled catalog |
| 64 | + # Validate status and error fields |
62 | 65 | validate_source_status(catalog=disabled_catalog, expected_status="disabled") |
63 | 66 | error_value = disabled_catalog["error"] |
64 | 67 | assert error_value is None or error_value == "", ( |
65 | | - f"Disabled source '{disabled_catalog.get('id')}' should not have error, got: {error_value}" |
| 68 | + f"Source '{disabled_catalog.get('id')}' should not have error, got: {error_value}" |
| 69 | + ) |
| 70 | + |
| 71 | + LOGGER.info( |
| 72 | + "Disabled catalog verified - " |
| 73 | + f"ID: {disabled_catalog.get('id')}, " |
| 74 | + f"Status: {disabled_catalog.get('status')}, " |
| 75 | + f"Error: {error_value}" |
66 | 76 | ) |
67 | 77 |
|
| 78 | + @pytest.mark.parametrize("disabled_catalog_source", ["redhat_ai_models"], indirect=True) |
| 79 | + @pytest.mark.sanity |
| 80 | + def test_sources_endpoint_returns_all_sources_regardless_of_enabled_field( |
| 81 | + self, |
| 82 | + enabled_model_catalog_config_map: ConfigMap, |
| 83 | + disabled_catalog_source: str, |
| 84 | + model_catalog_rest_url: list[str], |
| 85 | + model_registry_rest_headers: dict[str, str], |
| 86 | + ): |
| 87 | + """ |
| 88 | + RHOAIENG-41633: Test that sources endpoint returns ALL sources regardless of enabled field value. |
| 89 | + """ |
| 90 | + response = execute_get_command(url=f"{model_catalog_rest_url[0]}sources", headers=model_registry_rest_headers) |
| 91 | + items = response.get("items", []) |
| 92 | + |
| 93 | + assert len(items) > 1, "Expected multiple sources to be returned" |
| 94 | + |
| 95 | + # Verify we have at least one enabled source |
| 96 | + enabled_sources = [item for item in items if item.get("status") == "available"] |
| 97 | + assert enabled_sources, "Expected at least one enabled source" |
| 98 | + |
| 99 | + # Verify we have at least one disabled source |
| 100 | + disabled_sources = [item for item in items if item.get("status") == "disabled"] |
| 101 | + assert disabled_sources, "Expected at least one disabled source" |
| 102 | + |
| 103 | + assert len(enabled_sources) + len(disabled_sources) == len(items), "Expected all sources to be returned" |
| 104 | + |
68 | 105 | LOGGER.info( |
69 | | - f"Sources endpoint validation complete - Total: {len(items)}, " |
70 | | - f"Enabled: {len(enabled_sources)}, Disabled: {len(disabled_sources)}" |
| 106 | + f"Sources endpoint returned {len(items)} total sources: " |
| 107 | + f"{len(enabled_sources)} enabled, {len(disabled_sources)} disabled" |
71 | 108 | ) |
0 commit comments