Skip to content

Commit f99237b

Browse files
Use Convert2RHEL repofiles instead of deprecated repos for tests
Signed-off-by: Gaurav Talreja <gtalreja@redhat.com>
1 parent fdaa318 commit f99237b

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

robottelo/content_info.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,27 @@ def get_repo_files_by_url(url, extension='rpm'):
6969
return sorted([os.path.basename(f) for f in get_repo_files_urls_by_url(url, extension)])
7070

7171

72+
def get_baseurl_by_repofile(repo_url, verify_ssl=True):
73+
"""
74+
Returns the baseurl from a remote yum .repo file.
75+
76+
:param repo_url: URL to the .repo file
77+
:return: baseurl string
78+
:raises requests.HTTPError: if URL not accessible
79+
:raises ValueError: if baseurl not found
80+
"""
81+
response = requests.get(repo_url, verify=verify_ssl, timeout=10)
82+
response.raise_for_status()
83+
84+
for line in response.text.splitlines():
85+
line = line.strip()
86+
87+
if line.startswith('baseurl='):
88+
return line.split('=', 1)[1].strip()
89+
90+
raise ValueError(f'No baseurl found in {repo_url}')
91+
92+
7293
def get_repomd(repo_url):
7394
"""Fetches content of the repomd file of a repository
7495

tests/foreman/api/test_convert2rhel.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
from robottelo.config import settings
2121
from robottelo.constants import DEFAULT_ARCHITECTURE, REPOS
22+
from robottelo.content_info import get_baseurl_by_repofile
2223
from robottelo.utils.issue_handlers import is_open
2324

2425

@@ -134,7 +135,8 @@ def centos(
134135

135136
centos_host.enable_ipv6_dnf_proxy()
136137
assert centos_host.execute('yum -y update').status == 0
137-
repo_url = settings.repos.convert2rhel.convert_to_rhel_repo.format(major)
138+
repofile_url = settings.repos.convert2rhel.convert_to_rhel_repofile.format(major)
139+
repo_url = get_baseurl_by_repofile(repofile_url)
138140
repo = create_repo(module_target_sat, module_els_sca_manifest_org, repo_url)
139141
cv = update_cv(
140142
module_target_sat, module_promoted_cv, module_lce, enable_rhel_subscriptions + [repo]
@@ -229,7 +231,8 @@ def oracle(
229231
if oracle_host.execute('needs-restarting -r').status == 1:
230232
oracle_host.power_control(state='reboot')
231233

232-
repo_url = settings.repos.convert2rhel.convert_to_rhel_repo.format(major)
234+
repofile_url = settings.repos.convert2rhel.convert_to_rhel_repofile.format(major)
235+
repo_url = get_baseurl_by_repofile(repofile_url)
233236
repo = create_repo(module_target_sat, module_els_sca_manifest_org, repo_url, ssl_cert)
234237
cv = update_cv(
235238
module_target_sat, module_promoted_cv, module_lce, enable_rhel_subscriptions + [repo]

0 commit comments

Comments
 (0)