Skip to content

Commit

Permalink
Release 4.9.1 (#2047)
Browse files Browse the repository at this point in the history
* bump to 4.9.1
* include test namespace changes from master
* pin pytest-django<8
* pin pytest<8
No-Issue
  • Loading branch information
jerabekjiri authored Jan 31, 2024
1 parent ed857eb commit c19cdd3
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 94 deletions.
13 changes: 13 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://issues.redhat.com/browse/AAH-2588>`_


----


4.9.0 (2023-12-06)
==================

Expand Down
1 change: 0 additions & 1 deletion CHANGES/2588.bugfix

This file was deleted.

2 changes: 1 addition & 1 deletion galaxy_ng/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion galaxy_ng/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
150 changes: 62 additions & 88 deletions galaxy_ng/tests/integration/api/test_namespace_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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']

Expand All @@ -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']

Expand All @@ -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)
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 @@ -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}/"
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 4.9.0
current_version = 4.9.1
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>[a-z]+))?((?P<build>\d+))?
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion unittest_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mock
orionutils
pytest-django
pytest-django<8
pytest<8

0 comments on commit c19cdd3

Please sign in to comment.