Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from ocp_utilities.operators import install_operator, uninstall_operator
from pytest_testconfig import config as py_config
from simple_logger.logger import get_logger
from timeout_sampler import TimeoutExpiredError, TimeoutSampler

from tests.model_registry.model_registry.python_client.signing.constants import (
SECURESIGN_API_VERSION,
Expand All @@ -26,7 +25,6 @@
create_connection_type_field,
get_organization_config,
get_tas_service_urls,
is_securesign_ready,
)
from utilities.constants import OPENSHIFT_OPERATORS, Timeout
from utilities.infra import get_openshift_token
Expand Down Expand Up @@ -119,6 +117,10 @@ def installed_tas_operator(admin_client: DynamicClient) -> Generator[None, Any]:
operator_namespace=operator_ns.name,
clean_up_namespace=False,
)
# Ensure namespace exists for Securesign
ns = Namespace(name=SECURESIGN_NAMESPACE)
if ns.exists:
ns.delete(wait=True)
Comment thread
dbasunag marked this conversation as resolved.
else:
LOGGER.info(f"TAS operator already installed in {OPENSHIFT_OPERATORS}. Using existing installation.")
yield
Expand Down Expand Up @@ -149,7 +151,8 @@ def securesign_instance(
Resource: Securesign resource instance
"""
# Ensure namespace exists for Securesign
Namespace(name=SECURESIGN_NAMESPACE, ensure_exists=True)
ns = Namespace(name=SECURESIGN_NAMESPACE)
ns.wait_for_status(status=Namespace.Status.ACTIVE)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment thread
dbasunag marked this conversation as resolved.

# Build Securesign CR spec
org_config = get_organization_config()
Expand Down Expand Up @@ -197,21 +200,7 @@ def securesign_instance(
# Create Securesign instance using custom Securesign class
with Securesign(kind_dict=securesign_dict, client=admin_client) as securesign:
LOGGER.info(f"Securesign instance '{SECURESIGN_NAME}' created in namespace '{SECURESIGN_NAMESPACE}'")

# Wait for the Securesign instance to become ready
try:
for sample in TimeoutSampler(
wait_timeout=Timeout.TIMEOUT_5MIN,
sleep=5,
func=lambda: securesign.instance.to_dict(),
):
if sample and is_securesign_ready(sample):
LOGGER.info(f"Securesign instance '{SECURESIGN_NAME}' is ready")
break
except TimeoutExpiredError:
LOGGER.error(f"Timeout waiting for Securesign instance '{SECURESIGN_NAME}' to become ready")
raise

securesign.wait_for_condition(condition="Ready", status="True")
yield securesign

# Cleanup is handled automatically by the context manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,6 @@ def get_organization_config() -> dict[str, str]:
}


def is_securesign_ready(securesign_instance: dict) -> bool:
"""Check if a Securesign instance is ready.

Args:
securesign_instance: Securesign instance dictionary from Kubernetes API

Returns:
bool: True if instance has Ready condition with status True
"""
conditions = securesign_instance.get("status", {}).get("conditions", [])
ready = [
condition for condition in conditions if condition.get("type") == "Ready" and condition.get("status") == "True"
]
return bool(ready)


def get_tas_service_urls(securesign_instance: dict) -> dict[str, str]:
"""Extract TAS service URLs from Securesign instance status.

Expand Down