Skip to content

[6.17.z] Use Convert2RHEL repofiles instead of deprecated repos for tests - #20889

Merged
Satellite-QE merged 1 commit into
6.17.zfrom
cherry-pick-6.17.z-0644d11f807200c8014d37d1ac667fccd0952529
Feb 26, 2026
Merged

[6.17.z] Use Convert2RHEL repofiles instead of deprecated repos for tests#20889
Satellite-QE merged 1 commit into
6.17.zfrom
cherry-pick-6.17.z-0644d11f807200c8014d37d1ac667fccd0952529

Conversation

@Satellite-QE

@Satellite-QE Satellite-QE commented Feb 26, 2026

Copy link
Copy Markdown
Collaborator

Cherrypick of PR: #20869

Problem Statement

Solution

Related Issues

Summary by Sourcery

Update Convert2RHEL API tests to use base URLs derived from remote repofiles instead of hard-coded repository URLs.

Bug Fixes:

  • Resolve usage of deprecated Convert2RHEL repository URLs in tests by dynamically extracting base URLs from current repofile definitions.

Enhancements:

  • Add a helper to fetch and parse remote yum repofiles to obtain the repository baseurl for reuse in tests.

)

Signed-off-by: Gaurav Talreja <gtalreja@redhat.com>
(cherry picked from commit 0644d11)
@Satellite-QE Satellite-QE added 6.17.z Auto_Cherry_Picked Automatically cherrypicked PR using GHA No-CherryPick PR doesnt need CherryPick to previous branches labels Feb 26, 2026
@Satellite-QE

Copy link
Copy Markdown
Collaborator Author
trigger: test-robottelo
pytest: tests/foreman/api/test_convert2rhel.py
env:
     ROBOTTELO_REPOS__CONVERT2RHEL__CONVERT_TO_RHEL_REPOFILE: https://cdn-public.redhat.com/content/public/repofiles/convert2rhel-for-rhel-{}-x86_64.repo

@Satellite-QE Satellite-QE added the AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing label Feb 26, 2026
@sourcery-ai

sourcery-ai Bot commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Update Convert2RHEL API tests to obtain repository base URLs by downloading and parsing remote .repo files, replacing use of deprecated hard-coded repository URLs, and add a shared helper for extracting baseurls from repofiles.

Sequence diagram for get_baseurl_by_repofile resolving baseurl

sequenceDiagram
    participant TestCase
    participant ContentInfo
    participant Requests
    participant RepoServer

    TestCase->>ContentInfo: get_baseurl_by_repofile(repo_url, verify_ssl)
    ContentInfo->>Requests: get(repo_url, verify_ssl, timeout=10)
    Requests->>RepoServer: HTTP GET repo_url
    RepoServer-->>Requests: 200 OK, .repo content
    Requests-->>ContentInfo: response(text)
    ContentInfo->>ContentInfo: parse lines, find baseurl=
    ContentInfo-->>TestCase: baseurl string
Loading

Class diagram for updated content_info utilities

classDiagram
    class ContentInfo {
        +get_repo_files_by_url(url, extension)
        +get_repo_files_urls_by_url(url, extension)
        +get_repomd(repo_url)
        +get_baseurl_by_repofile(repo_url, verify_ssl)
    }

    class Requests {
        +get(url, verify, timeout)
    }

    ContentInfo ..> Requests : uses
Loading

File-Level Changes

Change Details Files
Introduce helper to derive a repository baseurl from a remote yum .repo file.
  • Add get_baseurl_by_repofile that downloads a .repo file over HTTP(S) with timeout and optional SSL verification.
  • Parse the .repo file contents line-by-line to find and return the first baseurl= entry.
  • Raise HTTPError on network/HTTP failures and ValueError if no baseurl is found.
robottelo/content_info.py
Refactor Convert2RHEL CentOS and Oracle API tests to use repofile-based base URLs from settings instead of deprecated repo URLs.
  • Replace usage of settings.repos.convert2rhel.convert_to_rhel_repo with convert_to_rhel_repofile for CentOS and Oracle tests.
  • Call get_baseurl_by_repofile to derive repo_url from the repofile URL before creating repositories in tests.
  • Keep existing test flow (host prep, repo creation, content view update) unchanged aside from how repo_url is obtained.
tests/foreman/api/test_convert2rhel.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The new get_baseurl_by_repofile parser is quite strict (line.startswith('baseurl=')), so it will miss common variations like baseurl = ... or uppercase keys; consider using configparser or a more flexible parse (e.g., splitting on = after checking line.lower().startswith('baseurl')).
  • Instead of hard-coding the timeout=10 in requests.get, consider reusing any existing HTTP helper or making the timeout configurable/centralized to keep network behavior consistent across the module.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `get_baseurl_by_repofile` parser is quite strict (`line.startswith('baseurl=')`), so it will miss common variations like `baseurl = ...` or uppercase keys; consider using `configparser` or a more flexible parse (e.g., splitting on `=` after checking `line.lower().startswith('baseurl')`).
