Skip to content

Automation test for kubevirt_vmi_sync_total metric#5246

Merged
vsibirsk merged 4 commits into
RedHatQE:mainfrom
OhadRevah:implement-vmi-sync-total-tests
Jun 30, 2026
Merged

Automation test for kubevirt_vmi_sync_total metric#5246
vsibirsk merged 4 commits into
RedHatQE:mainfrom
OhadRevah:implement-vmi-sync-total-tests

Conversation

@OhadRevah

@OhadRevah OhadRevah commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
What this PR does / why we need it:

Verify that kubevirt_vmi_sync_total metric is reported by both virt-controller and virt-handler, that after live migration the virt-controller value increases and the virt-handler pod changes, and that the metric is cleared after VM deletion.

Assisted-by: claude code claude-opus-4-6

Which issue(s) this PR fixes:
Special notes for reviewer:
jira-ticket:

https://redhat.atlassian.net/browse/CNV-89660

Summary by CodeRabbit

  • Tests
    • Added a dedicated kubevirt_vmi_sync_total Prometheus metric constant to improve VM migration observability coverage.
    • Introduced fixtures to capture VM-scoped initial metric values and to delete the migration-test VM to enable post-deletion assertions.
    • Refactored kubevirt_vmi_sync_total migration tests to rely on shared polling-based helpers that validate: the metric is reported and positive, values increase after live migration across controller/handler components, and the metric is cleared after VM deletion (including re-enabling the previously skipped check).

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@OhadRevah, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 13 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 730782ba-f809-455f-92f4-d0a7454fa89f

📥 Commits

Reviewing files that changed from the base of the PR and between 41f5554 and f8e30e8.

📒 Files selected for processing (1)
  • tests/observability/metrics/conftest.py
📝 Walkthrough

Walkthrough

Adds a KUBEVIRT_VMI_SYNC_TOTAL Prometheus metric constant, shared polling helpers, migration/deletion fixtures, and updates TestVmiSyncTotal to use them.

Changes

VMI Sync Total Metric Validation

Layer / File(s) Summary
Metric constant and validation helpers
tests/observability/metrics/constants.py, tests/observability/metrics/utils.py
Adds the KUBEVIRT_VMI_SYNC_TOTAL metric template, imports VIRT_CONTROLLER and VIRT_HANDLER, and defines Prometheus polling helpers for positive reporting, post-migration increase checks, and metric clearing after deletion.
conftest fixtures for initial values and VM deletion
tests/observability/metrics/conftest.py
Adds the metric constant and helper import to the fixture module, then defines fixtures for collecting initial sync-total values and deleting the migration test VM.
TestVmiSyncTotal test signature and assertion updates
tests/observability/metrics/test_vms_metrics.py
Updates the TestVmiSyncTotal imports, re-enables the base sync-total test, expands the migration/deletion test parameters, and replaces inline assertions with calls to the shared validation helpers.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

new-tests

Suggested reviewers

  • dshchedr
  • albarker-rh
  • vsibirsk
  • RoniKishner
  • rnetser
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, under 120 characters, and clearly describes the new automation test for kubevirt_vmi_sync_total.
Description check ✅ Passed The description matches the required template and includes the PR purpose and Jira ticket, though the issue and reviewer-notes sections are empty.
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.
Stp Link Required ✅ Passed PASS: Added tests live in TestVmiSyncTotal, and the class docstring already includes a Jira link with # ; no new test files were added.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Linked repositories: Your configuration references 1 linked repositories, but your current plan allows 0. Analyzed ``, skipped RedHatQE/openshift-virtualization-tests-design-docs.


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.

@openshift-virtualization-qe-bot-4

Copy link
Copy Markdown

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
  • /security-override - Set security check runs to pass (maintainers only)
  • /security-override cancel - Re-run security checks

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
  • /cherry-pick-retry <branch> - Retry a failed cherry-pick (merged PRs only)

Branch Management

  • /rebase - Rebase this PR branch onto its base branch

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
  • hmeir
  • rlobillo
  • rnetser
  • vsibirsk
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve
AI Features
  • Cherry-Pick Conflict Resolution: Enabled (claude/claude-opus-4-6[1m])
Security Checks
  • Suspicious Path Detection: Monitors paths: .claude/, .vscode/, .cursor/, .devcontainer/, .pi/, .github/workflows/, .github/actions/
  • Committer Identity Check: Verifies last committer matches PR author
  • Mandatory: Security checks block merge (use /security-override to bypass — maintainers only)

💡 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.

@openshift-virtualization-qe-bot

Copy link
Copy Markdown

