Skip to content

Commit 4628796

Browse files
authored
fix: minor bug fix in clean up and wait for TAS operator (#1192)
* fix: minor bug fix in clean up and wait * fix: add wait for namespace deletion call
1 parent 9a1ab3b commit 4628796

File tree

2 files changed

+7
-34
lines changed

2 files changed

+7
-34
lines changed

tests/model_registry/model_registry/python_client/signing/conftest.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from ocp_utilities.operators import install_operator, uninstall_operator
1515
from pytest_testconfig import config as py_config
1616
from simple_logger.logger import get_logger
17-
from timeout_sampler import TimeoutExpiredError, TimeoutSampler
1817

1918
from tests.model_registry.model_registry.python_client.signing.constants import (
2019
SECURESIGN_API_VERSION,
@@ -26,7 +25,6 @@
2625
create_connection_type_field,
2726
get_organization_config,
2827
get_tas_service_urls,
29-
is_securesign_ready,
3028
)
3129
from utilities.constants import OPENSHIFT_OPERATORS, Timeout
3230
from utilities.infra import get_openshift_token
@@ -119,6 +117,10 @@ def installed_tas_operator(admin_client: DynamicClient) -> Generator[None, Any]:
119117
operator_namespace=operator_ns.name,
120118
clean_up_namespace=False,
121119
)
120+
# Ensure namespace exists for Securesign
121+
ns = Namespace(name=SECURESIGN_NAMESPACE)
122+
if ns.exists:
123+
ns.delete(wait=True)
122124
else:
123125
LOGGER.info(f"TAS operator already installed in {OPENSHIFT_OPERATORS}. Using existing installation.")
124126
yield
@@ -149,7 +151,8 @@ def securesign_instance(
149151
Resource: Securesign resource instance
150152
"""
151153
# Ensure namespace exists for Securesign
152-
Namespace(name=SECURESIGN_NAMESPACE, ensure_exists=True)
154+
ns = Namespace(name=SECURESIGN_NAMESPACE)
155+
ns.wait_for_status(status=Namespace.Status.ACTIVE)
153156

154157
# Build Securesign CR spec
155158
org_config = get_organization_config()
@@ -197,21 +200,7 @@ def securesign_instance(
197200
# Create Securesign instance using custom Securesign class
198201
with Securesign(kind_dict=securesign_dict, client=admin_client) as securesign:
199202
LOGGER.info(f"Securesign instance '{SECURESIGN_NAME}' created in namespace '{SECURESIGN_NAMESPACE}'")
200-
201-
# Wait for the Securesign instance to become ready
202-
try:
203-
for sample in TimeoutSampler(
204-
wait_timeout=Timeout.TIMEOUT_5MIN,
205-
sleep=5,
206-
func=lambda: securesign.instance.to_dict(),
207-
):
208-
if sample and is_securesign_ready(sample):
209-
LOGGER.info(f"Securesign instance '{SECURESIGN_NAME}' is ready")
210-
break
211-
except TimeoutExpiredError:
212-
LOGGER.error(f"Timeout waiting for Securesign instance '{SECURESIGN_NAME}' to become ready")
213-
raise
214-
203+
securesign.wait_for_condition(condition="Ready", status="True")
215204
yield securesign
216205

217206
# Cleanup is handled automatically by the context manager

tests/model_registry/model_registry/python_client/signing/utils.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,6 @@ def get_organization_config() -> dict[str, str]:
1414
}
1515

1616

17-
def is_securesign_ready(securesign_instance: dict) -> bool:
18-
"""Check if a Securesign instance is ready.
19-
20-
Args:
21-
securesign_instance: Securesign instance dictionary from Kubernetes API
22-
23-
Returns:
24-
bool: True if instance has Ready condition with status True
25-
"""
26-
conditions = securesign_instance.get("status", {}).get("conditions", [])
27-
ready = [
28-
condition for condition in conditions if condition.get("type") == "Ready" and condition.get("status") == "True"
29-
]
30-
return bool(ready)
31-
32-
3317
def get_tas_service_urls(securesign_instance: dict) -> dict[str, str]:
3418
"""Extract TAS service URLs from Securesign instance status.
3519

0 commit comments

Comments
 (0)