- Instead of hard-coding the `timeout=10` in `requests.get`, consider reusing any existing HTTP helper or making the timeout configurable/centralized to keep network behavior consistent across the module.

## Individual Comments

### Comment 1
<location path="robottelo/content_info.py" line_range="81-90" />
<code_context>
+    for line in response.text.splitlines():
+        line = line.strip()
+
+        if line.startswith('baseurl='):
+            return line.split('=', 1)[1].strip()
+
+    raise ValueError(f'No baseurl found in {repo_url}')
</code_context>
<issue_to_address>
**suggestion:** Handle inline comments and empty values when extracting the baseurl

This will return anything after `baseurl=`, including inline comments (e.g. `baseurl=http://foo # comment`) or an empty value. Consider stripping inline comments first (e.g. split on `#`), ensuring the value is non-empty and URL-like, and otherwise continuing the scan or raising a clearer error to avoid silently returning malformed values.

```suggestion
    response = requests.get(repo_url, verify=verify_ssl, timeout=10)
    response.raise_for_status()

    for line in response.text.splitlines():
        line = line.strip()

        if line.startswith('baseurl='):
            # Extract raw value after "baseurl="
            raw_value = line.split('=', 1)[1].strip()
            if not raw_value:
                # Empty baseurl, continue scanning other lines
                continue

            # Strip inline comments: everything after '#' is considered a comment
            value = raw_value.split('#', 1)[0].strip()
            if not value:
                # Only comment or whitespace after baseurl=, keep scanning
                continue

            # Basic sanity check to avoid obviously malformed values
            # (most yum/dnf baseurls are URLs or file paths)
            if "://" not in value and not value.startswith("file:"):
                # Not URL-like, keep scanning for a better candidate
                continue

            return value

    raise ValueError(f'No valid baseurl found in repository metadata from {repo_url}')
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread robottelo/content_info.py
Comment on lines +81 to +90
response = requests.get(repo_url, verify=verify_ssl, timeout=10)
response.raise_for_status()

for line in response.text.splitlines():
line = line.strip()

if line.startswith('baseurl='):
return line.split('=', 1)[1].strip()

raise ValueError(f'No baseurl found in {repo_url}')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Handle inline comments and empty values when extracting the baseurl

This will return anything after baseurl=, including inline comments (e.g. baseurl=http://foo # comment) or an empty value. Consider stripping inline comments first (e.g. split on #), ensuring the value is non-empty and URL-like, and otherwise continuing the scan or raising a clearer error to avoid silently returning malformed values.

Suggested change
response = requests.get(repo_url, verify=verify_ssl, timeout=10)
response.raise_for_status()
for line in response.text.splitlines():
line = line.strip()
if line.startswith('baseurl='):
return line.split('=', 1)[1].strip()
raise ValueError(f'No baseurl found in {repo_url}')
response = requests.get(repo_url, verify=verify_ssl, timeout=10)
response.raise_for_status()
for line in response.text.splitlines():
line = line.strip()
if line.startswith('baseurl='):
# Extract raw value after "baseurl="
raw_value = line.split('=', 1)[1].strip()
if not raw_value:
# Empty baseurl, continue scanning other lines
continue
# Strip inline comments: everything after '#' is considered a comment
value = raw_value.split('#', 1)[0].strip()
if not value:
# Only comment or whitespace after baseurl=, keep scanning
continue
# Basic sanity check to avoid obviously malformed values
# (most yum/dnf baseurls are URLs or file paths)
if "://" not in value and not value.startswith("file:"):
# Not URL-like, keep scanning for a better candidate
continue
return value
raise ValueError(f'No valid baseurl found in repository metadata from {repo_url}')

@Satellite-QE

Copy link
Copy Markdown
Collaborator Author

PRT Result

Build Number: 14497
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/api/test_convert2rhel.py --external-logging
Test Result : ================ 4 passed, 252 warnings in 13217.83s (3:40:17) =================

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label Feb 26, 2026
@Satellite-QE
Satellite-QE merged commit 24cff6a into 6.17.z Feb 26, 2026
18 of 20 checks passed
@Satellite-QE
Satellite-QE deleted the cherry-pick-6.17.z-0644d11f807200c8014d37d1ac667fccd0952529 branch February 26, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.17.z Auto_Cherry_Picked Automatically cherrypicked PR using GHA AutoMerge_Cherry_Picked The cherrypicked PRs of master PR would be automerged if all checks passing No-CherryPick PR doesnt need CherryPick to previous branches PRT-Passed Indicates that latest PRT run is passed for the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants