Skip to content

Commit 6f49749

Browse files
dbasunagclaude
andcommitted
test: Add async job signing test automation
Signed-off-by: Debarati Basu-Nag <dbasunag@redhat.com> Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 605ae99 commit 6f49749

File tree

7 files changed

+891
-38
lines changed

7 files changed

+891
-38
lines changed

tests/model_registry/model_registry/async_job/conftest.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55
import pytest
66
import shortuuid
77
from kubernetes.dynamic import DynamicClient
8-
from kubernetes.dynamic.exceptions import ResourceNotFoundError
98
from model_registry import ModelRegistry as ModelRegistryClient
109
from model_registry.types import RegisteredModel
11-
from ocp_resources.config_map import ConfigMap
1210
from ocp_resources.job import Job
1311
from ocp_resources.role_binding import RoleBinding
1412
from ocp_resources.secret import Secret
1513
from ocp_resources.service import Service
1614
from ocp_resources.service_account import ServiceAccount
1715
from pytest import FixtureRequest
18-
from pytest_testconfig import py_config
1916

2017
from tests.model_registry.model_registry.async_job.constants import (
2118
ASYNC_JOB_ANNOTATIONS,
@@ -109,40 +106,6 @@ def oci_secret_for_async_job(
109106
yield secret
110107

111108

112-
@pytest.fixture(scope="class")
113-
def async_upload_image(admin_client: DynamicClient) -> str:
114-
"""
115-
Get the async upload image dynamically from the model-registry-operator-parameters ConfigMap.
116-
117-
This fetches the image from the cluster at runtime instead of using a hardcoded value.
118-
119-
Args:
120-
admin_client: Kubernetes client for resource access
121-
122-
Returns:
123-
str: The async upload image URL from the ConfigMap
124-
125-
Raises:
126-
KeyError: If the ConfigMap or the required key doesn't exist
127-
"""
128-
config_map = ConfigMap(
129-
client=admin_client,
130-
name="model-registry-operator-parameters",
131-
namespace=py_config["applications_namespace"],
132-
)
133-
134-
if not config_map.exists:
135-
raise ResourceNotFoundError(
136-
f"ConfigMap 'model-registry-operator-parameters' not found in"
137-
f" namespace '{py_config['applications_namespace']}'"
138-
)
139-
140-
try:
141-
return config_map.instance.data["IMAGES_JOBS_ASYNC_UPLOAD"]
142-
except KeyError as e:
143-
raise KeyError(f"Key 'IMAGES_JOBS_ASYNC_UPLOAD' not found in ConfigMap data: {e}") from e
144-
145-
146109
@pytest.fixture(scope="class")
147110
def model_sync_async_job(
148111
admin_client: DynamicClient,

tests/model_registry/model_registry/conftest.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from kubernetes.dynamic.exceptions import ResourceNotFoundError
1010
from model_registry import ModelRegistry as ModelRegistryClient
1111
from model_registry.types import RegisteredModel
12+
from ocp_resources.config_map import ConfigMap
1213
from ocp_resources.deployment import Deployment
1314
from ocp_resources.namespace import Namespace
1415
from ocp_resources.pod import Pod
@@ -17,6 +18,7 @@
1718
from ocp_resources.service_account import ServiceAccount
1819
from pyhelper_utils.shell import run_command
1920
from pytest import FixtureRequest
21+
from pytest_testconfig import config as py_config
2022

2123
from tests.model_registry.constants import (
2224
MODEL_REGISTRY_POD_FILTER,
@@ -236,3 +238,37 @@ def mr_access_role_binding(
236238
LOGGER.info(f"RoleBinding {binding.name} created successfully.")
237239
yield binding
238240
LOGGER.info(f"RoleBinding {binding.name} deletion initiated by context manager.")
241+
242+
243+
@pytest.fixture(scope="class")
244+
def async_upload_image(admin_client: DynamicClient) -> str:
245+
"""
246+
Get the async upload image dynamically from the model-registry-operator-parameters ConfigMap.
247+
248+
This fetches the image from the cluster at runtime instead of using a hardcoded value.
249+
250+
Args:
251+
admin_client: Kubernetes client for resource access
252+
253+
Returns:
254+
str: The async upload image URL from the ConfigMap
255+
256+
Raises:
257+
KeyError: If the ConfigMap or the required key doesn't exist
258+
"""
259+
config_map = ConfigMap(
260+
client=admin_client,
261+
name="model-registry-operator-parameters",
262+
namespace=py_config["applications_namespace"],
263+
)
264+
265+
if not config_map.exists:
266+
raise ResourceNotFoundError(
267+
f"ConfigMap 'model-registry-operator-parameters' not found in"
268+
f" namespace '{py_config['applications_namespace']}'"
269+
)
270+
271+
try:
272+
return config_map.instance.data["IMAGES_JOBS_ASYNC_UPLOAD"]
273+
except KeyError as e:
274+
raise KeyError(f"Key 'IMAGES_JOBS_ASYNC_UPLOAD' not found in ConfigMap data: {e}") from e

0 commit comments

Comments
 (0)