Skip to content

Commit

Permalink
Fix flaky test_namespace_create_and_delete[v3] (#2010)
Browse files Browse the repository at this point in the history
wait_for_namespace_tasks_gk
No-Issue
  • Loading branch information
jerabekjiri authored Dec 12, 2023
1 parent 141ae4f commit e607f1d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion galaxy_ng/tests/integration/api/test_namespace_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from ..utils.iqe_utils import is_stage_environment
from ..utils.repo_management_utils import upload_new_artifact
from ..utils.tasks import wait_for_all_tasks_gk
from ..utils.tasks import wait_for_all_tasks_gk, wait_for_namespace_tasks_gk
from ..utils.tools import generate_random_string

pytestmark = pytest.mark.qa # noqa: F821
Expand All @@ -39,6 +39,7 @@ def test_namespace_create_and_delete(api_version, galaxy_client):
new_namespace = f"ns_test_{generate_random_string()}"
payload = {'name': new_namespace, 'groups': []}
resp = gc.post(f"{api_version}/namespaces/", body=payload)
wait_for_namespace_tasks_gk(gc)
assert resp['name'] == new_namespace
if api_version == "v3":
get_namespace(gc, new_namespace)
Expand Down
12 changes: 12 additions & 0 deletions galaxy_ng/tests/integration/utils/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ def wait_for_task_ui_client(uclient, task):
assert state == 'completed'


def wait_for_namespace_tasks_gk(gc, timeout=300):
ready = False
wait_until = time.time() + timeout
while not ready:
if wait_until < time.time():
raise TaskWaitingTimeout()
running_count = gc.get("pulp/api/v3/tasks/?state=running&name__contains=namespace")["count"]
waiting_count = gc.get("pulp/api/v3/tasks/?state=waiting&name__contains=namespace")["count"]
ready = running_count == 0 and waiting_count == 0
time.sleep(1)


class TaskFailed(Exception):
def __init__(self, message):
self.message = message

0 comments on commit e607f1d

Please sign in to comment.