diff --git a/galaxy_ng/tests/integration/api/rbac_actions/utils.py b/galaxy_ng/tests/integration/api/rbac_actions/utils.py index 054b4c120e..eca4e6b15d 100644 --- a/galaxy_ng/tests/integration/api/rbac_actions/utils.py +++ b/galaxy_ng/tests/integration/api/rbac_actions/utils.py @@ -17,6 +17,7 @@ from galaxy_ng.tests.integration.utils.iqe_utils import get_ansible_config, \ get_galaxy_client, AnsibleConfigFixture +from galaxy_ng.tests.integration.constants import SLEEP_SECONDS_POLLING from galaxy_ng.tests.integration.utils.rbac_utils import create_local_image_container from galaxykit.container_images import get_container, get_container_images_latest ansible_config = get_ansible_config() @@ -130,7 +131,7 @@ def wait_for_task(resp, path=None, timeout=300): raise else: ready = resp.json()["state"] not in ("running", "waiting") - time.sleep(5) + time.sleep(SLEEP_SECONDS_POLLING) return resp diff --git a/galaxy_ng/tests/integration/api/test_container_push_update.py b/galaxy_ng/tests/integration/api/test_container_push_update.py index 0c6ce768cc..efd9956938 100644 --- a/galaxy_ng/tests/integration/api/test_container_push_update.py +++ b/galaxy_ng/tests/integration/api/test_container_push_update.py @@ -8,6 +8,7 @@ import pytest +from galaxy_ng.tests.integration.constants import SLEEP_SECONDS_ONETIME from galaxy_ng.tests.integration.utils import get_client from galaxy_ng.tests.integration.utils.iqe_utils import pull_and_tag_test_image from galaxykit.utils import wait_for_task @@ -107,7 +108,7 @@ def test_can_update_container_push(ansible_config, require_auth): client(container_href, method="PATCH", args={"retain_repo_versions": value}) # sleep 2 seconds waiting task to finish - time.sleep(2) + time.sleep(SLEEP_SECONDS_ONETIME) # assert the change was persisted repo = client(container_href) assert repo["retain_repo_versions"] == value diff --git a/galaxy_ng/tests/integration/api/test_container_signing.py b/galaxy_ng/tests/integration/api/test_container_signing.py index 744bc6dbfd..bd494dfbc0 100644 --- a/galaxy_ng/tests/integration/api/test_container_signing.py +++ b/galaxy_ng/tests/integration/api/test_container_signing.py @@ -8,6 +8,7 @@ import pytest +from galaxy_ng.tests.integration.constants import SLEEP_SECONDS_ONETIME from galaxy_ng.tests.integration.utils import get_client from galaxy_ng.tests.integration.utils.iqe_utils import pull_and_tag_test_image from galaxykit.container_images import get_container @@ -136,7 +137,7 @@ def test_push_and_sign_a_container(ansible_config, flags, require_auth, galaxy_c args={"manifest_signing_service": ss_href}) # sleep 2 second2 - time.sleep(2) + time.sleep(SLEEP_SECONDS_ONETIME) repo = client(container_href) latest_version_href = repo["latest_version_href"] diff --git a/galaxy_ng/tests/integration/api/test_namespace_management.py b/galaxy_ng/tests/integration/api/test_namespace_management.py index 2cfa33291b..52feebabe6 100644 --- a/galaxy_ng/tests/integration/api/test_namespace_management.py +++ b/galaxy_ng/tests/integration/api/test_namespace_management.py @@ -11,6 +11,7 @@ from galaxykit.repositories import search_collection from galaxykit.users import get_me +from galaxy_ng.tests.integration.constants import SLEEP_SECONDS_ONETIME 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, wait_for_namespace_tasks_gk @@ -157,7 +158,7 @@ def test_namespace_edit_logo(galaxy_client): } my_namespace = gc.post("_ui/v1/my-namespaces/", body=payload) assert my_namespace["avatar_url"] == '' - sleep(60) + sleep(SLEEP_SECONDS_ONETIME) wait_for_all_tasks_gk(gc) namespaces = gc.get('_ui/v1/my-namespaces/') @@ -169,7 +170,7 @@ def test_namespace_edit_logo(galaxy_client): "avatar_url": "https://avatars.githubusercontent.com/u/1869705?v=4" } gc.put(f"_ui/v1/my-namespaces/{name}/", body=payload) - sleep(60) + sleep(SLEEP_SECONDS_ONETIME) wait_for_all_tasks_gk(gc) updated_namespace = gc.get(f'_ui/v1/my-namespaces/{name}/') assert updated_namespace["avatar_url"] != "" diff --git a/galaxy_ng/tests/integration/api/test_repositories.py b/galaxy_ng/tests/integration/api/test_repositories.py index 2f43e7d266..e3eec1b017 100644 --- a/galaxy_ng/tests/integration/api/test_repositories.py +++ b/galaxy_ng/tests/integration/api/test_repositories.py @@ -2,6 +2,7 @@ import logging import time +from galaxy_ng.tests.integration.constants import SLEEP_SECONDS_POLLING from galaxy_ng.tests.integration.utils.iqe_utils import is_ocp_env from galaxy_ng.tests.integration.utils.rbac_utils import upload_test_artifact @@ -126,7 +127,7 @@ def test_move_cv_endpoint(self, galaxy_client): break except Exception as e: print(e) - time.sleep(5) + time.sleep(SLEEP_SECONDS_POLLING) if repo_pulp_href_2 is None: raise Exception("failed to create repo and dist") @@ -148,7 +149,7 @@ def test_move_cv_endpoint(self, galaxy_client): break except Exception as e: print(e) - time.sleep(5) + time.sleep(SLEEP_SECONDS_POLLING) # verify cv is only in destination repo _, results = search_collection_endpoint(gc_admin, name=artifact.name) diff --git a/galaxy_ng/tests/integration/api/test_upload_concurrency.py b/galaxy_ng/tests/integration/api/test_upload_concurrency.py index a4988ce171..ac45eecfd2 100644 --- a/galaxy_ng/tests/integration/api/test_upload_concurrency.py +++ b/galaxy_ng/tests/integration/api/test_upload_concurrency.py @@ -11,6 +11,7 @@ create_test_namespace from ..utils.tools import generate_random_string from ..utils.iqe_utils import aap_gateway +from galaxy_ng.tests.integration.constants import SLEEP_SECONDS_POLLING @pytest.mark.min_hub_version("4.8dev") @@ -64,6 +65,6 @@ def test_upload_concurrency(ansible_config, settings, galaxy_client): ) if matches == len(artifacts): break - time.sleep(10) + time.sleep(SLEEP_SECONDS_POLLING) assert matches == len(artifacts) diff --git a/galaxy_ng/tests/integration/community/test_community_api.py b/galaxy_ng/tests/integration/community/test_community_api.py index 1551ab7dee..f547153497 100644 --- a/galaxy_ng/tests/integration/community/test_community_api.py +++ b/galaxy_ng/tests/integration/community/test_community_api.py @@ -10,6 +10,7 @@ from urllib.parse import urlparse +from galaxy_ng.tests.integration.constants import SLEEP_SECONDS_POLLING from ..utils import ( ansible_galaxy, build_collection, @@ -283,7 +284,7 @@ def test_social_auth_delete_collection(ansible_config): ) if exists_resp.status_code == 200: break - time.sleep(5) + time.sleep(SLEEP_SECONDS_POLLING) assert exists_resp.status_code == 200 del_resp = client.delete( @@ -340,7 +341,7 @@ def test_social_auth_deprecate_collection(ansible_config): ) if exists_resp.status_code == 200: break - time.sleep(5) + time.sleep(SLEEP_SECONDS_POLLING) assert exists_resp.status_code == 200 dep_resp = client.patch( diff --git a/galaxy_ng/tests/integration/utils/iqe_utils.py b/galaxy_ng/tests/integration/utils/iqe_utils.py index f8f2d3e524..bef1bdeac2 100755 --- a/galaxy_ng/tests/integration/utils/iqe_utils.py +++ b/galaxy_ng/tests/integration/utils/iqe_utils.py @@ -8,6 +8,8 @@ from pkg_resources import parse_version +from galaxy_ng.tests.integration.constants import SLEEP_SECONDS_POLLING +from galaxy_ng.tests.integration.constants import POLLING_MAX_ATTEMPTS from galaxy_ng.tests.integration.constants import GALAXY_STAGE_ANSIBLE_PROFILES, \ EPHEMERAL_PROFILES, PROFILES, CREDENTIALS, SYNC_PROFILES, DEPLOYED_PAH_PROFILES from galaxy_ng.tests.integration.utils import get_client @@ -722,17 +724,15 @@ def require_signature_for_approval(): ansible_config = get_ansible_config() galaxy_client = get_galaxy_client(ansible_config) gc = galaxy_client("admin") - max_attempts = 5 - delay = 3 # we need retries because in ephemeral env we get 502 sometimes - for attempt in range(1, max_attempts + 1): + for attempt in range(1, POLLING_MAX_ATTEMPTS + 1): try: settings = gc.get_settings() return settings.get("GALAXY_REQUIRE_SIGNATURE_FOR_APPROVAL") except JSONDecodeError as e: - if attempt == max_attempts: + if attempt == POLLING_MAX_ATTEMPTS: raise e - time.sleep(delay) + time.sleep(SLEEP_SECONDS_POLLING) def sign_collection_on_demand(client, signing_service, repo, ns, collection_name, diff --git a/galaxy_ng/tests/integration/utils/legacy.py b/galaxy_ng/tests/integration/utils/legacy.py index a211c5e97f..010eb1b117 100644 --- a/galaxy_ng/tests/integration/utils/legacy.py +++ b/galaxy_ng/tests/integration/utils/legacy.py @@ -6,6 +6,7 @@ import time import yaml +from galaxy_ng.tests.integration.constants import SLEEP_SECONDS_POLLING from galaxykit.users import delete_user as delete_user_gk from .client_ansible_lib import get_client from .namespaces import cleanup_namespace, cleanup_namespace_gk @@ -32,7 +33,7 @@ def wait_for_v1_task(task_id=None, resp=None, api_client=None, check=True): state = task_resp['results'][0]['state'] if state != 'RUNNING': break - time.sleep(.5) + time.sleep(SLEEP_SECONDS_POLLING) if check: assert state == 'SUCCESS' diff --git a/galaxy_ng/tests/integration/utils/tasks.py b/galaxy_ng/tests/integration/utils/tasks.py index af6f8834df..64a7226416 100644 --- a/galaxy_ng/tests/integration/utils/tasks.py +++ b/galaxy_ng/tests/integration/utils/tasks.py @@ -30,7 +30,7 @@ def wait_for_all_tasks(client, timeout=300): ready = running_count == 0 and waiting_count == 0 - time.sleep(1) + time.sleep(SLEEP_SECONDS_POLLING) def wait_for_all_tasks_gk(gc, timeout=300): @@ -42,7 +42,7 @@ def wait_for_all_tasks_gk(gc, timeout=300): running_count = gc.get("pulp/api/v3/tasks/?state=running")["count"] waiting_count = gc.get("pulp/api/v3/tasks/?state=waiting")["count"] ready = running_count == 0 and waiting_count == 0 - time.sleep(1) + time.sleep(SLEEP_SECONDS_POLLING) def wait_for_task(api_client, resp, task_id=None, timeout=6000, raise_on_error=False): @@ -100,7 +100,7 @@ def wait_for_namespace_tasks_gk(gc, timeout=300): 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) + time.sleep(SLEEP_SECONDS_POLLING) class TaskFailed(Exception): diff --git a/galaxy_ng/tests/integration/utils/urls.py b/galaxy_ng/tests/integration/utils/urls.py index db47d7ac1b..c720d24975 100644 --- a/galaxy_ng/tests/integration/utils/urls.py +++ b/galaxy_ng/tests/integration/utils/urls.py @@ -7,6 +7,7 @@ from galaxykit.utils import GalaxyClientError from .errors import CapturingGalaxyError, TaskWaitingTimeout +from galaxy_ng.tests.integration.constants import SLEEP_SECONDS_POLLING def test_url_safe_join(): @@ -126,7 +127,7 @@ def wait_for_url(api_client, url, timeout_sec=6000): except (GalaxyError, CapturingGalaxyError, GalaxyClientError) as e: if "404" not in str(e): raise - time.sleep(0.5) + time.sleep(SLEEP_SECONDS_POLLING) else: ready = True return res diff --git a/profiles/base/run_integration.sh b/profiles/base/run_integration.sh index 6a071921c2..5c98c8caa0 100644 --- a/profiles/base/run_integration.sh +++ b/profiles/base/run_integration.sh @@ -45,7 +45,12 @@ cd /src/galaxy_ng/ # echo $MARKS - +export GALAXYKIT_SLEEP_SECONDS_POLLING=.5 +export GALAXYKIT_SLEEP_SECONDS_ONETIME=.5 +export GALAXYKIT_POLLING_MAX_ATTEMPTS=50 +export GALAXY_SLEEP_SECONDS_POLLING=.5 +export GALAXY_SLEEP_SECONDS_ONETIME=.5 +export GALAXY_POLLING_MAX_ATTEMPTS=50 # TODO: fix marks set -x diff --git a/profiles/dab_jwt/run_integration.sh b/profiles/dab_jwt/run_integration.sh index a46af96bfc..3d462182f6 100644 --- a/profiles/dab_jwt/run_integration.sh +++ b/profiles/dab_jwt/run_integration.sh @@ -26,6 +26,13 @@ export JWT_PROXY=true export AAP_GATEWAY=true export GW_ROOT_URL=http://jwtproxy:8080 +export GALAXYKIT_SLEEP_SECONDS_POLLING=.5 +export GALAXYKIT_SLEEP_SECONDS_ONETIME=.5 +export GALAXYKIT_POLLING_MAX_ATTEMPTS=50 +export GALAXY_SLEEP_SECONDS_POLLING=.5 +export GALAXY_SLEEP_SECONDS_ONETIME=.5 +export GALAXY_POLLING_MAX_ATTEMPTS=50 + #$VENVPATH/bin/pytest -v -r sx --color=yes "$@" galaxy_ng/tests/integration/dab $VENVPATH/bin/pytest -v -r sx --color=yes -m "$HUB_TEST_MARKS" "$@" galaxy_ng/tests/integration RC=$?