1313from tests .model_registry .model_catalog .constants import DEFAULT_CATALOG_ID
1414from tests .model_registry .model_catalog .utils import (
1515 validate_model_catalog_enabled ,
16- execute_get_command ,
1716 validate_model_catalog_resource ,
1817 validate_default_catalog ,
1918 get_validate_default_model_catalog_source ,
2019)
21- from tests .model_registry .utils import get_rest_headers
20+ from tests .model_registry .utils import get_rest_headers , execute_get_command
2221from utilities .user_utils import UserTestSession
2322
2423LOGGER = get_logger (name = __name__ )
3231
3332@pytest .mark .skip_must_gather
3433class TestModelCatalogGeneral :
34+ @pytest .mark .pre_upgrade
3535 @pytest .mark .post_upgrade
3636 @pytest .mark .install
37- def test_config_map_exists (self : Self , catalog_config_map : ConfigMap ) :
37+ def test_config_map_exists (self : Self , catalog_config_map : ConfigMap , pytestconfig : pytest . Config ) -> None :
3838 # Check that the default configmaps is created when model registry is
3939 # enabled on data science cluster.
40+ expected_num_catalog = 1
41+ if pytestconfig .option .pre_upgrade or pytestconfig .option .post_upgrade :
42+ expected_num_catalog = 2
4043 assert catalog_config_map .exists , f"{ catalog_config_map .name } does not exist"
4144 catalogs = yaml .safe_load (catalog_config_map .instance .data ["sources.yaml" ])["catalogs" ]
4245 assert catalogs
43- assert len (catalogs ) == 1 , f"{ catalog_config_map .name } should have 1 catalog"
46+ assert len (catalogs ) == expected_num_catalog , f"{ catalog_config_map .name } should have 1 catalog"
4447 validate_default_catalog (default_catalog = catalogs [0 ])
4548
4649 @pytest .mark .parametrize (
@@ -65,6 +68,7 @@ def test_config_map_exists(self: Self, catalog_config_map: ConfigMap):
6568 ],
6669 )
6770 @pytest .mark .post_upgrade
71+ @pytest .mark .pre_upgrade
6872 @pytest .mark .install
6973 def test_model_catalog_resources_exists (
7074 self : Self , admin_client : DynamicClient , model_registry_namespace : str , resource_name : Any
@@ -77,12 +81,14 @@ def test_operator_pod_enabled_model_catalog(self: Self, model_registry_operator_
7781 assert validate_model_catalog_enabled (pod = model_registry_operator_pod )
7882
7983
84+ @pytest .mark .install
8085@pytest .mark .parametrize (
8186 "user_token_for_api_calls," ,
8287 [
8388 pytest .param (
8489 {},
8590 id = "test_model_catalog_source_admin_user" ,
91+ marks = (pytest .mark .pre_upgrade , pytest .mark .post_upgrade ),
8692 ),
8793 pytest .param (
8894 {"user_type" : "test" },
@@ -98,16 +104,28 @@ def test_operator_pod_enabled_model_catalog(self: Self, model_registry_operator_
98104class TestModelCatalogDefault :
99105 def test_model_catalog_default_catalog_sources (
100106 self ,
107+ pytestconfig : pytest .Config ,
101108 test_idp_user : UserTestSession ,
102109 model_catalog_rest_url : list [str ],
103110 user_token_for_api_calls : str ,
104111 ):
105112 """
106113 Validate specific user can access default model catalog source
107114 """
108- get_validate_default_model_catalog_source (
109- token = user_token_for_api_calls , model_catalog_url = f"{ model_catalog_rest_url [0 ]} sources"
110- )
115+ LOGGER .info ("Attempting client connection with token" )
116+ result = execute_get_command (
117+ url = f"{ model_catalog_rest_url [0 ]} sources" ,
118+ headers = get_rest_headers (token = user_token_for_api_calls ),
119+ )["items" ]
120+ assert result
121+ items_to_validate = []
122+ if pytestconfig .option .pre_upgrade or pytestconfig .option .post_upgrade :
123+ for catalog in result :
124+ if catalog ["id" ] == DEFAULT_CATALOG_ID :
125+ items_to_validate .append (catalog )
126+ else :
127+ items_to_validate = result
128+ get_validate_default_model_catalog_source (catalogs = items_to_validate )
111129
112130 def test_model_default_catalog_get_models_by_source (
113131 self : Self ,
0 commit comments