Skip to content

Commit

Permalink
Make container content related settings configurable (#17570)
Browse files Browse the repository at this point in the history
(cherry picked from commit fc02e89)
  • Loading branch information
dosas authored and web-flow committed Feb 25, 2025
1 parent aa6bc1b commit c8bc53b
Show file tree
Hide file tree
Showing 26 changed files with 192 additions and 165 deletions.
15 changes: 15 additions & 0 deletions conf/container.yaml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
CONTAINER:
CLIENTS:
- docker
- podman
REGISTRY_HUB: https://mirror.gcr.io
UPSTREAM_NAME: 'library/busybox'
DOCKER:
REPO_UPSTREAM_NAME: 'openshift3/logging-elasticsearch'
PULP:
REGISTRY_HUB: 'https://ghcr.io'
RH:
REGISTRY_HUB: 'https://registry.redhat.io/'
UPSTREAM_NAME: 'openshift3/ose-metrics-hawkular-openshift-agent'
...
41 changes: 41 additions & 0 deletions robottelo/config/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,47 @@
Validator('libvirt.libvirt_hostname', must_exist=True),
Validator('libvirt.libvirt_image_dir', default='/var/lib/libvirt/images'),
],
container=[
Validator(
'container.clients', must_exist=True, is_type_of=list, default=['docker', 'podman']
),
Validator(
'container.registry_hub',
must_exist=True,
is_type_of=str,
default='https://mirror.gcr.io',
),
Validator(
'container.upstream_name',
must_exist=True,
is_type_of=str,
default='library/busybox',
),
Validator(
'container.docker.repo_upstream_name',
must_exist=True,
is_type_of=str,
default='openshift3/logging-elasticsearch',
),
Validator(
'container.pulp.registry_hub',
must_exist=True,
is_type_of=str,
default='https://ghcr.io',
),
Validator(
'container.rh.registry_hub',
must_exist=True,
is_type_of=str,
default='https://registry.redhat.io/',
),
Validator(
'container.rh.upstream_name',
must_exist=True,
is_type_of=str,
default='openshift3/ose-metrics-hawkular-openshift-agent',
),
],
container_repo=[
Validator(
'container_repo.registries.redhat.url',
Expand Down
8 changes: 1 addition & 7 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,12 +792,7 @@
FILTER_ERRATA_DATE = {'updated': "updated", 'issued': "issued"}

REPORT_TEMPLATE_FILE = 'report_template.txt'
CONTAINER_REGISTRY_HUB = 'https://mirror.gcr.io'
RH_CONTAINER_REGISTRY_HUB = 'https://registry.redhat.io/'
PULP_CONTAINER_REGISTRY_HUB = 'https://ghcr.io'
CONTAINER_UPSTREAM_NAME = 'library/busybox'
DOCKER_REPO_UPSTREAM_NAME = 'openshift3/logging-elasticsearch'
CONTAINER_RH_REGISTRY_UPSTREAM_NAME = 'openshift3/ose-metrics-hawkular-openshift-agent'

BOOTABLE_REPO = {
'upstream_name': 'pulp/bootc-labeled',
'manifest': {
Expand Down Expand Up @@ -851,7 +846,6 @@
'katello': 'https://{}/' + FLATPAK_INDEX_SUFFIX,
}

CONTAINER_CLIENTS = ['docker', 'podman']
CUSTOM_LOCAL_FOLDER = '/var/lib/pulp/imports/myrepo/'
CUSTOM_LOCAL_FILE = '/var/lib/pulp/imports/myrepo/test.txt'
CUSTOM_FILE_REPO_FILES_COUNT = 3
Expand Down
12 changes: 4 additions & 8 deletions tests/foreman/api/test_capsulecontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@

from robottelo.config import settings
from robottelo.constants import (
CONTAINER_CLIENTS,
CONTAINER_REGISTRY_HUB,
CONTAINER_UPSTREAM_NAME,
ENVIRONMENT,
FAKE_1_YUM_REPOS_COUNT,
FAKE_3_YUM_REPO_RPMS,
Expand All @@ -42,7 +39,6 @@
PULP_ARTIFACT_DIR,
REPOS,
REPOSET,
RH_CONTAINER_REGISTRY_HUB,
RPM_TO_UPLOAD,
DataFile,
)
Expand Down Expand Up @@ -981,7 +977,7 @@ def test_positive_sync_container_repo_end_to_end(
for repo in repos
]

for con_client in CONTAINER_CLIENTS:
for con_client in settings.container.clients:
result = module_container_contenthost.execute(
f'{con_client} login -u {settings.server.admin_username}'
f' -p {settings.server.admin_password} {module_capsule_configured.hostname}'
Expand Down Expand Up @@ -1609,7 +1605,7 @@ def test_positive_capsule_sync_openstack_container_repos(
content_type='docker',
docker_upstream_name=ups_name,
product=function_product,
url=RH_CONTAINER_REGISTRY_HUB,
url=settings.container.rh.registry_hub,
upstream_username=settings.subscription.rhn_username,
upstream_password=settings.subscription.rhn_password,
).create()
Expand Down Expand Up @@ -1647,8 +1643,8 @@ def test_positive_capsule_sync_openstack_container_repos(
'YumRepository': {'url': settings.repos.module_stream_1.url},
'FileRepository': {'url': CUSTOM_FILE_REPO},
'DockerRepository': {
'url': CONTAINER_REGISTRY_HUB,
'upstream_name': CONTAINER_UPSTREAM_NAME,
'url': settings.container.registry_hub,
'upstream_name': settings.container.upstream_name,
},
'AnsibleRepository': {
'url': ANSIBLE_GALAXY,
Expand Down
3 changes: 1 addition & 2 deletions tests/foreman/api/test_contentview.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

from robottelo.config import settings, user_nailgun_config
from robottelo.constants import (
CONTAINER_REGISTRY_HUB,
CUSTOM_RPM_SHA_512_FEED_COUNT,
DEFAULT_ARCHITECTURE,
PERMISSIONS,
Expand Down Expand Up @@ -1258,7 +1257,7 @@ def initiate_testclass(self, request, module_product, class_target_sat):
content_type='docker',
docker_upstream_name='busybox',
product=module_product,
url=CONTAINER_REGISTRY_HUB,
url=settings.container.registry_hub,
).create()
self.docker_repo.sync()

Expand Down
5 changes: 2 additions & 3 deletions tests/foreman/api/test_contentviewfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from requests.exceptions import HTTPError

from robottelo.config import settings
from robottelo.constants import CONTAINER_REGISTRY_HUB
from robottelo.utils.datafactory import (
parametrized,
valid_data_list,
Expand Down Expand Up @@ -217,7 +216,7 @@ def test_positive_create_with_docker_repos(
content_type='docker',
docker_upstream_name='busybox',
product=module_product.id,
url=CONTAINER_REGISTRY_HUB,
url=settings.container.registry_hub,
).create()
content_view.repository = [sync_repo, docker_repository]
content_view.update(['repository'])
Expand Down Expand Up @@ -428,7 +427,7 @@ def test_positive_update_repo_with_docker(
content_type='docker',
docker_upstream_name='busybox',
product=module_product.id,
url=CONTAINER_REGISTRY_HUB,
url=settings.container.registry_hub,
).create()
content_view.repository = [sync_repo, docker_repository]
content_view = content_view.update(['repository'])
Expand Down
15 changes: 7 additions & 8 deletions tests/foreman/api/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from requests.exceptions import HTTPError

from robottelo.config import settings
from robottelo.constants import CONTAINER_REGISTRY_HUB, CONTAINER_UPSTREAM_NAME
from robottelo.utils.datafactory import (
generate_strings_list,
invalid_docker_upstream_names,
Expand All @@ -34,19 +33,19 @@ def _create_repository(module_target_sat, product, name=None, upstream_name=None
:param str name: Name for the repository. If ``None`` then a random
value will be generated.
:param str upstream_name: A valid name of an existing upstream repository.
If ``None`` then defaults to CONTAINER_UPSTREAM_NAME.
If ``None`` then defaults to settings.container.upstream_name.
:return: A ``Repository`` object.
"""
if name is None:
name = choice(generate_strings_list(15, ['numeric', 'html']))
if upstream_name is None:
upstream_name = CONTAINER_UPSTREAM_NAME
upstream_name = settings.container.upstream_name
return module_target_sat.api.Repository(
content_type='docker',
docker_upstream_name=upstream_name,
name=name,
product=product,
url=CONTAINER_REGISTRY_HUB,
url=settings.container.registry_hub,
).create()


Expand Down Expand Up @@ -125,7 +124,7 @@ def test_positive_create_with_name(self, module_product, name, module_target_sat
"""
repo = _create_repository(module_target_sat, module_product, name)
assert repo.name == name
assert repo.docker_upstream_name == CONTAINER_UPSTREAM_NAME
assert repo.docker_upstream_name == settings.container.upstream_name
assert repo.content_type == 'docker'

@pytest.mark.tier1
Expand Down Expand Up @@ -230,7 +229,7 @@ def test_positive_update_upstream_name(self, repo):
:CaseImportance: Critical
"""
assert repo.docker_upstream_name == CONTAINER_UPSTREAM_NAME
assert repo.docker_upstream_name == settings.container.upstream_name

# Update the repository upstream name
new_upstream_name = 'fedora/ssh'
Expand All @@ -249,14 +248,14 @@ def test_positive_update_url(self, repo):
:BZ: 1489322
"""
assert repo.url == CONTAINER_REGISTRY_HUB
assert repo.url == settings.container.registry_hub

# Update the repository URL
new_url = gen_url()
repo.url = new_url
repo = repo.update()
assert repo.url == new_url
assert repo.url != CONTAINER_REGISTRY_HUB
assert repo.url != settings.container.registry_hub

@pytest.mark.tier1
def test_positive_delete(self, repo):
Expand Down
8 changes: 2 additions & 6 deletions tests/foreman/api/test_http_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@

from robottelo import constants
from robottelo.config import settings
from robottelo.constants import (
CONTAINER_REGISTRY_HUB,
CONTAINER_UPSTREAM_NAME,
)
from robottelo.constants.repos import ANSIBLE_GALAXY, CUSTOM_FILE_REPO


Expand All @@ -43,8 +39,8 @@
'YumRepository': {'url': settings.repos.module_stream_1.url},
'FileRepository': {'url': CUSTOM_FILE_REPO},
'DockerRepository': {
'url': CONTAINER_REGISTRY_HUB,
'upstream_name': CONTAINER_UPSTREAM_NAME,
'url': settings.container.registry_hub,
'upstream_name': settings.container.upstream_name,
},
'AnsibleRepository': {
'url': ANSIBLE_GALAXY,
Expand Down
6 changes: 2 additions & 4 deletions tests/foreman/api/test_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

from robottelo.config import settings
from robottelo.constants import (
CONTAINER_REGISTRY_HUB,
CONTAINER_UPSTREAM_NAME,
REPO_TYPE,
DataFile,
)
Expand Down Expand Up @@ -180,9 +178,9 @@ def test_positive_sync_several_repos(module_org, module_target_sat):
).create()
docker_repo = module_target_sat.api.Repository(
content_type=REPO_TYPE['docker'],
docker_upstream_name=CONTAINER_UPSTREAM_NAME,
docker_upstream_name=settings.container.upstream_name,
product=product,
url=CONTAINER_REGISTRY_HUB,
url=settings.container.registry_hub,
).create()
assert rpm_repo.read().content_counts['rpm'] == 0
assert docker_repo.read().content_counts['docker_tag'] == 0
Expand Down
40 changes: 20 additions & 20 deletions tests/foreman/api/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -1549,9 +1549,9 @@ class TestDockerRepository:
[
{
'content_type': 'docker',
'docker_upstream_name': constants.CONTAINER_UPSTREAM_NAME,
'docker_upstream_name': settings.container.upstream_name,
'name': name,
'url': constants.CONTAINER_REGISTRY_HUB,
'url': settings.container.registry_hub,
}
for name in datafactory.valid_docker_repository_names()
]
Expand Down Expand Up @@ -1579,9 +1579,9 @@ def test_positive_create(self, repo_options, repo):
{
'large_repo': {
'content_type': 'docker',
'docker_upstream_name': constants.DOCKER_REPO_UPSTREAM_NAME,
'docker_upstream_name': settings.container.docker.repo_upstream_name,
'name': gen_string('alphanumeric', 10),
'url': constants.RH_CONTAINER_REGISTRY_HUB,
'url': settings.container.rh.registry_hub,
'upstream_username': settings.subscription.rhn_username,
'upstream_password': settings.subscription.rhn_password,
}
Expand Down Expand Up @@ -1622,11 +1622,11 @@ def test_positive_cancel_docker_repo_sync(self, repo, target_sat):
'repo_options_custom_product',
**datafactory.parametrized(
{
constants.CONTAINER_UPSTREAM_NAME: {
settings.container.upstream_name: {
'content_type': 'docker',
'docker_upstream_name': constants.CONTAINER_UPSTREAM_NAME,
'docker_upstream_name': settings.container.upstream_name,
'name': gen_string('alphanumeric', 10),
'url': constants.CONTAINER_REGISTRY_HUB,
'url': settings.container.registry_hub,
}
}
),
Expand Down Expand Up @@ -1801,12 +1801,12 @@ def test_negative_synchronize_private_registry_no_passwd(
'repo_options',
**datafactory.parametrized(
{
constants.CONTAINER_UPSTREAM_NAME: {
settings.container.upstream_name: {
'content_type': 'docker',
'include_tags': ['latest'],
'docker_upstream_name': constants.CONTAINER_UPSTREAM_NAME,
'docker_upstream_name': settings.container.upstream_name,
'name': gen_string('alphanumeric', 10),
'url': constants.CONTAINER_REGISTRY_HUB,
'url': settings.container.registry_hub,
}
}
),
Expand Down Expand Up @@ -1836,7 +1836,7 @@ def test_positive_synchronize_docker_repo_with_included_tags(self, repo_options,
'content_type': 'docker',
'docker_upstream_name': item['upstream_name'],
'name': gen_string('alpha'),
'url': constants.PULP_CONTAINER_REGISTRY_HUB,
'url': settings.container.pulp.registry_hub,
}
for item in LABELLED_REPOS
]
Expand Down Expand Up @@ -1908,11 +1908,11 @@ def test_positive_synchronize_docker_repo_with_manifest_labels(
'repo_options',
**datafactory.parametrized(
{
constants.CONTAINER_UPSTREAM_NAME: {
settings.container.upstream_name: {
'content_type': 'docker',
'docker_upstream_name': constants.CONTAINER_UPSTREAM_NAME,
'docker_upstream_name': settings.container.upstream_name,
'name': gen_string('alphanumeric', 10),
'url': constants.CONTAINER_REGISTRY_HUB,
'url': settings.container.registry_hub,
}
}
),
Expand Down Expand Up @@ -1949,12 +1949,12 @@ def test_positive_synchronize_docker_repo_set_tags_later(self, repo):
'repo_options',
**datafactory.parametrized(
{
constants.CONTAINER_UPSTREAM_NAME: {
settings.container.upstream_name: {
'content_type': 'docker',
'include_tags': ['latest', gen_string('alpha')],
'docker_upstream_name': constants.CONTAINER_UPSTREAM_NAME,
'docker_upstream_name': settings.container.upstream_name,
'name': gen_string('alphanumeric', 10),
'url': constants.CONTAINER_REGISTRY_HUB,
'url': settings.container.registry_hub,
}
}
),
Expand All @@ -1980,12 +1980,12 @@ def test_negative_synchronize_docker_repo_with_mix_valid_invalid_tags(self, repo
'repo_options',
**datafactory.parametrized(
{
constants.CONTAINER_UPSTREAM_NAME: {
settings.container.upstream_name: {
'content_type': 'docker',
'include_tags': [gen_string('alpha') for _ in range(3)],
'docker_upstream_name': constants.CONTAINER_UPSTREAM_NAME,
'docker_upstream_name': settings.container.upstream_name,
'name': gen_string('alphanumeric', 10),
'url': constants.CONTAINER_REGISTRY_HUB,
'url': settings.container.registry_hub,
}
}
),
Expand Down
Loading

0 comments on commit c8bc53b

Please sign in to comment.