Skip to content

fix(test): fix stop deleting registries in integration tests #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2023
Merged
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
23 changes: 4 additions & 19 deletions tests/integrations/project_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
from scaleway import Client
from scaleway.account.v2 import AccountV2API
from scaleway.function.v1beta1 import FunctionV1Beta1API
from scaleway.registry.v1 import RegistryV1API
from scaleway_core.api import ScalewayException
from scaleway_core.utils import WaitForOptions

from .utils import create_client

Expand Down Expand Up @@ -42,30 +40,17 @@ def _create_scaleway_project(client: Client) -> ProjectID:

def _cleanup_project(client: Client, project_id: ProjectID):
"""Delete all Scaleway resources created in the temporary project."""
function_api = FunctionV1Beta1API(client)
api = FunctionV1Beta1API(client)

namespaces = function_api.list_namespaces_all(project_id=project_id)
namespaces = api.list_namespaces_all(project_id=project_id)
for namespace in namespaces:
function_api.delete_namespace(namespace_id=namespace.id)

registry_api = RegistryV1API(client)
registries = registry_api.list_namespaces_all(project_id=project_id)
for registry in registries:
registry_api.delete_namespace(namespace_id=registry.id)
api.delete_namespace(namespace_id=namespace.id)

# All deletions have been scheduled,
# we can wait for their completion sequentially
for namespace in namespaces:
try:
function_api.wait_for_namespace(namespace_id=namespace.id)
except ScalewayException as e:
if e.status_code != 404:
raise e
for registry in registries:
try:
registry_api.wait_for_namespace(
namespace_id=registry.id, options=WaitForOptions(timeout=600)
)
api.wait_for_namespace(namespace_id=namespace.id)
except ScalewayException as e:
if e.status_code != 404:
raise e
Expand Down