Skip to content

[IUO] Fix runbook URL test failures#4741

Open
OhadRevah wants to merge 1 commit intoRedHatQE:mainfrom
OhadRevah:fixRunbookFailure
Open

[IUO] Fix runbook URL test failures#4741
OhadRevah wants to merge 1 commit intoRedHatQE:mainfrom
OhadRevah:fixRunbookFailure

Conversation

@OhadRevah
Copy link
Copy Markdown
Contributor

@OhadRevah OhadRevah commented May 5, 2026

Short description:

Replace status code check with data validation in available_runbook_urls fixture to handle non-200 responses that still contain valid data. Add AAQ prometheus rule support to test_no_new_prometheus_rules so clusters with AAQ enabled don't fail the assertion.

Signed-off-by: Ohad Revah orevah@redhat.com
assisted by: claude code claude-opus-4-6

More details:
What this PR does / why we need it:
Which issue(s) this PR fixes:
Special notes for reviewer:
jira-ticket:

Summary by CodeRabbit

  • Tests

    • Added a session-scoped fixture to detect whether Application Aware Quota (AAQ) is enabled.
    • Updated tests to conditionally include the AAQ Prometheus rule when AAQ is enabled.
  • Chores

    • Improved HTTP/JSON robustness in test utilities to skip/continue on malformed or non-JSON responses.
    • Added a shared constant for the AAQ Prometheus rule name.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

📝 Walkthrough

Walkthrough

Adds a session-scoped pytest fixture aaq_enabled that reads enableApplicationAwareQuota from the HCO CR spec (defaults to False), introduces AAQ_PROMETHEUS_RULE constant, updates a Prometheus-rule test to conditionally expect the AAQ rule when enabled, and tightens JSON parsing/return logic in an observability fixture.

Changes

AAQ Prometheus Rule Testing

Layer / File(s) Summary
Constant Definition
utilities/constants.py
Adds AAQ_PROMETHEUS_RULE = "prometheus-aaq-rules" for referencing the AAQ PrometheusRule.
Session Fixture Setup
tests/conftest.py
Adds session-scoped pytest fixture aaq_enabled(hyperconverged_resource_scope_session) that returns False if the session fixture is falsy, otherwise returns hyperconverged_resource_scope_session.instance.spec.get("enableApplicationAwareQuota", False).
Observability Fixture Logic
tests/observability/runbook_url/conftest.py
available_runbook_urls() now verifies sample is truthy, attempts sample.json() inside try/except ValueError, logs status and Content-Type on JSON decode errors and continues; returns a non-empty set of entry["html_url"] only when present.
Prometheus Rule Test Wiring
tests/observability/runbook_url/test_runbook_url.py
test_no_new_prometheus_rules(...) adds the aaq_enabled fixture and appends AAQ_PROMETHEUS_RULE to expected rule names when aaq_enabled is true before asserting equality with cnv_prometheus_rules_names.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes a short description of key changes but lacks required sections: 'More details', 'What this PR does / why we need it', 'Which issue(s) this PR fixes', 'Special notes for reviewer', and 'jira-ticket' are incomplete or empty. Expand description with: context for why status code checks were insufficient, why AAQ support is needed, which issue(s) are fixed, and relevant reviewer notes or Jira ticket reference.
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title '[IUO] Fix runbook URL test failures' is directly related to the main changes: fixing the available_runbook_urls fixture and updating test assertions for AAQ-enabled clusters.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-virtualization-qe-bot-2
Copy link
Copy Markdown
Contributor

Report bugs in Issues

Welcome! 🎉

This pull request will be automatically processed with the following features:

🔄 Automatic Actions

  • Reviewer Assignment: Reviewers are automatically assigned based on the OWNERS file in the repository root
  • Size Labeling: PR size labels (XS, S, M, L, XL, XXL) are automatically applied based on changes
  • Issue Creation: A tracking issue is created for this PR and will be closed when the PR is merged or closed
  • Branch Labeling: Branch-specific labels are applied to track the target branch
  • Auto-verification: Auto-verified users have their PRs automatically marked as verified
  • Labels: Enabled categories: branch, can-be-merged, cherry-pick, has-conflicts, hold, needs-rebase, size, verified, wip

📋 Available Commands

PR Status Management

  • /wip - Mark PR as work in progress (adds WIP: prefix to title)
  • /wip cancel - Remove work in progress status
  • /hold - Block PR merging (approvers only)
  • /hold cancel - Unblock PR merging
  • /verified - Mark PR as verified
  • /verified cancel - Remove verification status
  • /reprocess - Trigger complete PR workflow reprocessing (useful if webhook failed or configuration changed)
  • /regenerate-welcome - Regenerate this welcome message

