Skip to content

Commit

Permalink
#113 Investigating the SaaS test error
Browse files Browse the repository at this point in the history
  • Loading branch information
ahsimb committed Apr 30, 2024
1 parent 5da55ca commit d0077eb
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions test_saas/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import Optional
import os
import time

Expand All @@ -9,15 +10,20 @@
from exasol.saas.client.openapi.models.status import Status as SaasStatus


def create_saas_test_client(url: str, token: str, raise_on_unexpected_status: bool = True):
def create_saas_test_client(url: str,
token: str,
raise_on_unexpected_status: bool = True
) -> openapi.AuthenticatedClient:
return openapi.AuthenticatedClient(
base_url=url,
token=token,
raise_on_unexpected_status=raise_on_unexpected_status
)


def create_saas_test_database(account_id, client):
def create_saas_test_database(account_id: str,
client: openapi.AuthenticatedClient
) -> Optional[openapi.models.database.Database]:
cluster_spec = openapi.models.CreateCluster(
name="my-cluster",
size="XS",
Expand Down Expand Up @@ -52,16 +58,17 @@ def saas_test_account_id() -> str:

@pytest.fixture(scope='session')
def saas_test_database_id(saas_test_service_url, saas_test_token, saas_test_account_id) -> str:

with create_saas_test_client(
url=saas_test_service_url,
token=saas_test_token
) as client:
db: Optional[openapi.models.database.Database] = None
try:
db = create_saas_test_database(
account_id=saas_test_account_id,
client=client
)

# Wait till the database gets to the running state.
sleep_time = 600
small_interval = 20
Expand All @@ -81,6 +88,9 @@ def saas_test_database_id(saas_test_service_url, saas_test_token, saas_test_acco
raise RuntimeError(f'Test SaaS database status is {db.status} '
f'after {max_wait_time} seconds.')
yield db.id
except Exception as ex:
raise RuntimeError(f'Failed to create a database at {saas_test_service_url}. '
f'Got an exception {ex}')
finally:
if db is not None:
delete_saas_database(
Expand Down

0 comments on commit d0077eb

Please sign in to comment.