From c19cdd39301feb17556bb8726d994e6988eb9b26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Je=C5=99=C3=A1bek=20=28Jiri=20Jerabek=29?= Date: Wed, 31 Jan 2024 17:27:15 +0100 Subject: [PATCH] Release 4.9.1 (#2047) * bump to 4.9.1 * include test namespace changes from master * pin pytest-django<8 * pin pytest<8 No-Issue --- CHANGES.rst | 13 ++ CHANGES/2588.bugfix | 1 - galaxy_ng/__init__.py | 2 +- galaxy_ng/app/__init__.py | 2 +- .../api/test_namespace_management.py | 150 ++++++++---------- galaxy_ng/tests/integration/utils/tasks.py | 12 ++ setup.cfg | 2 +- setup.py | 2 +- unittest_requirements.txt | 3 +- 9 files changed, 93 insertions(+), 94 deletions(-) delete mode 100644 CHANGES/2588.bugfix diff --git a/CHANGES.rst b/CHANGES.rst index 58fa3c8dd0..0fa1199d34 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -13,6 +13,19 @@ Changelog .. towncrier release notes start +4.9.1 (2024-01-30) +================== + +Bugfixes +-------- + +- bump pulp_ansible to enable re-upload of deleted collection version + `AAH-2588 `_ + + +---- + + 4.9.0 (2023-12-06) ================== diff --git a/CHANGES/2588.bugfix b/CHANGES/2588.bugfix deleted file mode 100644 index 334f6554f0..0000000000 --- a/CHANGES/2588.bugfix +++ /dev/null @@ -1 +0,0 @@ -bump pulp_ansible to enable re-upload of deleted collection version diff --git a/galaxy_ng/__init__.py b/galaxy_ng/__init__.py index c04ed3ece2..dfe22ca7c3 100644 --- a/galaxy_ng/__init__.py +++ b/galaxy_ng/__init__.py @@ -3,6 +3,6 @@ sys.modules.setdefault("automated_logging", automated_logging) -__version__ = "4.9.0" +__version__ = "4.9.1" default_app_config = "galaxy_ng.app.PulpGalaxyPluginAppConfig" diff --git a/galaxy_ng/app/__init__.py b/galaxy_ng/app/__init__.py index a6ad3e041e..cc0a8f3d87 100644 --- a/galaxy_ng/app/__init__.py +++ b/galaxy_ng/app/__init__.py @@ -6,7 +6,7 @@ class PulpGalaxyPluginAppConfig(PulpPluginAppConfig): name = "galaxy_ng.app" label = "galaxy" - version = "4.9.0" + version = "4.9.1" python_package_name = "galaxy-ng" def ready(self): diff --git a/galaxy_ng/tests/integration/api/test_namespace_management.py b/galaxy_ng/tests/integration/api/test_namespace_management.py index 208b99c935..70e88ec1ad 100644 --- a/galaxy_ng/tests/integration/api/test_namespace_management.py +++ b/galaxy_ng/tests/integration/api/test_namespace_management.py @@ -3,18 +3,25 @@ See: https://issues.redhat.com/browse/AAH-1303 """ +from time import sleep + import pytest + from ansible.errors import AnsibleError +from galaxykit.repositories import search_collection + +from ..utils.repo_management_utils import upload_new_artifact +from ..utils.iqe_utils import is_stage_environment from ..utils import ( - build_collection as galaxy_build_collection, get_all_namespaces, get_client, generate_unused_namespace, - wait_for_all_tasks, - wait_for_task, ) +from ..utils.tasks import wait_for_all_tasks_gk +from ..utils.tools import generate_random_string + pytestmark = pytest.mark.qa # noqa: F821 @@ -173,46 +180,40 @@ def test_namespace_edit_with_user(ansible_config, user_property): @pytest.mark.namespace @pytest.mark.all -def test_namespace_edit_logo(ansible_config): - - config = ansible_config("admin") - api_client = get_client(config, request_token=True, require_auth=True) - api_prefix = config.get("api_prefix").rstrip("/") - - new_namespace = generate_unused_namespace(api_client=api_client) - +def test_namespace_edit_logo(galaxy_client): + gc = galaxy_client("admin") + new_namespace = f"ns_test_{generate_random_string()}" payload = { 'name': new_namespace, } - my_namespace = api_client(f'{api_prefix}/_ui/v1/my-namespaces/', args=payload, method='POST') + my_namespace = gc.post("_ui/v1/my-namespaces/", body=payload) assert my_namespace["avatar_url"] == '' - namespaces = api_client(f'{api_prefix}/_ui/v1/my-namespaces/') - + namespaces = gc.get('_ui/v1/my-namespaces/') name = my_namespace["name"] payload = { "name": name, - "avatar_url": "http://placekitten.com/400/400" + # "avatar_url": "http://placekitten.com/400/400" + "avatar_url": "https://avatars.githubusercontent.com/u/1869705?v=4" } - api_client(f'{api_prefix}/_ui/v1/my-namespaces/{name}/', args=payload, method='PUT') - - wait_for_all_tasks(api_client) - updated_namespace = api_client(f'{api_prefix}/_ui/v1/my-namespaces/{name}/') + gc.put(f"_ui/v1/my-namespaces/{name}/", body=payload) + wait_for_all_tasks_gk(gc) + updated_namespace = gc.get(f'_ui/v1/my-namespaces/{name}/') assert updated_namespace["avatar_url"] != "" payload = { "name": name, - "avatar_url": "http://placekitten.com/123/456" + # "avatar_url": "http://placekitten.com/123/456" + "avatar_url": "https://avatars.githubusercontent.com/u/481677?v=4" } - resp = api_client(f'{api_prefix}/_ui/v1/my-namespaces/{name}/', args=payload, method='PUT') - - wait_for_all_tasks(api_client) - updated_again_namespace = api_client(f'{api_prefix}/_ui/v1/my-namespaces/{name}/') + gc.put(f"_ui/v1/my-namespaces/{name}/", body=payload) + wait_for_all_tasks_gk(gc) + updated_again_namespace = gc.get(f"_ui/v1/my-namespaces/{name}/") assert updated_namespace["avatar_url"] != updated_again_namespace["avatar_url"] # verify no additional namespaces are created - resp = api_client(f'{api_prefix}/_ui/v1/my-namespaces/') + resp = gc.get("_ui/v1/my-namespaces/") assert resp["meta"]["count"] == namespaces["meta"]["count"] # verify no side effects @@ -225,65 +226,47 @@ def test_namespace_edit_logo(ansible_config): assert my_namespace[field] != updated_again_namespace[field] -def _test_namespace_logo_propagates_to_collections(ansible_config, upload_artifact, is_insights): - admin_config = ansible_config("admin") - api_prefix = admin_config.get("api_prefix").rstrip("/") - api_client = get_client(admin_config, request_token=True, require_auth=True) - - namespace_name = generate_unused_namespace(api_client=api_client) - - # create empty namespace +def _test_namespace_logo_propagates_to_collections(galaxy_client, is_insights): + gc = galaxy_client("admin") + namespace_name = f"ns_test_{generate_random_string()}" payload = { 'name': namespace_name } - my_namespace = api_client(f'{api_prefix}/_ui/v1/my-namespaces/', args=payload, method='POST') - wait_for_all_tasks(api_client) + my_namespace = gc.post("_ui/v1/my-namespaces/", body=payload) assert my_namespace["avatar_url"] == '' assert my_namespace["avatar_sha256"] is None assert my_namespace["metadata_sha256"] is not None - artifact = galaxy_build_collection(namespace=namespace_name) + artifact = upload_new_artifact( + gc, namespace_name, "published", "1.0.1", tags=["application"] + ) + if is_stage_environment(): + sleep(90) - # upload collection to namespace - upload_task = upload_artifact(admin_config, api_client, artifact) - resp = wait_for_task(api_client, upload_task) - assert resp["state"] == "completed" + resp = search_collection(gc, namespace=namespace_name, name=artifact.name) - # verify cv index is correct - search_url = ( - api_prefix - + '/v3/plugin/ansible/search/collection-versions/' - + f'?namespace={namespace_name}&name={artifact.name}' - ) - resp = api_client.request(search_url) assert resp['data'][0]['namespace_metadata']["avatar_url"] is None # upload logo to namespace payload = { "name": namespace_name, - "avatar_url": "http://placekitten.com/123/456" + # "avatar_url": "http://placekitten.com/123/456" + "avatar_url": "https://avatars.githubusercontent.com/u/1869705?v=4" } - api_client(f'{api_prefix}/_ui/v1/my-namespaces/{namespace_name}/', args=payload, method='PUT') - wait_for_all_tasks(api_client) + gc.put(f"_ui/v1/my-namespaces/{namespace_name}/", body=payload) + if is_stage_environment(): + sleep(90) + wait_for_all_tasks_gk(gc) # namespace logo was updated correctly - my_namespace = api_client(f'{api_prefix}/_ui/v1/my-namespaces/{namespace_name}/') + my_namespace = gc.get(f'_ui/v1/my-namespaces/{namespace_name}/') assert my_namespace["avatar_url"] is not None - search_url = ( - api_prefix - + '/v3/plugin/ansible/search/collection-versions/' - + f'?namespace={namespace_name}&name={artifact.name}' - ) - resp = api_client(search_url) + resp = search_collection(gc, namespace=namespace_name, name=artifact.name) cv_namespace_metadata = resp['data'][0]['namespace_metadata'] - - namespace_metadata = api_client( - api_prefix - + '/pulp/api/v3/content/ansible/namespaces/' - f'?name={namespace_name}&ordering=-pulp_created' - )['results'][0] - + resp = gc.get(f"pulp/api/v3/content/ansible/namespaces/" + f"?name={namespace_name}&ordering=-pulp_created") + namespace_metadata = resp['results'][0] # verify that collection is using latest namespace avatar assert cv_namespace_metadata['avatar_url'] == namespace_metadata['avatar_url'] @@ -300,36 +283,27 @@ def _test_namespace_logo_propagates_to_collections(ansible_config, upload_artifa "name": namespace_name, "description": "hehe hihi haha", "company": "RedHat Inc.", - "avatar_url": "http://placekitten.com/654/321" + # "avatar_url": "http://placekitten.com/654/321" + "avatar_url": "https://avatars.githubusercontent.com/u/481677?v=4" } - api_client( - f'{api_prefix}/_ui/v1/my-namespaces/{namespace_name}/', - args=payload, - method='PUT' - ) + gc.put(f"_ui/v1/my-namespaces/{namespace_name}/", body=payload) + if is_stage_environment(): + sleep(90) assert my_namespace["avatar_sha256"] is not None assert my_namespace["metadata_sha256"] is not None - wait_for_all_tasks(api_client) + wait_for_all_tasks_gk(gc) - my_namespace = api_client(f'{api_prefix}/_ui/v1/my-namespaces/{namespace_name}/') + my_namespace = gc.get(f'_ui/v1/my-namespaces/{namespace_name}/') # verify cv metadata are latest and correct - search_url = ( - api_prefix - + '/v3/plugin/ansible/search/collection-versions/' - + f'?namespace={namespace_name}&name={artifact.name}' - ) - resp = api_client(search_url) + resp = search_collection(gc, namespace=namespace_name, name=artifact.name) cv_namespace_metadata = resp['data'][0]['namespace_metadata'] assert cv_namespace_metadata["description"] == "hehe hihi haha" assert cv_namespace_metadata["company"] == "RedHat Inc." - namespace_metadata = api_client( - api_prefix - + '/pulp/api/v3/content/ansible/namespaces/' - f'?name={namespace_name}&ordering=-pulp_created' - )['results'][0] - + resp = gc.get(f"pulp/api/v3/content/ansible/namespaces/" + f"?name={namespace_name}&ordering=-pulp_created") + namespace_metadata = resp["results"][0] # verify cv idnex is using latest matedata assert cv_namespace_metadata['avatar_url'] == namespace_metadata['avatar_url'] @@ -340,11 +314,11 @@ def _test_namespace_logo_propagates_to_collections(ansible_config, upload_artifa @pytest.mark.namespace @pytest.mark.deployment_community @pytest.mark.deployment_standalone -def test_namespace_logo_propagates_to_collections(ansible_config, upload_artifact): - _test_namespace_logo_propagates_to_collections(ansible_config, upload_artifact, False) +def test_namespace_logo_propagates_to_collections(galaxy_client): + _test_namespace_logo_propagates_to_collections(galaxy_client, False) @pytest.mark.namespace @pytest.mark.deployment_cloud -def test_insights_namespace_logo_propagates_to_collections(ansible_config, upload_artifact): - _test_namespace_logo_propagates_to_collections(ansible_config, upload_artifact, True) +def test_insights_namespace_logo_propagates_to_collections(galaxy_client): + _test_namespace_logo_propagates_to_collections(galaxy_client, True) diff --git a/galaxy_ng/tests/integration/utils/tasks.py b/galaxy_ng/tests/integration/utils/tasks.py index a6c27a9cfa..6a03a029cf 100644 --- a/galaxy_ng/tests/integration/utils/tasks.py +++ b/galaxy_ng/tests/integration/utils/tasks.py @@ -33,6 +33,18 @@ def wait_for_all_tasks(client, timeout=300): time.sleep(1) +def wait_for_all_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")["count"] + waiting_count = gc.get("pulp/api/v3/tasks/?state=waiting")["count"] + ready = running_count == 0 and waiting_count == 0 + time.sleep(1) + + def wait_for_task(api_client, resp, task_id=None, timeout=6000, raise_on_error=False): if task_id: url = f"v3/tasks/{task_id}/" diff --git a/setup.cfg b/setup.cfg index 284c97bf1e..d92be41ec4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 4.9.0 +current_version = 4.9.1 commit = False tag = False parse = (?P\d+)\.(?P\d+)\.(?P\d+)((?P[a-z]+))?((?P\d+))? diff --git a/setup.py b/setup.py index d2678af0c7..ea94fe81f2 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ from setuptools.command.sdist import sdist as _SDistCommand package_name = os.environ.get("GALAXY_NG_ALTERNATE_NAME", "galaxy-ng") -version = "4.9.0" +version = "4.9.1" class PrepareStaticCommand(Command): diff --git a/unittest_requirements.txt b/unittest_requirements.txt index 51c7f8078b..1b5956fbb1 100644 --- a/unittest_requirements.txt +++ b/unittest_requirements.txt @@ -1,3 +1,4 @@ mock orionutils -pytest-django +pytest-django<8 +pytest<8