Skip to content

Commit

Permalink
testlib: add logging for operation timeout / duration
Browse files Browse the repository at this point in the history
Change-Id: I886fbbfa42b8fecaff8fcc71f59d5de9157f8ab7
  • Loading branch information
mo-ki committed Oct 22, 2024
1 parent ae42b8c commit 66593c5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/testlib/openapi_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def activate_changes_and_wait_for_completion(
force_foreign_changes: bool = False,
timeout: int = 120,
) -> bool:
logger.info("Activate changes and wait for completion...")
logger.info("Activate changes and wait %ds for completion...", timeout)
with self._wait_for_completion(timeout, "get", "activate_changes"):
if activation_started := self.activate_changes(sites, force_foreign_changes):
pending_changes = self.pending_changes()
Expand Down Expand Up @@ -565,13 +565,18 @@ def _wait_for_completion(
url=redirect_url,
allow_redirects=False,
)
if response.status_code == 204 and not response.content: # job has finished
if response.status_code == 204 and not response.content:
logger.info(
"Wait for completion finished after %ss for %s", running_time, operation
)
break

if not 300 <= response.status_code < 400:
raise UnexpectedResponse.from_response(response)

time.sleep(0.5)
else:
logger.info("Wait for completion finished instantly for %s", operation)

def get_host_services(
self, hostname: str, pending: bool | None = None, columns: list[str] | None = None
Expand Down

0 comments on commit 66593c5

Please sign in to comment.