forked from opendatahub-io/opendatahub-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
69 lines (58 loc) · 1.94 KB
/
conftest.py
File metadata and controls
69 lines (58 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from collections.abc import Generator
from typing import Any
import pytest
from kubernetes.dynamic import DynamicClient
from ocp_resources.deployment import Deployment
from ocp_resources.namespace import Namespace
from ocp_resources.route import Route
from utilities.certificates_utils import create_ca_bundle_file
from utilities.constants import Timeout
from utilities.opendatahub_logger import get_logger
from utilities.resources.evalhub import EvalHub
LOGGER = get_logger(name=__name__)
@pytest.fixture(scope="class")
def evalhub_cr(
admin_client: DynamicClient,
model_namespace: Namespace,
) -> Generator[EvalHub, Any, Any]:
"""Create an EvalHub custom resource and wait for it to be ready."""
with EvalHub(
client=admin_client,
name="evalhub",
namespace=model_namespace.name,
wait_for_resource=True,
) as evalhub:
yield evalhub
@pytest.fixture(scope="class")
def evalhub_deployment(
admin_client: DynamicClient,
model_namespace: Namespace,
evalhub_cr: EvalHub,
) -> Deployment:
"""Wait for the EvalHub deployment to become available."""
deployment = Deployment(
client=admin_client,
name=evalhub_cr.name,
namespace=model_namespace.name,
)
deployment.wait_for_replicas(timeout=Timeout.TIMEOUT_5MIN)
return deployment
@pytest.fixture(scope="class")
def evalhub_route(
admin_client: DynamicClient,
model_namespace: Namespace,
evalhub_deployment: Deployment,
) -> Route:
"""Get the Route created by the operator for the EvalHub service."""
return Route(
client=admin_client,
name=evalhub_deployment.name,
namespace=model_namespace.name,
ensure_exists=True,
)
@pytest.fixture(scope="class")
def evalhub_ca_bundle_file(
admin_client: DynamicClient,
) -> str:
"""Create a CA bundle file for verifying the EvalHub route TLS certificate."""
return create_ca_bundle_file(client=admin_client)