Review & Approval

  • /lgtm - Approve changes (looks good to me)
  • /approve - Approve PR (approvers only)
  • /assign-reviewers - Assign reviewers based on OWNERS file
  • /assign-reviewer @username - Assign specific reviewer
  • /check-can-merge - Check if PR meets merge requirements

Testing & Validation

  • /retest tox - Run Python test suite with tox
  • /retest build-container - Rebuild and test container image
  • /retest verify-bugs-are-open - verify-bugs-are-open
  • /retest all - Run all available tests

Container Operations

  • /build-and-push-container - Build and push container image (tagged with PR number)
    • Supports additional build arguments: /build-and-push-container --build-arg KEY=value

Cherry-pick Operations

  • /cherry-pick <branch> - Schedule cherry-pick to target branch when PR is merged
    • Multiple branches: /cherry-pick branch1 branch2 branch3

Label Management

  • /<label-name> - Add a label to the PR
  • /<label-name> cancel - Remove a label from the PR

✅ Merge Requirements

This PR will be automatically approved when the following conditions are met:

  1. Approval: /approve from at least one approver
  2. LGTM Count: Minimum 2 /lgtm from reviewers
  3. Status Checks: All required status checks must pass
  4. No Blockers: No wip, hold, has-conflicts labels and PR must be mergeable (no conflicts)
  5. Verified: PR must be marked as verified

📊 Review Process

Approvers and Reviewers

Approvers:

  • dshchedr
  • myakove
  • rnetser
  • vsibirsk

Reviewers:

  • OhadRevah
  • RoniKishner
  • albarker-rh
  • dshchedr
  • geetikakay
  • hmeir
  • rlobillo
  • rnetser
  • vsibirsk
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve
AI Features
  • Cherry-Pick Conflict Resolution: Enabled (claude/claude-opus-4-6[1m])

💡 Tips

  • WIP Status: Use /wip when your PR is not ready for review
  • Verification: The verified label is removed on new commits unless the push is detected as a clean rebase
  • Cherry-picking: Cherry-pick labels are processed when the PR is merged
  • Container Builds: Container images are automatically tagged with the PR number
  • Permission Levels: Some commands require approver permissions
  • Auto-verified Users: Certain users have automatic verification and merge privileges

For more information, please refer to the project documentation or contact the maintainers.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.67%. Comparing base (b4ad2e0) to head (2455627).
⚠️ Report is 128 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4741      +/-   ##
==========================================
+ Coverage   98.63%   98.67%   +0.03%     
==========================================
  Files          25       25              
  Lines        2420     2484      +64     
==========================================
+ Hits         2387     2451      +64     
  Misses         33       33              
Flag Coverage Δ
utilities 98.67% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/observability/runbook_url/conftest.py`:
- Around line 60-61: The call to sample.json() can raise JSONDecodeError and
escape the sampler retry loop; wrap the sample.json() extraction into a
try/except that catches requests.exceptions.JSONDecodeError (or ValueError for
older requests) around the line creating runbook_urls (the {entry["html_url"]
for entry in sample.json()} expression), log or ignore the decode error and
continue the loop so the TimeoutExpiredError retry logic (the existing except
handling) can retry, and only return runbook_urls when JSON parsing succeeds.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c8611c94-c7b5-4fcf-ac3b-81777cf4b293

📥 Commits

Reviewing files that changed from the base of the PR and between 968a40a and f413348.

📒 Files selected for processing (4)
  • tests/conftest.py
  • tests/observability/runbook_url/conftest.py
  • tests/observability/runbook_url/test_runbook_url.py
  • utilities/constants.py

Comment thread tests/observability/runbook_url/conftest.py Outdated
@OhadRevah
Copy link
Copy Markdown
Contributor Author

/build-and-push-container

@openshift-virtualization-qe-bot-2
Copy link
Copy Markdown
Contributor

Clean rebase detected — no code changes compared to previous head (bdbe8df).

@openshift-virtualization-qe-bot-2
Copy link
Copy Markdown
Contributor

New container for quay.io/openshift-cnv/openshift-virtualization-tests:pr-4741 published

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/conftest.py`:
- Around line 1340-1342: The fixture aaq_enabled currently assumes
hyperconverged_resource_scope_session is always present and will raise
AttributeError when that fixture is None; update the aaq_enabled fixture
signature to accept installing_cnv (like other fixtures) and guard against a
None hyperconverged_resource_scope_session by returning False (or a safe
default) when hyperconverged_resource_scope_session is None, otherwise return
hyperconverged_resource_scope_session.instance.spec.get("enableApplicationAwareQuota",
False); reference the aaq_enabled fixture and
hyperconverged_resource_scope_session to locate and change the code.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 30c834f2-1297-4685-8071-079031dec556