/build-and-push-container

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 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/metrics/conftest.py`:
- Around line 668-671: The initial_vmi_sync_total_values function captures a
single snapshot via prometheus.query_sampler without waiting for all Prometheus
series to be exposed and stable, resulting in an incomplete baseline that causes
downstream migration validations to be flaky. Modify the function to poll or
wait for stable metrics before returning the baseline, ensuring that all
expected series for the given VM are present and their values have stabilized
before capturing the snapshot. This ensures reliable migration comparison.

In `@tests/observability/metrics/utils.py`:
- Around line 831-839: The pod-level validation using
`all(float(result["value"][1]) > 0 for result in sample)` is too strict and
causes false failures when replica churn or standby pods exist. Instead of
validating every pod in the sample, change the logic to only check that the
specific component pods (those starting with VIRT_CONTROLLER or VIRT_HANDLER)
have positive metric values. Modify the all_positive check to filter the sample
results to only those pods that match the required components before checking if
their values are positive, ensuring the test validates component-level behavior
rather than all pod series. This pattern appears in multiple locations in the
codebase and should be fixed consistently wherever the same validation pattern
exists.
🪄 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: 6f34ace6-4f6e-459f-8053-c2a8ab35c144

📥 Commits

Reviewing files that changed from the base of the PR and between 6730968 and 86ce2ec.

📒 Files selected for processing (4)
  • tests/observability/metrics/conftest.py
  • tests/observability/metrics/constants.py
  • tests/observability/metrics/test_vms_metrics.py
  • tests/observability/metrics/utils.py

Comment thread tests/observability/metrics/conftest.py
Comment thread tests/observability/metrics/utils.py Outdated
@OhadRevah

Copy link
Copy Markdown
Contributor Author

/retest build-container

@openshift-virtualization-qe-bot

Copy link
Copy Markdown

Verification failed for PR #5246.
The pipeline did not reach the test execution stage.

Execution details
pytest tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal -s -o log_cli=true -m tier2 --jira

@OhadRevah OhadRevah changed the title Automation test for kubevirt_vmi_sync_totric metric Automation test for kubevirt_vmi_sync_total metric Jun 16, 2026
@openshift-virtualization-qe-bot

Copy link
Copy Markdown

/build-and-push-container

@openshift-virtualization-qe-bot-6

Copy link
Copy Markdown

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

@openshift-virtualization-qe-bot

Copy link
Copy Markdown

/verified

All tests passed for PR #5246.
Job: openshift-virtualization-tests-runner #5689

Execution details
pytest tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal -s -o log_cli=true -m tier2 --jira
Image: openshift-virtualization-tests:pr-5246

Comment thread tests/observability/metrics/utils.py
Comment thread tests/observability/metrics/utils.py
Comment thread tests/observability/metrics/utils.py
Signed-off-by: Ohad <orevah@redhat.com>

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

♻️ Duplicate comments (1)
tests/observability/metrics/constants.py (1)

48-48: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

HIGH: Scope this metric query by namespace too.

Both the PR objective and the test docstrings describe a namespace+name lookup, but this template filters only by name. Because vm_for_migration_metrics_test uses a fixed VM name, another namespace with the same VM name can contribute extra series and break the “2 entries”, migration-baseline, and clear-after-delete assertions against the wrong VM.

Suggested direction
-KUBEVIRT_VMI_SYNC_TOTAL = "kubevirt_vmi_sync_total{{name='{vm_name}'}}"
+KUBEVIRT_VMI_SYNC_TOTAL = "kubevirt_vmi_sync_total{{namespace='{namespace}',name='{vm_name}'}}"

Then update callers to format both namespace and vm_name.

🤖 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/metrics/constants.py` at line 48, The
KUBEVIRT_VMI_SYNC_TOTAL metric template currently filters only by vm_name, which
can pick up series from other namespaces with the same VM name. Update the
constant in constants.py and all callers that use it to include namespace plus
name formatting, using the relevant namespace variable alongside vm_name in the
metric query. This should be applied where the metric is consumed in the
migration metrics tests so the assertions target the correct VM series.
🤖 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/metrics/conftest.py`:
- Around line 681-683: The deleted_vmi_sync_total_vm fixture currently only
performs the delete side effect and returns None, so update it to yield or
return vm_for_migration_metrics_test after calling delete(wait=True). Keep the
fixture behavior in place but make the resource available to callers, matching
the existing fixture pattern used in tests/observability/metrics/conftest.py.

---

Duplicate comments:
In `@tests/observability/metrics/constants.py`:
- Line 48: The KUBEVIRT_VMI_SYNC_TOTAL metric template currently filters only by
vm_name, which can pick up series from other namespaces with the same VM name.
Update the constant in constants.py and all callers that use it to include
namespace plus name formatting, using the relevant namespace variable alongside
vm_name in the metric query. This should be applied where the metric is consumed
in the migration metrics tests so the assertions target the correct VM series.
🪄 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: 9ccf0f88-3a88-4195-bcb0-26e094dca534

📥 Commits

Reviewing files that changed from the base of the PR and between 8035d25 and 53dc6cc.

📒 Files selected for processing (4)
  • tests/observability/metrics/conftest.py
  • tests/observability/metrics/constants.py
  • tests/observability/metrics/test_vms_metrics.py
  • tests/observability/metrics/utils.py

Comment thread tests/observability/metrics/conftest.py
@openshift-virtualization-qe-bot-3

Copy link
Copy Markdown
Contributor

/retest all

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

Overlapping files

tests/observability/metrics/conftest.py
tests/observability/metrics/test_vms_metrics.py
tests/observability/metrics/utils.py

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 29, 2026
@openshift-virtualization-qe-bot

Copy link
Copy Markdown

/build-and-push-container

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/observability/metrics/test_vms_metrics.py (1)

597-612: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

LOW: Update the Expected blocks to match the shared helper checks.

The migration test no longer asserts that both current series are greater than the initial sample; it checks that the virt-controller value increased and that a new virt-handler pod reports a positive value. The deletion test also accepts either no samples or zero-valued samples. Keeping the old wording makes failures harder to interpret.

Suggested fix
         Expected:
-            - Metric values from both virt-controller and virt-handler
-              are greater than the values recorded before migration
+            - The virt-controller value is greater than the value recorded before migration
+            - A new virt-handler pod reports a value greater than 0
@@
         Expected:
-            - Metric value is None
+            - The query returns no samples, or all returned values are 0

Also applies to: 623-636

🤖 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/metrics/test_vms_metrics.py` around lines 597 - 612, The
Expected blocks in the migration and deletion metric tests are out of sync with
the shared helper behavior in the vms metrics test suite. Update the
docstrings/comments in the relevant test cases to reflect that the migration
check now verifies an increased virt-controller value plus a positive
virt-handler series, and that the deletion check accepts either no samples or
zero-valued samples. Use the existing test helper context in the VMS metrics
tests to align the wording with the actual assertions so failures are described
accurately.
🤖 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/metrics/conftest.py`:
- Around line 710-712: The VM fixture starts the guest and yields it
immediately, which can race guest initialization in downstream
NAD-swap/migration tests. In the fedora_vm fixture, after vm.start(wait=True) in
the context managed block, wait for readiness with vm.wait_for_agent_connected()
before yielding the VM so callers only receive a fully connected guest.

---

Outside diff comments:
In `@tests/observability/metrics/test_vms_metrics.py`:
- Around line 597-612: The Expected blocks in the migration and deletion metric
tests are out of sync with the shared helper behavior in the vms metrics test
suite. Update the docstrings/comments in the relevant test cases to reflect that
the migration check now verifies an increased virt-controller value plus a
positive virt-handler series, and that the deletion check accepts either no
samples or zero-valued samples. Use the existing test helper context in the VMS
metrics tests to align the wording with the actual assertions so failures are
described accurately.
🪄 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: 2706b827-10f8-47a3-98c3-da65cc7a4eab

📥 Commits

Reviewing files that changed from the base of the PR and between 53dc6cc and 7267580.

📒 Files selected for processing (3)
  • tests/observability/metrics/conftest.py
  • tests/observability/metrics/test_vms_metrics.py
  • tests/observability/metrics/utils.py

@coderabbitai coderabbitai 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.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/observability/metrics/test_vms_metrics.py (1)

597-612: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

LOW: Update the Expected blocks to match the shared helper checks.

The migration test no longer asserts that both current series are greater than the initial sample; it checks that the virt-controller value increased and that a new virt-handler pod reports a positive value. The deletion test also accepts either no samples or zero-valued samples. Keeping the old wording makes failures harder to interpret.

Suggested fix
         Expected:
-            - Metric values from both virt-controller and virt-handler
-              are greater than the values recorded before migration
+            - The virt-controller value is greater than the value recorded before migration
+            - A new virt-handler pod reports a value greater than 0
@@
         Expected:
-            - Metric value is None
+            - The query returns no samples, or all returned values are 0

Also applies to: 623-636

🤖 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/metrics/test_vms_metrics.py` around lines 597 - 612, The
Expected blocks in the migration and deletion metric tests are out of sync with
the shared helper behavior in the vms metrics test suite. Update the
docstrings/comments in the relevant test cases to reflect that the migration
check now verifies an increased virt-controller value plus a positive
virt-handler series, and that the deletion check accepts either no samples or
zero-valued samples. Use the existing test helper context in the VMS metrics
tests to align the wording with the actual assertions so failures are described
accurately.
🤖 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/metrics/conftest.py`:
- Around line 710-712: The VM fixture starts the guest and yields it
immediately, which can race guest initialization in downstream
NAD-swap/migration tests. In the fedora_vm fixture, after vm.start(wait=True) in
the context managed block, wait for readiness with vm.wait_for_agent_connected()
before yielding the VM so callers only receive a fully connected guest.

---

Outside diff comments:
In `@tests/observability/metrics/test_vms_metrics.py`:
- Around line 597-612: The Expected blocks in the migration and deletion metric
tests are out of sync with the shared helper behavior in the vms metrics test
suite. Update the docstrings/comments in the relevant test cases to reflect that
the migration check now verifies an increased virt-controller value plus a
positive virt-handler series, and that the deletion check accepts either no
samples or zero-valued samples. Use the existing test helper context in the VMS
metrics tests to align the wording with the actual assertions so failures are
described accurately.
🪄 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: 2706b827-10f8-47a3-98c3-da65cc7a4eab

📥 Commits

Reviewing files that changed from the base of the PR and between 53dc6cc and 7267580.

📒 Files selected for processing (3)
  • tests/observability/metrics/conftest.py
  • tests/observability/metrics/test_vms_metrics.py
  • tests/observability/metrics/utils.py
📜 Review details
🔇 Additional comments (3)
tests/observability/metrics/utils.py (1)

39-42: LGTM!

Also applies to: 603-617, 823-932

tests/observability/metrics/conftest.py (1)

18-23: LGTM!

Also applies to: 36-36, 117-117, 715-740

tests/observability/metrics/test_vms_metrics.py (1)

20-31: LGTM!

Also applies to: 470-495, 574-590, 614-618, 638-641

🛑 Comments failed to post (1)
tests/observability/metrics/conftest.py (1)

710-712: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

HIGH: Wait for the guest agent before yielding the VM.

This fixture hands the VM straight to the NAD-swap/migration flow after start(wait=True). If the guest is still booting, the subsequent mutation and metric polling can race initialization and make the test flaky on slower backends.

Suggested fix
     with fedora_vm(namespace=namespace.name, name=vm_name, client=unprivileged_client, spec=spec) as vm:
         vm.start(wait=True)
+        vm.wait_for_agent_connected()
         yield vm

Based on learnings, after vm.start() in VM-related fixtures, prefer vm.wait_for_agent_connected() as the readiness gate.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    with fedora_vm(namespace=namespace.name, name=vm_name, client=unprivileged_client, spec=spec) as vm:
        vm.start(wait=True)
        vm.wait_for_agent_connected()
        yield vm
🤖 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/metrics/conftest.py` around lines 710 - 712, The VM
fixture starts the guest and yields it immediately, which can race guest
initialization in downstream NAD-swap/migration tests. In the fedora_vm fixture,
after vm.start(wait=True) in the context managed block, wait for readiness with
vm.wait_for_agent_connected() before yielding the VM so callers only receive a
fully connected guest.

