Skip to content

Commit

Permalink
Tests: error handling in _is_kopf_handler_finished and increase defau…
Browse files Browse the repository at this point in the history
…lt timeout for failing tests
  • Loading branch information
goat-ssh committed Sep 19, 2024
1 parent b9286ff commit 18410bf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tests/test_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ async def test_bootstrap_users(
mock.ANY,
),
err_msg="Did not notify cluster creation status update.",
timeout=DEFAULT_TIMEOUT,
timeout=DEFAULT_TIMEOUT * 3,
)
await assert_wait_for(
True,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_update_grand_central.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ async def test_update_grand_central(
namespace.metadata.name,
"cloud.registry.cr8.net/crate/grand-central:latest",
err_msg="Container image has not been updated.",
timeout=DEFAULT_TIMEOUT,
timeout=DEFAULT_TIMEOUT * 3,
)

await assert_wait_for(
Expand All @@ -117,7 +117,7 @@ async def test_update_grand_central(
namespace.metadata.name,
"cloud.registry.cr8.net/crate/grand-central:latest",
err_msg="InitContainer image has not been updated.",
timeout=DEFAULT_TIMEOUT,
timeout=DEFAULT_TIMEOUT * 3,
)


Expand Down
2 changes: 1 addition & 1 deletion tests/test_update_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ async def test_update_cluster_password(
mock.ANY,
),
err_msg="Did not notify cluster creation status update.",
timeout=DEFAULT_TIMEOUT,
timeout=DEFAULT_TIMEOUT * 3,
)

await core.patch_namespaced_secret(
Expand Down
20 changes: 13 additions & 7 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,19 @@ async def is_cluster_healthy(
async def is_kopf_handler_finished(
coapi: CustomObjectsApi, name, namespace: str, handler_name: str
):
cratedb = await coapi.get_namespaced_custom_object(
group=API_GROUP,
version="v1",
plural=RESOURCE_CRATEDB,
namespace=namespace,
name=name,
)
try:
cratedb = await coapi.get_namespaced_custom_object(
group=API_GROUP,
version="v1",
plural=RESOURCE_CRATEDB,
namespace=namespace,
name=name,
)
except Exception as e:
logger.error(
f"Error checking handler for '{name}' in namespace '{namespace}': {e}"
)
return False

handler_status = cratedb["metadata"].get("annotations", {}).get(handler_name, None)
return handler_status is None
Expand Down

0 comments on commit 18410bf

Please sign in to comment.