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
4 changes: 2 additions & 2 deletions .github/workflows/check-api-outdated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:
types: [opened, reopened]
workflow_dispatch:
schedule:
# At 4 am on every day. (https://crontab.guru)
- cron: "0 4 * * *"
# "At 2 am UTC on every day." (https://crontab.guru)
- cron: "0 2 * * *"

jobs:

Expand Down
2 changes: 2 additions & 0 deletions doc/changes/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
## Refactorings

* #68: Update to Python 3.10
* #70: Optimized logging
* n/a: Changed schedule checking if open api is outdated to 2 am
23 changes: 22 additions & 1 deletion exasol/saas/client/api_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ class DatabaseStartupFailure(Exception):
successful.
"""

class DatabaseDeleteTimeout(Exception):
"""
If deletion of a SaaS database instance was requested but during the
specified timeout it was still reported in the list of existing databases.
"""

def create_saas_client(
host: str,
Expand Down Expand Up @@ -212,6 +217,22 @@ def _ignore_failures(self, ignore: bool = False):
yield self._client
self._client.raise_on_unexpected_status = before

def wait_until_deleted(
self,
database_id: str,
timeout: timedelta = timedelta(seconds=1),
interval: timedelta = timedelta(minutes=1),
):
@retry(wait=wait_fixed(interval), stop=stop_after_delay(timeout))
def still_exists() -> bool:
result = database_id in self.list_database_ids()
if result:
raise TryAgain
return result

if still_exists():
raise DatabaseDeleteTimeout

def delete_database(self, database_id: str, ignore_failures=False):
with self._ignore_failures(ignore_failures) as client:
return delete_database.sync_detailed(
Expand Down Expand Up @@ -273,7 +294,7 @@ def wait_until_running(
def poll_status():
db = self.get_database(database_id)
if db.status not in success:
print(f'status = {db.status}')
LOG.info("- Database status: %s ...", db.status)
raise TryAgain
return db.status

Expand Down
1 change: 1 addition & 0 deletions test/integration/databases_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_lifecycle(api_access, database_name):
# delete database and verify database is not listed anymore
wait_for_delete_clearance(start)
testee.delete_database(db.id)
testee.wait_until_deleted(db.id)
assert db.id not in testee.list_database_ids()


Expand Down