Skip to content

[6.18.z] Use Convert2RHEL repofiles instead of deprecated repos for tests - #20891

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

[6.18.z] Use Convert2RHEL repofiles instead of deprecated repos for tests#20891
Satellite-QE merged 1 commit into
6.18.zfrom
cherry-pick-6.18.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 derive repository base URLs from remote repofile definitions instead of using deprecated repository URLs directly.

New Features:

  • Add a utility to extract a repository baseurl from a remote yum .repo file URL.

Enhancements:

  • Refine repository handling to work with repofile-based configuration for Convert2RHEL-related operations.

Tests:

  • Adjust Convert2RHEL API tests to obtain the repository baseurl from repofile URLs provided in settings instead of direct repository URLs.

)

Signed-off-by: Gaurav Talreja <gtalreja@redhat.com>
(cherry picked from commit 0644d11)
@Satellite-QE Satellite-QE added 6.18.z Introduced in or relating directly to Satellite 6.18 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

Updates Convert2RHEL API tests to stop using hardcoded/deprecated repository URLs and instead derive repository base URLs from remote .repo files, via a new utility helper.

Sequence diagram for deriving baseurl from remote repofile in Convert2RHEL tests

sequenceDiagram
    actor Tester
    participant TestConvert2RHEL as TestConvert2RHELAPI
    participant ContentInfo as content_info
    participant Requests as requests
    participant RepoServer as RemoteRepoServer

    Tester->>TestConvert2RHEL: run_API_test()
    TestConvert2RHEL->>ContentInfo: get_baseurl_by_repofile(repo_url, verify_ssl)
    ContentInfo->>Requests: get(repo_url, verify=verify_ssl, timeout=10)
    Requests->>RepoServer: HTTP GET /path/to/file.repo
    RepoServer-->>Requests: 200 OK (repofile content)
    Requests-->>ContentInfo: Response(text)
    ContentInfo->>ContentInfo: parse lines for baseurl=
    alt baseurl_found
        ContentInfo-->>TestConvert2RHEL: baseurl
        TestConvert2RHEL->>TestConvert2RHEL: build_repo_settings_using_baseurl()
    else baseurl_not_found
        ContentInfo-->>TestConvert2RHEL: raise ValueError
    end
Loading

Class diagram for new repofile baseurl helper and its use in Convert2RHEL tests

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

    class TestConvert2RHELAPI {
        +test_centos_convert2rhel_api()
        +test_oracle_convert2rhel_api()
        +_get_convert2rhel_baseurl(repo_url)
    }

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

    TestConvert2RHELAPI ..> content_info : uses
    content_info ..> requests : uses
Loading

File-Level Changes

Change Details Files
Introduce helper to derive a yum repository baseurl from a remote .repo file URL.
  • Add get_baseurl_by_repofile that fetches a .repo over HTTP(S) with timeout and optional SSL verification.
  • Parse the fetched .repo content line-by-line to find and return the first baseurl= entry, trimming whitespace.
  • Raise HTTPError for inaccessible URLs and ValueError when no baseurl is found, to make failures explicit.
robottelo/content_info.py
Refactor Convert2RHEL CentOS and Oracle API tests to use repofile-based base URLs from settings instead of deprecated repo URLs.
  • Update CentOS test fixture to read convert_to_rhel_repofile from settings, resolve it via get_baseurl_by_repofile, and pass the derived base URL to create_repo.
  • Similarly update Oracle test fixture to derive repo_url from convert_to_rhel_repofile using get_baseurl_by_repofile before creating the repository.
  • Keep the rest of the test flow (host prep, content view update, subscriptions) unchanged to minimize behavioral differences.
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 left some high level feedback:

  • Consider using a parser like configparser to read the .repo file instead of manually scanning for baseurl=, so you can correctly handle multiple sections and future optional keys.
  • If multiple baseurl entries exist in a .repo file, the current implementation will silently return the first one; if that’s not guaranteed to be correct, you may want to scope the search to a specific section or make the behavior explicit.
  • You might want to make the request timeout configurable or at least a module-level constant instead of being hardcoded to 10 seconds in get_baseurl_by_repofile.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider using a parser like `configparser` to read the `.repo` file instead of manually scanning for `baseurl=`, so you can correctly handle multiple sections and future optional keys.
- If multiple `baseurl` entries exist in a `.repo` file, the current implementation will silently return the first one; if that’s not guaranteed to be correct, you may want to scope the search to a specific section or make the behavior explicit.
- You might want to make the request timeout configurable or at least a module-level constant instead of being hardcoded to 10 seconds in `get_baseurl_by_repofile`.

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.

@Satellite-QE

Copy link
Copy Markdown
Collaborator Author

PRT Result

Build Number: 14495
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/api/test_convert2rhel.py --external-logging
Test Result : ================ 4 passed, 259 warnings in 13480.09s (3:44:40) =================

@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 58a6b5f into 6.18.z Feb 26, 2026
18 of 20 checks passed
@Satellite-QE
Satellite-QE deleted the cherry-pick-6.18.z-0644d11f807200c8014d37d1ac667fccd0952529 branch February 26, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.18.z Introduced in or relating directly to Satellite 6.18 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