Skip to content

adjusted asserts for mcp user tests - #20852

Merged
lpramuk merged 1 commit into
SatelliteQE:masterfrom
pondrejk:mcp-first
Feb 25, 2026
Merged

adjusted asserts for mcp user tests#20852
lpramuk merged 1 commit into
SatelliteQE:masterfrom
pondrejk:mcp-first

Conversation

@pondrejk

@pondrejk pondrejk commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

Problem Statement

targeting an issue that isn't reproducible outside of our regular automation runs, therefore a bit mysterious. My hypothesis is that on the first run attempt the mcp client queries the mcp server before the connection with satellite is established using custom credentials.

Solution

Allow for a second try if the aforementioned issue happens

Related Issues

@pondrejk pondrejk self-assigned this Feb 24, 2026
@pondrejk
pondrejk requested a review from a team as a code owner February 24, 2026 11:13
@pondrejk pondrejk added Stream Introduced in or relating directly to Satellite Stream/Master 6.18.z Introduced in or relating directly to Satellite 6.18 6.19.z labels Feb 24, 2026
@sourcery-ai

sourcery-ai Bot commented Feb 24, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR updates the MCP user permission system tests to be more resilient to transient connection issues and to assert the exact error payload for denied resource access.

File-Level Changes

Change Details Files
Make the positive MCP user view permissions test resilient to a transient 'Max retries exceeded' error and tighten the assertion on the denied-resource response.
  • After the initial MCP client call to the Foreman API for the allowed resource, detect a specific transient failure pattern ('error' in result.data with 'Max retries exceeded') and immediately retry the same call once.
  • Add a strict assertion that the denied resource response includes an 'Access denied' error message at result.data['response']['error']['message'], in addition to the existing message substring assertion.
tests/foreman/sys/test_mcp.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

@pondrejk

Copy link
Copy Markdown
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/sys/test_mcp.py::test_positive_mcp_user_view_permissions

@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:

  • The retry logic based on checking for 'Max retries exceeded' in result.data['error'] is brittle; consider encapsulating this in a small helper or using a more structured condition (e.g., error code/type) so other error messages don’t trigger an opaque second call.
  • The new assertion on result.data['response']['error']['message'] assumes a specific nested response structure; consider using .get or adding an explicit assertion that response and error keys exist to avoid confusing KeyError/TypeError failures.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The retry logic based on checking for `'Max retries exceeded'` in `result.data['error']` is brittle; consider encapsulating this in a small helper or using a more structured condition (e.g., error code/type) so other error messages don’t trigger an opaque second call.
- The new assertion on `result.data['response']['error']['message']` assumes a specific nested response structure; consider using `.get` or adding an explicit assertion that `response` and `error` keys exist to avoid confusing `KeyError`/`TypeError` failures.

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.

@pondrejk pondrejk added the CherryPick PR needs CherryPick to previous branches label Feb 24, 2026
@Satellite-QE

Copy link
Copy Markdown
Collaborator

PRT Result

Build Number: 14424
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/sys/test_mcp.py::test_positive_mcp_user_view_permissions --external-logging
Test Result : ================== 4 passed, 39 warnings in 851.92s (0:14:11) ==================

@Satellite-QE Satellite-QE added the PRT-Passed Indicates that latest PRT run is passed for the PR label Feb 24, 2026
@lpramuk
lpramuk merged commit 7777535 into SatelliteQE:master Feb 25, 2026
10 of 14 checks passed
github-actions Bot pushed a commit that referenced this pull request Feb 25, 2026
github-actions Bot pushed a commit that referenced this pull request Feb 25, 2026
lpramuk pushed a commit that referenced this pull request Feb 25, 2026
adjusted asserts for mcp user tests (#20852)

(cherry picked from commit 7777535)

Co-authored-by: Peter Ondrejka <pondrejk@users.noreply.github.com>
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 6.19.z CherryPick PR needs CherryPick to previous branches PRT-Passed Indicates that latest PRT run is passed for the PR Stream Introduced in or relating directly to Satellite Stream/Master

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants