77import pytest
88import shortuuid
99import yaml
10+ from _pytest ._py .path import LocalPath
11+ from _pytest .legacypath import TempdirFactory
1012from _pytest .tmpdir import TempPathFactory
1113from ocp_resources .config_map import ConfigMap
1214from ocp_resources .dsc_initialization import DSCInitialization
3234 create_ns ,
3335 login_with_user_password ,
3436 get_openshift_token ,
37+ download_oc_console_cli ,
3538)
3639from utilities .constants import (
3740 AcceleratorType ,
4144 Protocols ,
4245)
4346from utilities .infra import update_configmap_data
47+ from utilities .logger import RedactedString
4448from utilities .minio import create_minio_data_connection_secret
4549from utilities .operator_utils import get_csv_related_images
4650
@@ -65,7 +69,7 @@ def tests_tmp_dir(request: FixtureRequest, tmp_path_factory: TempPathFactory) ->
6569
6670@pytest .fixture (scope = "session" )
6771def current_client_token (admin_client : DynamicClient ) -> str :
68- return get_openshift_token ()
72+ return RedactedString ( value = get_openshift_token () )
6973
7074
7175@pytest .fixture (scope = "session" )
@@ -217,6 +221,14 @@ def vllm_runtime_image(pytestconfig: pytest.Config) -> str | None:
217221 return runtime_image
218222
219223
224+ @pytest .fixture (scope = "session" )
225+ def mlserver_runtime_image (pytestconfig : pytest .Config ) -> str | None :
226+ runtime_image = pytestconfig .option .mlserver_runtime_image
227+ if not runtime_image :
228+ return None
229+ return runtime_image
230+
231+
220232@pytest .fixture (scope = "session" )
221233def use_unprivileged_client (pytestconfig : pytest .Config ) -> bool :
222234 _use_unprivileged_client = py_config .get ("use_unprivileged_client" )
@@ -490,8 +502,7 @@ def junitxml_plugin(
490502 return record_testsuite_property if request .config .pluginmanager .has_plugin ("junitxml" ) else None
491503
492504
493- @pytest .fixture (scope = "session" , autouse = True )
494- @pytest .mark .early (order = 0 )
505+ @pytest .fixture (scope = "session" )
495506def cluster_sanity_scope_session (
496507 request : FixtureRequest ,
497508 nodes : list [Node ],
@@ -525,3 +536,40 @@ def related_images_refs(admin_client: DynamicClient) -> set[str]:
525536 related_images = get_csv_related_images (admin_client = admin_client )
526537 related_images_refs = {img ["image" ] for img in related_images }
527538 return related_images_refs
539+
540+
541+ @pytest .fixture (scope = "session" )
542+ def os_path_environment () -> str :
543+ return os .environ ["PATH" ]
544+
545+
546+ @pytest .fixture (scope = "session" )
547+ def bin_directory (tmpdir_factory : TempdirFactory ) -> LocalPath :
548+ return tmpdir_factory .mktemp (basename = "bin" )
549+
550+
551+ @pytest .fixture (scope = "session" )
552+ def bin_directory_to_os_path (os_path_environment : str , bin_directory : LocalPath , oc_binary_path : str ) -> None :
553+ LOGGER .info (f"OC binary path: { oc_binary_path } " )
554+ LOGGER .info (f"Adding { bin_directory } to $PATH" )
555+ os .environ ["PATH" ] = f"{ bin_directory } :{ os_path_environment } "
556+
557+
558+ @pytest .fixture (scope = "session" )
559+ def oc_binary_path (bin_directory : LocalPath ) -> str :
560+ installed_oc_binary_path = os .getenv ("OC_BINARY_PATH" )
561+ if installed_oc_binary_path :
562+ LOGGER .warning (f"Using previously installed: { installed_oc_binary_path } " )
563+ return installed_oc_binary_path
564+
565+ return download_oc_console_cli (tmpdir = bin_directory )
566+
567+
568+ @pytest .fixture (scope = "session" , autouse = True )
569+ @pytest .mark .early (order = 0 )
570+ def autouse_fixtures (
571+ bin_directory_to_os_path : None ,
572+ cluster_sanity_scope_session : None ,
573+ ) -> None :
574+ """Fixture to control the order of execution of some of the fixtures"""
575+ return
0 commit comments