Source: Learnings

@openshift-virtualization-qe-bot

Copy link
Copy Markdown

Verification failed for PR #5246.
The pipeline did not reach the test execution stage.

Execution details
pytest tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal -s -o log_cli=true -m tier2 --jira

@openshift-virtualization-qe-bot

Copy link
Copy Markdown

/build-and-push-container

@coderabbitai coderabbitai 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.

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/metrics/constants.py`:
- Line 48: The KUBEVIRT_VMI_SYNC_TOTAL metric template is only filtering by
vm_name, which can match VMIs from other namespaces and break the “this VM only”
assumption in the observability helpers. Update the template in constants.py to
include namespace alongside vm_name, then adjust the call sites in
vm_for_migration_metrics_test and related helpers to format both namespace=...
and vm_name=... when building the query.
🪄 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: 48e90460-8a38-4a61-9317-8d78e7a75c82

📥 Commits

Reviewing files that changed from the base of the PR and between 7267580 and 41f5554.

📒 Files selected for processing (4)
  • tests/observability/metrics/conftest.py
  • tests/observability/metrics/constants.py
  • tests/observability/metrics/test_vms_metrics.py
  • tests/observability/metrics/utils.py

Comment thread tests/observability/metrics/constants.py
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 29, 2026
for more information, see https://pre-commit.ci

Signed-off-by: Ohad <orevah@redhat.com>
@openshift-virtualization-qe-bot-3

Copy link
Copy Markdown
Contributor

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

@openshift-virtualization-qe-bot

Copy link
Copy Markdown

Verification failed for PR #5246.
Result: FAILURE
Job: openshift-virtualization-tests-runner #5834

Execution details
pytest tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal -s -o log_cli=true -m tier2 --jira
Image: openshift-virtualization-tests:pr-5246

@openshift-virtualization-qe-bot

Copy link
Copy Markdown

/build-and-push-container

@openshift-virtualization-qe-bot-6

Copy link
Copy Markdown

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

@openshift-virtualization-qe-bot

Copy link
Copy Markdown

/verified

All tests passed for PR #5246.
Job: openshift-virtualization-tests-runner #5837

Execution details
pytest tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal -s -o log_cli=true -m tier2 --jira
Image: openshift-virtualization-tests:pr-5246

@openshift-virtualization-qe-bot-3

Copy link
Copy Markdown
Contributor

@coderabbitai

Test execution plan request details

CRITICAL: You MUST post an inline review comment on the first changed line of the first file.
The inline comment should contain the full Test Execution Plan (smoke decision, gating decision, and specific affected tests).
Do NOT submit a blocking review event (REQUEST_CHANGES/APPROVE).
Post a single inline PR comment on Files Changed (non-blocking COMMENT flow).

As an expert software testing engineer, analyze all modified files in this PR and create a targeted test execution plan.
You will post an inline review comment with the test execution plan on the first changed file.
If you fail to run or post a comment, retry.

Analysis Requirements:

  1. Examine code changes in each modified file

  2. Identify affected code paths, functions, and classes

  3. Analyze pytest-specific elements: fixtures (scope, dependencies), parametrization, markers, conftest changes

  4. Trace test dependencies through imports, shared utilities, fixture inheritance, fixture teardown, and yield from cleanup in conftest

  5. Detect new tests introduced in the PR

  6. Utilities and libs impact (when utilities/ or libs/ changes):
    You MUST use shell scripts (rg, git diff) to trace the full impact.
    Follow these sub-steps in order:

    6a. Identify modified symbols: For each changed file under utilities/ or libs/,
    list every modified function or method.
    Example: git diff HEAD~1 --unified=0 -- utilities/hco.py | grep '^[+-]def '

    6b. Find direct callers: Search tests and conftest for each symbol from 6a.
    Example: rg -l 'get_hco_version' tests/

    6c. Trace fixture teardown and cleanup: Find fixtures that reach
    the modified symbol through yield from or context-manager wrappers.
    Example: rg -l 'yield from.*enable_common_boot|def.*enable_common_boot' tests/

    6d. Trace same-file callers: In each changed file, find other functions
    whose body calls a modified symbol (including code after yield
    in @contextmanager helpers).
    Example: rg 'get_hco_version|enable_common_boot' utilities/hco.py

    6e. Expand transitively: If function A calls modified B, then
    tests/fixtures that call A are affected — even when the test body
    never imports B directly.

    Do NOT limit impact to tests that import the modified symbol only.

  7. Smoke test impact: Intersect the affected set from step 6 with smoke-marked tests.
    Run: rg -l '@pytest.mark.smoke' tests/
    VERIFY the above command returned actual file paths before concluding False.
    Set True if either condition is met:

    • a smoke-marked file appears in the affected set from 6b-6e, OR
    • any conftest.py in the smoke test's parent-directory hierarchy (up to repo root)
      imports or calls a modified utilities/libs symbol — including autouse fixtures
      that depend on modified functions. ALL tests in that directory and below are affected.
      Example check: for each smoke_file, scan dirname(smoke_file)/conftest.py,
      dirname(dirname(smoke_file))/conftest.py, etc. for modified symbol imports
      and autouse fixtures that depend on modified symbols.
  8. Gating test impact: Intersect the affected set from step 6 with gating-marked tests.
    Run: rg -l '@pytest.mark.gating' tests/
    Set True if a gating-marked file also appears in the affected set from 6b-6e.
    Utilities/libs changes often affect gating tests without affecting smoke tests.
    Do NOT stop analysis after concluding Run smoke tests: False.

Output rules:
Do NOT include analysis step numbers (1-8) in your visible output.

Your deliverable:
Your inline informational comment will be based on the following requirements:

Test Execution Plan

  • Run smoke tests: True / False — If True, state the dependency path (test → fixture → changed symbol). True ONLY with a verified path.
  • Run gating tests: True / False — If True, state the dependency path. True if any gating-marked test is in the affected set.
  • Affected tests to run (required when utilities/, libs/, or shared conftest changes — list concrete paths even when smoke is False)

Use these formats:

  • path/to/test_file.py - When the entire test file needs verification
  • path/to/test_file.py::TestClass::test_method - When specific test(s) needed
  • path/to/test_file.py::test_function - When specific test(s) needed
  • -m marker - When a marker covers multiple affected tests (e.g. -m gating only if ALL gating tests in scope need run)
  • Tag each listed test or group with its marker when not obvious, e.g. (gating) or (smoke)

Real test commands (MANDATORY when changes affect session/runtime code):

When the affected code runs at session/collection time (conftest fixtures, pytest plugins,
config hooks, session-scoped setup) or modifies runtime behavior that unit tests mock away,
you MUST include concrete pytest commands the PR author must run on a real cluster
to verify the change works end-to-end. Include:

  • A command for the error/fix path (the scenario the PR fixes)
  • A command for the happy path (regression: the normal case still works)
  • Use lightweight tests (e.g., --collect-only for startup failures,
    a single small test for runtime behavior)
    If the PR only changes test logic (not utilities/libs/conftest), the affected test
    paths themselves serve as the real test commands — no separate section needed.

Example output for a session-startup fix:

**Real tests (cluster required)**
Error path (the fix):
`pytest tests/storage/.../test_foo.py --storage-class-matrix=nonexistent-sc --collect-only`
Expected: ValueError with clear message, not IndexError

Happy path (regression):
`pytest tests/storage/.../test_foo.py --storage-class-matrix=<valid-sc> -k test_bar`
Expected: session starts normally

Guidelines:

  • Include tests affected directly OR via fixture setup/teardown, yield from cleanup, or transitive utility call chains (caller calls modified helper)
  • Use a full file path only if ALL tests in that file require verification
  • Use file path + test name when only specific tests use an affected fixture or utility wrapper (preferred for partial file impact)
  • If a test marker can cover multiple files/tests, provide the marker
  • Balance coverage vs over-testing - Keep descriptions minimal
  • Example: if leaf helper foo() changes, include tests whose fixture teardown calls wrapper bar() where bar() calls foo(), even when the test body only imports an unrelated symbol from the same utilities module

Hardware-Related Checks (SR-IOV, GPU, DPDK):

When PR modifies fixtures for hardware-specific resources:

  • Collection Safety: Fixtures MUST have existence checks (return None when hardware unavailable)
  • Test Plan: MUST verify both WITH and WITHOUT hardware:
    • Run affected tests on cluster WITH hardware
    • Verify collection succeeds on cluster WITHOUT hardware

CRITICAL WORKFLOW COMPLETION RULES:

When responding to this test execution plan request, you MUST follow these rules EXACTLY:

  1. YOUR ONLY DELIVERABLE: Post one non-blocking inline comment containing the test execution plan on the first changed line
  2. THEN STOP IMMEDIATELY - Do NOT generate any additional response
  3. FALLBACK ONLY: If inline comment API calls fail after retrying, post as a regular PR comment
  4. SILENCE = SUCCESS: After successfully submitting the review, your task is complete. No confirmation needed.

ABSOLUTE PROHIBITIONS (violating these creates empty/meaningless reviews):

  • ❌ Do NOT post acknowledgment messages like "Test execution plan posted", "Review posted successfully", "I've successfully posted"
  • ❌ Do NOT mention review IDs, URLs, or confirmation of posting in the PR thread
  • ❌ Do NOT add any follow-up comments after submitting the review
  • ❌ Do NOT reply to confirm task completion
  • ❌ Do NOT explain what you did - just do it and stop

Remember: The pull request review is visible to users. Additional comments are redundant noise.

CRITICAL — Verification rules for smoke and gating decisions:
- For each True decision, you must have traced a concrete path: test file → fixture → utility function → modified symbol.
- Do NOT assume impact based on scope, file proximity, or infrastructure-sounding names.
Only set True when you trace a concrete path through steps 6a-6e, then 7 or 8.
WRONG: "utilities/hco.py changed → run smoke" (no traced dependency path)
WRONG: "Run smoke tests: False" with no affected-test list when gating tests use the changed utility
RIGHT: "Run smoke tests: False, Run gating tests: True" plus tests/.../test_foo.py::TestBar::test_baz (gating)
RIGHT: "Smoke test X uses fixture Y → wrapper Z → changed function W in utilities/hco.py"

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="RedHatQE/openshift-virtualization-tests"
pr="5246"

echo "== Current changed files =="
gh api "/repos/$repo/pulls/$pr/files?per_page=100" --jq '.[].filename'

files_json="$(mktemp)"
gh api "/repos/$repo/pulls/$pr/files?per_page=100" > "$files_json"

first_file="$(jq -r '.[0].filename' "$files_json")"
echo "FIRST_FILE=$first_file"

echo
echo "== First file patch =="
jq -r '.[0].patch // ""' "$files_json" | sed -n '1,120p'

first_line="$(
jq -r '.[0].patch // ""' "$files_json" | python - <<'PY'
import re, sys
cur = None
for raw in sys.stdin:
    line = raw.rstrip("\n")
    m = re.match(r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@', line)
    if m:
        cur = int(m.group(1))
        continue
    if cur is None:
        continue
    if line.startswith('+') and not line.startswith('+++'):
        print(cur)
        raise SystemExit(0)
    if line.startswith('-') and not line.startswith('---'):
        continue
    cur += 1
raise SystemExit("no added line found")
PY
)"
echo "FIRST_CHANGED_LINE=$first_line"

echo
echo "== Outline changed Python files =="
while IFS= read -r f; do
  echo "--- $f ---"
  ast-grep outline "$f" --lang python || true
done < <(jq -r '.[].filename' "$files_json" | grep '^tests/observability/metrics/.*\.py$')

echo
echo "== Relevant symbol usage in observability metrics =="
rg -n -C2 \
  'KUBEVIRT_VMI_SYNC_TOTAL|initial_vmi_sync_total_values|deleted_vmi_sync_total_vm|validate_vmi_sync_total_reported_and_positive|validate_vmi_sync_total_after_migration|validate_metric_value_cleared|TestVmiSyncTotal|`@pytest`\.mark\.(smoke|gating|tier2)' \
  tests/observability/metrics

echo
echo "== Global usage of changed fixtures/helpers =="
rg -n -C2 \
  'initial_vmi_sync_total_values|deleted_vmi_sync_total_vm|validate_vmi_sync_total_reported_and_positive|validate_vmi_sync_total_after_migration|validate_metric_value_cleared' \
  tests

echo
echo "== Smoke-marked tests (actual paths) =="
rg -n -l '`@pytest`\.mark\.smoke' tests | sed -n '1,120p'

echo
echo "== Gating-marked tests (actual paths) =="
rg -n -l '`@pytest`\.mark\.gating' tests | sed -n '1,120p'

echo
echo "== Any smoke/gating markers under observability metrics =="
rg -n '`@pytest`\.mark\.(smoke|gating|tier2)' tests/observability/metrics || true

echo
echo "== Parent conftest references for smoke suites =="
python <<'PY'
from pathlib import Path
import subprocess

changed = [
    "KUBEVIRT_VMI_SYNC_TOTAL",
    "initial_vmi_sync_total_values",
    "deleted_vmi_sync_total_vm",
    "validate_vmi_sync_total_reported_and_positive",
    "validate_vmi_sync_total_after_migration",
    "validate_metric_value_cleared",
]

smoke_files = subprocess.check_output(
    ["bash", "-lc", r"rg -l '`@pytest`\.mark\.smoke' tests || true"],
    text=True,
).splitlines()

repo_root = Path(".").resolve()
seen = set()

for smoke in smoke_files:
    cur = (repo_root / smoke).parent
    while True:
        cf = cur / "conftest.py"
        if cf.exists() and cf not in seen:
            seen.add(cf)
            text = cf.read_text()
            hits = [s for s in changed if s in text]
            if hits:
                print(f"{cf.relative_to(repo_root)} :: {', '.join(hits)}")
        if cur == repo_root:
            break
        cur = cur.parent
PY

body_file="$(mktemp)"
cat > "$body_file" <<'EOF'
## Test Execution Plan

**Run smoke tests: False**  
No smoke-marked test has a verified dependency path to the changed symbols. `KUBEVIRT_VMI_SYNC_TOTAL`, `initial_vmi_sync_total_values`, `deleted_vmi_sync_total_vm`, `validate_vmi_sync_total_reported_and_positive`, `validate_vmi_sync_total_after_migration`, and `validate_metric_value_cleared` are only referenced within `tests/observability/metrics/`, specifically by `tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal`. No smoke-marked file or parent `conftest.py` for smoke suites imports or calls these symbols.

**Run gating tests: False**  
No gating-marked test is in the affected set. The changed fixtures/helpers have no callers outside `tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal`, and there are no gating-marked tests under `tests/observability/metrics/`.

**Affected tests to run**
- `tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal::test_kubevirt_vmi_sync_total` *(tier2)*
- `tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal::test_kubevirt_vmi_sync_total_increases_after_migration` *(tier2)*
- `tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal::test_kubevirt_vmi_sync_total_cleared_after_vm_deletion` *(tier2)*

**Real tests (cluster required)**  
Error/fix path:  
`pytest tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal::test_kubevirt_vmi_sync_total_increases_after_migration -s -o log_cli=true -m tier2 --jira`  
Expected: after live migration, the `virt-controller` metric value increases, a new `virt-handler` pod is observed, and the updated fixture/helper chain in `tests/observability/metrics/conftest.py` and `tests/observability/metrics/utils.py` succeeds.

Happy path (regression):  
`pytest tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal::test_kubevirt_vmi_sync_total -s -o log_cli=true -m tier2 --jira && pytest tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal::test_kubevirt_vmi_sync_total_cleared_after_vm_deletion -s -o log_cli=true -m tier2 --jira`  
Expected: the metric is reported by both `virt-controller` and `virt-handler` before deletion, and the metric is cleared (absent or zero) after VM deletion.

**Why this scope:** `tests/observability/metrics/conftest.py` and `tests/observability/metrics/utils.py` are shared files, so real-cluster commands are required, but the dependency chain remains local: `TestVmiSyncTotal` → `initial_vmi_sync_total_values` / `deleted_vmi_sync_total_vm` → `validate_vmi_sync_total_reported_and_positive` / `validate_vmi_sync_total_after_migration` / `validate_metric_value_cleared`.
EOF

commit_id="$(gh pr view "$pr" --repo "$repo" --json headRefOid --jq '.headRefOid')"

echo
echo "== Attempt inline PR review comment via direct endpoint =="
set +e
gh api \
  --method POST \
  -H "Accept: application/vnd.github+json" \
  "/repos/$repo/pulls/$pr/comments" \
  -f commit_id="$commit_id" \
  -f path="$first_file" \
  -F line="$first_line" \
  -f side="RIGHT" \
  -f body="$(cat "$body_file")"
status_inline=$?
set -e
echo "INLINE_STATUS=$status_inline"

if [ "$status_inline" -ne 0 ]; then
  echo
  echo "== Fallback regular PR comment =="
  set +e
  gh api \
    --method POST \
    -H "Accept: application/vnd.github+json" \
    "/repos/$repo/issues/$pr/comments" \
    -f body="$(cat "$body_file")"
  status_fallback=$?
  set -e
  echo "FALLBACK_STATUS=$status_fallback"
fi

rm -f "$body_file" "$files_json"

Length of output: 8871


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="RedHatQE/openshift-virtualization-tests"
pr="5246"
path="tests/observability/metrics/conftest.py"
line="30"

echo "== Sanity check: current changed files =="
gh api "/repos/$repo/pulls/$pr/files?per_page=100" --jq '.[].filename'

echo
echo "== Sanity check: verify target patch context =="
gh api "/repos/$repo/pulls/$pr/files?per_page=100" \
  --jq '.[] | select(.filename=="tests/observability/metrics/conftest.py") | .patch' \
  | sed -n '1,40p'

echo
echo "== Verify affected symbols remain local to TestVmiSyncTotal =="
rg -n -C1 \
  'initial_vmi_sync_total_values|deleted_vmi_sync_total_vm|validate_vmi_sync_total_reported_and_positive|validate_vmi_sync_total_after_migration|validate_metric_value_cleared|KUBEVIRT_VMI_SYNC_TOTAL|TestVmiSyncTotal' \
  tests

echo
echo "== Verify smoke/gating markers under observability metrics =="
rg -n '`@pytest`\.mark\.(smoke|gating|tier2)' tests/observability/metrics || true

echo
echo "== Verify global smoke/gating file paths exist =="
rg -n -l '`@pytest`\.mark\.smoke' tests | sed -n '1,40p'
rg -n -l '`@pytest`\.mark\.gating' tests | sed -n '1,40p'

body_file="$(mktemp)"
cat > "$body_file" <<'EOF'
## Test Execution Plan

**Run smoke tests: False**  
No smoke-marked test has a verified dependency path to the changed symbols. `KUBEVIRT_VMI_SYNC_TOTAL`, `initial_vmi_sync_total_values`, `deleted_vmi_sync_total_vm`, `validate_vmi_sync_total_reported_and_positive`, `validate_vmi_sync_total_after_migration`, and `validate_metric_value_cleared` are only referenced within `tests/observability/metrics/`, specifically by `tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal`. No smoke-marked file or parent `conftest.py` for smoke suites imports or calls these symbols.

**Run gating tests: False**  
No gating-marked test is in the affected set. The changed fixtures/helpers have no callers outside `tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal`, and there are no gating-marked tests under `tests/observability/metrics/`.

**Affected tests to run**
- `tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal::test_kubevirt_vmi_sync_total` *(tier2)*
- `tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal::test_kubevirt_vmi_sync_total_increases_after_migration` *(tier2)*
- `tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal::test_kubevirt_vmi_sync_total_cleared_after_vm_deletion` *(tier2)*

**Real tests (cluster required)**  
Error/fix path:  
`pytest tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal::test_kubevirt_vmi_sync_total_increases_after_migration -s -o log_cli=true -m tier2 --jira`  
Expected: after live migration, the `virt-controller` metric value increases, a new `virt-handler` pod is observed, and the updated fixture/helper chain in `tests/observability/metrics/conftest.py` and `tests/observability/metrics/utils.py` succeeds.

Happy path (regression):  
`pytest tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal::test_kubevirt_vmi_sync_total -s -o log_cli=true -m tier2 --jira && pytest tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal::test_kubevirt_vmi_sync_total_cleared_after_vm_deletion -s -o log_cli=true -m tier2 --jira`  
Expected: the metric is reported by both `virt-controller` and `virt-handler` before deletion, and the metric is cleared (absent or zero) after VM deletion.

**Why this scope:** `tests/observability/metrics/conftest.py` and `tests/observability/metrics/utils.py` are shared files, so real-cluster commands are required, but the dependency chain remains local: `TestVmiSyncTotal` → `initial_vmi_sync_total_values` / `deleted_vmi_sync_total_vm` → `validate_vmi_sync_total_reported_and_positive` / `validate_vmi_sync_total_after_migration` / `validate_metric_value_cleared`.
EOF

commit_id="$(gh pr view "$pr" --repo "$repo" --json headRefOid --jq '.headRefOid')"

echo
echo "== Attempt 1: direct inline PR review comment endpoint =="
set +e
gh api \
  --method POST \
  -H "Accept: application/vnd.github+json" \
  "/repos/$repo/pulls/$pr/comments" \
  -f commit_id="$commit_id" \
  -f path="$path" \
  -F line="$line" \
  -f side="RIGHT" \
  -f body="$(cat "$body_file")"
status_inline=$?
set -e
echo "INLINE_STATUS=$status_inline"

if [ "$status_inline" -ne 0 ]; then
  echo
  echo "== Attempt 2: review API with inline comment payload =="
  set +e
  gh api \
    --method POST \
    -H "Accept: application/vnd.github+json" \
    "/repos/$repo/pulls/$pr/reviews" \
    -f event=COMMENT \
    -f commit_id="$commit_id" \
    -f body= \
    -f "comments[][path]=$path" \
    -F "comments[][line]=$line" \
    -f "comments[][side]=RIGHT" \
    -f "comments[][body]=$(cat "$body_file")"
  status_review=$?
  set -e
  echo "REVIEW_STATUS=$status_review"
else
  status_review=0
fi

if [ "${status_inline:-1}" -ne 0 ] && [ "${status_review:-1}" -ne 0 ]; then
  echo
  echo "== Fallback: regular PR comment =="
  set +e
  gh api \
    --method POST \
    -H "Accept: application/vnd.github+json" \
    "/repos/$repo/issues/$pr/comments" \
    -f body="$(cat "$body_file")"
  status_fallback=$?
  set -e
  echo "FALLBACK_STATUS=$status_fallback"
fi

rm -f "$body_file"

Length of output: 16338


@openshift-virtualization-qe-bot-3

CRITICAL: Retry completed, but GitHub rejected all write paths with 403 Resource not accessible by integration.

Why this matters: your workflow requires the plan to be posted as a PR comment. I can analyze the PR, but without comment/review write permission, I cannot complete the delivery step.

Verified target

  • File: tests/observability/metrics/conftest.py
  • Line 30
  • First added line: KUBEVIRT_VMI_SYNC_TOTAL,

Verified findings

  • Changed symbols stay local to tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal
  • No @pytest.mark.smoke or @pytest.mark.gating tests exist under tests/observability/metrics
  • Write attempts failed on:
    • inline review comment endpoint
    • review API with inline comment payload
    • fallback regular PR comment endpoint

Ready-to-post content

## Test Execution Plan

**Run smoke tests: False**  
No smoke-marked test has a verified dependency path to the changed symbols. `KUBEVIRT_VMI_SYNC_TOTAL`, `initial_vmi_sync_total_values`, `deleted_vmi_sync_total_vm`, `validate_vmi_sync_total_reported_and_positive`, `validate_vmi_sync_total_after_migration`, and `validate_metric_value_cleared` are only referenced within `tests/observability/metrics/`, specifically by `tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal`. No smoke-marked file or parent `conftest.py` for smoke suites imports or calls these symbols.

**Run gating tests: False**  
No gating-marked test is in the affected set. The changed fixtures/helpers have no callers outside `tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal`, and there are no gating-marked tests under `tests/observability/metrics/`.

**Affected tests to run**
- `tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal::test_kubevirt_vmi_sync_total` *(tier2)*
- `tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal::test_kubevirt_vmi_sync_total_increases_after_migration` *(tier2)*
- `tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal::test_kubevirt_vmi_sync_total_cleared_after_vm_deletion` *(tier2)*

**Real tests (cluster required)**  
Error/fix path:  
`pytest tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal::test_kubevirt_vmi_sync_total_increases_after_migration -s -o log_cli=true -m tier2 --jira`  
Expected: after live migration, the `virt-controller` metric value increases, a new `virt-handler` pod is observed, and the updated fixture/helper chain in `tests/observability/metrics/conftest.py` and `tests/observability/metrics/utils.py` succeeds.

Happy path (regression):  
`pytest tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal::test_kubevirt_vmi_sync_total -s -o log_cli=true -m tier2 --jira && pytest tests/observability/metrics/test_vms_metrics.py::TestVmiSyncTotal::test_kubevirt_vmi_sync_total_cleared_after_vm_deletion -s -o log_cli=true -m tier2 --jira`  
Expected: the metric is reported by both `virt-controller` and `virt-handler` before deletion, and the metric is cleared (absent or zero) after VM deletion.

**Why this scope:** `tests/observability/metrics/conftest.py` and `tests/observability/metrics/utils.py` are shared files, so real-cluster commands are required, but the dependency chain remains local: `TestVmiSyncTotal``initial_vmi_sync_total_values` / `deleted_vmi_sync_total_vm``validate_vmi_sync_total_reported_and_positive` / `validate_vmi_sync_total_after_migration` / `validate_metric_value_cleared`.

HIGH: Once the integration has PR comment/review write permission on #5246, I can retry the exact same payload against tests/observability/metrics/conftest.py at Line 30.

@dshchedr

Copy link
Copy Markdown
Collaborator

/lgtm

@vsibirsk

Copy link
Copy Markdown
Collaborator

/approve

@openshift-virtualization-qe-bot-4

Copy link
Copy Markdown

Successfully removed PR tag: quay.io/openshift-cnv/openshift-virtualization-tests:pr-5246.

@openshift-virtualization-qe-bot-4

Copy link
Copy Markdown

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

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.