Skip to content

Commit

Permalink
Make container content related settings configurable (#17570)
Browse files Browse the repository at this point in the history
  • Loading branch information
dosas committed Feb 25, 2025
1 parent ad97f9d commit 3c55640
Show file tree
Hide file tree
Showing 23 changed files with 184 additions and 150 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 @@ -91,6 +91,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
6 changes: 0 additions & 6 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,12 +696,6 @@
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/'
CONTAINER_UPSTREAM_NAME = 'library/busybox'
DOCKER_REPO_UPSTREAM_NAME = 'openshift3/logging-elasticsearch'
CONTAINER_RH_REGISTRY_UPSTREAM_NAME = 'openshift3/ose-metrics-hawkular-openshift-agent'
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
6 changes: 2 additions & 4 deletions tests/foreman/api/test_capsulecontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

from robottelo.config import settings
from robottelo.constants import (
CONTAINER_CLIENTS,
ENVIRONMENT,
FAKE_1_YUM_REPOS_COUNT,
FAKE_3_YUM_REPO_RPMS,
Expand All @@ -35,7 +34,6 @@
PRDS,
REPOS,
REPOSET,
RH_CONTAINER_REGISTRY_HUB,
RPM_TO_UPLOAD,
DataFile,
)
Expand Down Expand Up @@ -920,7 +918,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 @@ -1423,7 +1421,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
3 changes: 1 addition & 2 deletions tests/foreman/api/test_contentview.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

from robottelo.config import settings, user_nailgun_config
from robottelo.constants import (
CONTAINER_REGISTRY_HUB,
CUSTOM_RPM_SHA_512_FEED_COUNT,
PERMISSIONS,
PRDS,
Expand Down Expand Up @@ -1097,7 +1096,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
16 changes: 8 additions & 8 deletions tests/foreman/api/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import pytest
from requests.exceptions import HTTPError

from robottelo.constants import CONTAINER_REGISTRY_HUB, CONTAINER_UPSTREAM_NAME
from robottelo.config import settings
from robottelo.utils.datafactory import (
generate_strings_list,
invalid_docker_upstream_names,
Expand All @@ -33,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 @@ -116,7 +116,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 @@ -221,7 +221,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 @@ -240,14 +240,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 @@ -348,9 +346,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
38 changes: 19 additions & 19 deletions tests/foreman/api/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -1597,9 +1597,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 @@ -1627,9 +1627,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 @@ -1670,11 +1670,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 @@ -1849,12 +1849,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 @@ -1882,11 +1882,11 @@ def test_positive_synchronize_docker_repo_with_included_tags(self, repo_options,
'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 @@ -1923,12 +1923,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 @@ -1954,12 +1954,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 3c55640

Please sign in to comment.