Skip to content

Fix PRN scenarios tests#20757

Merged
vsedmik merged 1 commit intoSatelliteQE:masterfrom
vsedmik:fix-prn-scenarios
Feb 11, 2026
Merged

Fix PRN scenarios tests#20757
vsedmik merged 1 commit intoSatelliteQE:masterfrom
vsedmik:fix-prn-scenarios

Conversation

@vsedmik
Copy link
Contributor

@vsedmik vsedmik commented Feb 10, 2026

Problem Statement

In CI the PRN new_upgrade-scenarios tests are failing in setup to create a CV since the nailgun fails to create_missing parameters:

tests/new_upgrades/test_pulp.py:37: in pulp_upgrade_setup
    test_data = _setup_prn_content(
pytest_fixtures/component/pulp.py:133: in _setup_prn_content
    cv = sat.api.ContentView(organization=org, repository=repos).create()
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../lib64/python3.12/site-packages/nailgun/entity_mixins.py:1004: in create
    return self.read(attrs=self.create_json(create_missing))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../lib64/python3.12/site-packages/nailgun/entity_mixins.py:974: in create_json
    raise_for_status_add_to_exception(response)
../../lib64/python3.12/site-packages/nailgun/entity_mixins.py:58: in raise_for_status_add_to_exception
    raise e
../../lib64/python3.12/site-packages/nailgun/entity_mixins.py:54: in raise_for_status_add_to_exception
    response.raise_for_status()
../../lib64/python3.12/site-packages/requests/models.py:1026: in raise_for_status
    raise HTTPError(http_error_msg, response=self)
E   requests.exceptions.HTTPError: ('422 Client Error: Unprocessable Content for url: https://satellite.redhat.com/katello/api/v2/content_views', {'displayMessage': "Validation failed: Label can't be blank, Name can't be blank, Name cannot be blank, Label can't be blank", 'errors': {'label': ["can't be blank", "can't be blank"], 'name': ["can't be blank", 'cannot be blank']}})

Solution

It feels like some version mismatch related inconsistency in nailgun (master nailgun runs against 6.18.z instance).
Since there are the "single-branch" discussion in progress, I'm not to dig into this deeper. This PR just provides a quick fix - provides the missing parameters explicitly so we don't depend on the create_missing method.

PRT test Cases example

trigger: test-robottelo
pytest: tests/new_upgrades/test_pulp.py -n 2
env:
    ROBOTTELO_server__xdist_behavior: 'run-on-one'
    ROBOTTELO_upgrade__from_version: '6.18'
    ROBOTTELO_upgrade__to_version: 'stream'

Summary by Sourcery

Ensure PRN upgrade scenario tests can create content views and lifecycle environments by explicitly providing required attributes instead of relying on automatic parameter creation.

Bug Fixes:

  • Provide explicit name when creating content views used in PRN upgrade scenario tests to avoid validation errors in CI.
  • Create lifecycle environments with a valid prior environment and explicit name to fix setup failures in PRN upgrade scenario tests.

@vsedmik vsedmik self-assigned this Feb 10, 2026
@vsedmik vsedmik requested a review from a team as a code owner February 10, 2026 11:16
@vsedmik vsedmik added No-CherryPick PR doesnt need CherryPick to previous branches Stream Introduced in or relating directly to Satellite Stream/Master labels Feb 10, 2026
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 10, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Ensure PRN upgrade scenario tests explicitly create Content Views and Lifecycle Environments with required attributes instead of relying on nailgun’s create_missing behavior, fixing 422 validation errors in CI.

Sequence diagram for updated PRN content setup in pulp upgrade tests

sequenceDiagram
    actor Tester
    participant Pytest as Pytest_runner
    participant Fixture as _setup_prn_content
    participant Sat as SatelliteAPI
    participant CV as ContentView_entity
    participant LEnv as LifecycleEnvironment_entity

    Tester->>Pytest: run tests/new_upgrades/test_pulp.py
    Pytest->>Fixture: call _setup_prn_content(sat, manifest, test_name)

    Fixture->>Sat: api.ContentView(organization=org, repository=repos, name=gen_string_alpha)
    activate Sat
    Sat-->>Fixture: ContentView_entity instance
    deactivate Sat

    Fixture->>CV: create()
    activate CV
    CV-->>Fixture: persisted ContentView (cv)
    deactivate CV

    Fixture->>Sat: api.LifecycleEnvironment()
    activate Sat
    Sat-->>Fixture: LifecycleEnvironment search proxy
    deactivate Sat

    Fixture->>LEnv: search(query={search: name=ENVIRONMENT and organization_id=org_id})
    activate LEnv
    LEnv-->>Fixture: [library_environment]
    deactivate LEnv

    Fixture->>LEnv: library_environment.read()
    activate LEnv
    LEnv-->>Fixture: library_environment_with_id
    deactivate LEnv

    Fixture->>Sat: api.LifecycleEnvironment(organization=org, prior=library_id, name=gen_string_alpha)
    activate Sat
    Sat-->>Fixture: LifecycleEnvironment_entity instance
    deactivate Sat

    Fixture->>LEnv: create()
    activate LEnv
    LEnv-->>Fixture: persisted LifecycleEnvironment (lce)
    deactivate LEnv

    Fixture->>CV: publish()
    CV-->>Fixture: published

    Fixture-->>Pytest: return test_data with cv and lce
    Pytest-->>Tester: test execution continues without 422 errors
Loading

Flow diagram for explicit ContentView and LifecycleEnvironment creation in PRN setup

flowchart TD
    A[Start _setup_prn_content] --> B[Prepare repositories list]
    B --> C[Create ContentView instance with organization, repository, name]
    C --> D[Call ContentView.create]
    D --> E[ContentView cv created]
    E --> F[Create LifecycleEnvironment search proxy]
    F --> G[Search for library environment by name and organization_id]
    G --> H[Read first search result as library]
    H --> I[Create LifecycleEnvironment instance with organization, prior=library.id, name]
    I --> J[Call LifecycleEnvironment.create]
    J --> K[lce created]
    K --> L[Publish ContentView cv]
    L --> M[Read cv version]
    M --> N[Return test data]
    N --> O[End _setup_prn_content]
Loading

File-Level Changes

Change Details Files
Explicitly provide required fields when creating ContentView and LifecycleEnvironment in PRN pulp upgrade setup to avoid nailgun create_missing issues.
  • Create ContentView with an explicit generated name and associated repositories and organization
  • Look up the existing library LifecycleEnvironment for the organization using a search query and read it to obtain its ID
  • Create a new LifecycleEnvironment with an explicit generated name, associated organization, and its prior set to the library environment
pytest_fixtures/component/pulp.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

@vsedmik
Copy link
Contributor Author

vsedmik commented Feb 10, 2026

trigger: test-robottelo
pytest: tests/new_upgrades/test_pulp.py -n 2
env:
    ROBOTTELO_server__xdist_behavior: 'run-on-one'
    ROBOTTELO_upgrade__from_version: '6.18'
    ROBOTTELO_upgrade__to_version: 'stream'

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

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:

  • The library lookup assumes search(...)[0] will always succeed; consider handling the case where no lifecycle environment is returned to avoid an IndexError that would mask the original problem.
  • The name for the content view and lifecycle environment is now always a random gen_string('alpha'); if these names need to be correlated with the test or traceable in logs, consider incorporating test_name or other context into the generated names.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `library` lookup assumes `search(...)[0]` will always succeed; consider handling the case where no lifecycle environment is returned to avoid an IndexError that would mask the original problem.
- The name for the content view and lifecycle environment is now always a random `gen_string('alpha')`; if these names need to be correlated with the test or traceable in logs, consider incorporating `test_name` or other context into the generated names.

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
Collaborator

PRT Result

Build Number: 14227
Build Status: UNSTABLE
PRT Comment: pytest tests/new_upgrades/test_pulp.py -n 2 --external-logging
Test Result : ============ 1 failed, 18 passed, 42 warnings in 2051.51s (0:34:11) ============

@Satellite-QE Satellite-QE added the PRT-Failed Indicates that latest PRT run is failed for the PR label Feb 10, 2026
@vsedmik
Copy link
Contributor Author

vsedmik commented Feb 10, 2026

The only failure is related to this PR #20746
(it will be addressed separately later)

@vsedmik vsedmik added PRT-Passed Indicates that latest PRT run is passed for the PR and removed PRT-Failed Indicates that latest PRT run is failed for the PR labels Feb 10, 2026
@Satellite-QE Satellite-QE removed the PRT-Passed Indicates that latest PRT run is passed for the PR label Feb 11, 2026
@vsedmik
Copy link
Contributor Author

vsedmik commented Feb 11, 2026

rebased ^

@vsedmik vsedmik merged commit dc806c9 into SatelliteQE:master Feb 11, 2026
10 checks passed
@vsedmik vsedmik deleted the fix-prn-scenarios branch February 11, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

No-CherryPick PR doesnt need CherryPick to previous branches Stream Introduced in or relating directly to Satellite Stream/Master

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants