|
7 | 7 | from typing import Generator, List, Dict, Any |
8 | 8 |
|
9 | 9 | from _pytest.fixtures import FixtureRequest |
10 | | -from pytest_testconfig import py_config |
11 | 10 | from simple_logger.logger import get_logger |
12 | 11 |
|
13 | | -from ocp_resources.data_science_cluster import DataScienceCluster |
14 | 12 | from ocp_resources.deployment import Deployment |
| 13 | +from ocp_resources.infrastructure import Infrastructure |
15 | 14 | from ocp_resources.model_registry_modelregistry_opendatahub_io import ModelRegistry |
16 | 15 | from ocp_resources.namespace import Namespace |
17 | 16 | from ocp_resources.oauth import OAuth |
|
28 | 27 | from pyhelper_utils.shell import run_command |
29 | 28 |
|
30 | 29 | from tests.model_registry.rbac.utils import wait_for_oauth_openshift_deployment, create_role_binding |
31 | | -from utilities.constants import DscComponents |
32 | 30 | from utilities.general import generate_random_name |
33 | 31 | from tests.model_registry.utils import ( |
34 | 32 | generate_namespace_name, |
35 | | - wait_for_pods_running, |
36 | 33 | ) |
37 | 34 | from utilities.infra import login_with_user_password |
38 | 35 | from utilities.user_utils import UserTestSession, create_htpasswd_file, wait_for_user_creation |
@@ -425,47 +422,6 @@ def created_role_binding_user( |
425 | 422 | # ============================================================================= |
426 | 423 | # RESOURCE FIXTURES PARMETRIZED |
427 | 424 | # ============================================================================= |
428 | | -@pytest.fixture(scope="class") |
429 | | -def updated_dsc_component_state_parametrized( |
430 | | - request: FixtureRequest, |
431 | | - admin_client: DynamicClient, |
432 | | - dsc_resource: DataScienceCluster, |
433 | | - teardown_resources: bool, |
434 | | -) -> Generator[DataScienceCluster, Any, Any]: |
435 | | - """Configure DSC to use parametrized Model Registry namespace""" |
436 | | - if not teardown_resources: |
437 | | - yield dsc_resource |
438 | | - |
439 | | - # Get the namespace name from the parameter if provided, otherwise use the default namespace |
440 | | - namespace_name = request.param.get("ns_name", py_config["model_registry_namespace"]) |
441 | | - |
442 | | - # Set the new namespace and manage |
443 | | - component_patch = { |
444 | | - DscComponents.MODELREGISTRY: { |
445 | | - "managementState": DscComponents.ManagementState.MANAGED, |
446 | | - "registriesNamespace": namespace_name, |
447 | | - }, |
448 | | - } |
449 | | - |
450 | | - with ResourceEditor(patches={dsc_resource: {"spec": {"components": component_patch}}}): |
451 | | - dsc_resource.wait_for_condition( |
452 | | - condition=DscComponents.COMPONENT_MAPPING[DscComponents.MODELREGISTRY], status="True" |
453 | | - ) |
454 | | - namespace = Namespace(name=namespace_name, wait_for_resource=True) |
455 | | - namespace.wait_for_status(status=Namespace.Status.ACTIVE) |
456 | | - wait_for_pods_running( |
457 | | - admin_client=admin_client, |
458 | | - namespace_name=py_config["applications_namespace"], |
459 | | - number_of_consecutive_checks=6, |
460 | | - ) |
461 | | - yield dsc_resource |
462 | | - |
463 | | - # Clean up the dynamic namespace |
464 | | - namespace = Namespace(name=namespace_name, ensure_exists=True) |
465 | | - if namespace: |
466 | | - namespace.delete(wait=True) |
467 | | - |
468 | | - |
469 | 425 | @pytest.fixture(scope="class") |
470 | 426 | def db_secret_parametrized(request: FixtureRequest, teardown_resources: bool) -> Generator[List[Secret], Any, Any]: |
471 | 427 | """Create DB Secret parametrized""" |
@@ -556,3 +512,9 @@ def model_registry_instance_parametrized( |
556 | 512 | f"Created {len(model_registry_instances)} MR instances: {[mr.name for mr in model_registry_instances]}" |
557 | 513 | ) |
558 | 514 | yield model_registry_instances |
| 515 | + |
| 516 | + |
| 517 | +@pytest.fixture(scope="session") |
| 518 | +def api_server_url(admin_client: DynamicClient) -> str: |
| 519 | + infrastructure = Infrastructure(client=admin_client, name="cluster", ensure_exists=True) |
| 520 | + return infrastructure.instance.status.apiServerURL |
0 commit comments