📥 Commits

Reviewing files that changed from the base of the PR and between f413348 and b992e20.

📒 Files selected for processing (4)
  • tests/conftest.py
  • tests/observability/runbook_url/conftest.py
  • tests/observability/runbook_url/test_runbook_url.py
  • utilities/constants.py

Comment thread tests/conftest.py
@OhadRevah OhadRevah changed the title [IUO] Fix runbook URL test failures: resilient GitHub fetch and AAQ support [IUO] Fix runbook URL test failures May 5, 2026
…upport

Replace status code check with data validation in available_runbook_urls
fixture to handle non-200 responses that still contain valid data.
Add AAQ prometheus rule support to test_no_new_prometheus_rules so clusters
with AAQ enabled don't fail the assertion.

Signed-off-by: Ohad <orevah@redhat.com>
assisted by: claude code claude-opus-4-6
@OhadRevah OhadRevah force-pushed the fixRunbookFailure branch from b992e20 to 2455627 Compare May 5, 2026 12:26
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/observability/runbook_url/conftest.py`:
- Around line 60-70: The code builds runbook_urls using a set comprehension from
sample.json() which can raise TypeError/KeyError when the JSON is not the
expected list-of-dicts or when entries lack "html_url"; modify the block around
sample.json() in conftest.py so you first parse the payload into a variable
(resp = sample.json()), validate that resp is an iterable/list, then iterate
entries and only add entry["html_url"] when entry is a dict and "html_url" in
entry; catch and handle TypeError/KeyError (and ValueError already handled) by
logging the failure with runbooks_api_url, sample.status_code and content-type
via LOGGER and continue the sampler loop so retries are preserved (referencing
sample, runbook_urls, runbooks_api_url, LOGGER).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6190730e-69a9-40ec-8826-0fb68e4c3a75

📥 Commits

Reviewing files that changed from the base of the PR and between b992e20 and 2455627.

📒 Files selected for processing (4)
  • tests/conftest.py
  • tests/observability/runbook_url/conftest.py
  • tests/observability/runbook_url/test_runbook_url.py
  • utilities/constants.py

Comment on lines +60 to +70
if sample:
try:
runbook_urls = {entry["html_url"] for entry in sample.json()}
except ValueError:
LOGGER.error(
f"Failed to decode JSON from '{runbooks_api_url}', "
f"status: {sample.status_code}, content-type: {sample.headers.get('Content-Type')}"
)
continue
if runbook_urls:
return runbook_urls
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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

HIGH: Validate JSON payload shape before extracting html_url.

At Line 62, valid-but-unexpected JSON (e.g., dict payload or entries without html_url) can raise TypeError/KeyError, escape the sampler loop, and bypass retry behavior.

Proposed fix
             if sample:
                 try:
-                    runbook_urls = {entry["html_url"] for entry in sample.json()}
+                    payload = sample.json()
                 except ValueError:
                     LOGGER.error(
                         f"Failed to decode JSON from '{runbooks_api_url}', "
                         f"status: {sample.status_code}, content-type: {sample.headers.get('Content-Type')}"
                     )
                     continue
+                if not isinstance(payload, list):
+                    LOGGER.error(
+                        f"Unexpected JSON payload type from '{runbooks_api_url}': "
+                        f"{type(payload).__name__}, status: {sample.status_code}"
+                    )
+                    continue
+                runbook_urls = {
+                    entry.get("html_url")
+                    for entry in payload
+                    if isinstance(entry, dict) and entry.get("html_url")
+                }
                 if runbook_urls:
                     return runbook_urls
🧰 Tools
🪛 Ruff (0.15.12)

[warning] 64-67: Use logging.exception instead of logging.error

Replace with exception

(TRY400)


[warning] 65-66: Logging statement uses f-string

(G004)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/observability/runbook_url/conftest.py` around lines 60 - 70, The code
builds runbook_urls using a set comprehension from sample.json() which can raise
TypeError/KeyError when the JSON is not the expected list-of-dicts or when
entries lack "html_url"; modify the block around sample.json() in conftest.py so
you first parse the payload into a variable (resp = sample.json()), validate
that resp is an iterable/list, then iterate entries and only add
entry["html_url"] when entry is a dict and "html_url" in entry; catch and handle
TypeError/KeyError (and ValueError already handled) by logging the failure with
runbooks_api_url, sample.status_code and content-type via LOGGER and continue
the sampler loop so retries are preserved (referencing sample, runbook_urls,
runbooks_api_url, LOGGER).

@openshift-virtualization-qe-bot-3
Copy link
Copy Markdown
Contributor

/retest all

Auto-triggered: Files in this PR were modified by merged PR #4658.

Overlapping files

utilities/constants.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants