Skip to content

Add STD for vnic_info metric NAD swap test#4601

Open
OhadRevah wants to merge 1 commit intoRedHatQE:mainfrom
OhadRevah:add-vnic-info-nad-swap-std
Open

Add STD for vnic_info metric NAD swap test#4601
OhadRevah wants to merge 1 commit intoRedHatQE:mainfrom
OhadRevah:add-vnic-info-nad-swap-std

Conversation

@OhadRevah
Copy link
Copy Markdown
Contributor

@OhadRevah OhadRevah commented Apr 27, 2026

Short description:

Add test stub with STD for verifying that
kubevirt_vm_vnic_info and kubevirt_vmi_vnic_info Prometheus metrics update their network label after swapping a VM's secondary NAD reference. Parametrized for both metric variants.

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

More details:

As part of NAD reference live-update STP

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

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

Summary by CodeRabbit

  • Tests
    • Added a parametrized test to validate VM vNIC metrics after a network-attachment (NAD) swap, covering multiple metric variants and documenting the NAD-swap scenario. The test is currently disabled and will not run until re-enabled.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

📝 Walkthrough

Walkthrough

Adds a new parametrized test method to TestVmVnicInfo documenting a NAD-swap scenario for the secondary vNIC targeting kubevirt_vm_vnic_info and kubevirt_vmi_vnic_info; the test is disabled from pytest collection.

Changes

Test Addition: vnic_info NAD-swap

Layer / File(s) Summary
Test Description
tests/observability/metrics/test_vms_metrics.py
Adds test_metric_kubevirt_vm_vnic_info_after_nad_swap(self, query) with a docstring describing NAD-swap preconditions, steps, and expected metric label updates (Polarion CNV-12225, CNV-12226).
Parametrization
tests/observability/metrics/test_vms_metrics.py
Parametrizes query to exercise kubevirt_vm_vnic_info{..., vnic_name='secondary'} and kubevirt_vmi_vnic_info{..., vnic_name='secondary'}.
Collection Control
tests/observability/metrics/test_vms_metrics.py
Disables pytest collection for the new method by setting test_metric_kubevirt_vm_vnic_info_after_nad_swap.__test__ = False.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: adding a test stub with STD for verifying vnic_info metric behavior after NAD swap, which aligns with the changeset that adds a parametrized test for this scenario.
Description check ✅ Passed The description covers most required sections: short description explains the test purpose, more details reference the related STP, and jira-ticket is provided. However, 'What this PR does / why we need it' and 'Special notes for reviewer' 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.

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

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

Warning

Review ran into problems

🔥 Problems

Timed out fetching pipeline failures after 30000ms


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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

@openshift-virtualization-qe-bot-5
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

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

@openshift-virtualization-qe-bot-5
Copy link
Copy Markdown

Clean rebase detected — no code changes compared to previous head (920fb44).
The following labels were preserved: lgtm-coderabbitai[bot].

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

D/S test tox -e verify-tc-requirement-polarion failed: cnv-tests-tox-executor/27239

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

D/S test tox -e verify-tc-requirement-polarion failed: cnv-tests-tox-executor/27240

Comment thread tests/observability/metrics/test_vms_metrics.py Outdated
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 the current code and only fix it if needed.

Inline comments:
In `@tests/observability/metrics/test_vms_metrics.py`:
- Around line 453-488: Move the STP traceability link out of the test and into
the module-level docstring at the top of the file, and simplify the test
docstring for test_metric_kubevirt_vm_vnic_info_after_nad_swap by removing the
"Parametrize:" section and leaving only "Preconditions:", "Steps:", and
"Expected:" entries; ensure the test stub (function
test_metric_kubevirt_vm_vnic_info_after_nad_swap) retains __test__ = False and
that the module docstring includes the required STP link for tests/** STD
coverage.
🪄 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: a6c00541-c936-4c6c-b925-24b9735d429f

📥 Commits

Reviewing files that changed from the base of the PR and between 920fb44 and 2ddee62.

📒 Files selected for processing (1)
  • tests/observability/metrics/test_vms_metrics.py

Comment thread tests/observability/metrics/test_vms_metrics.py
@openshift-virtualization-qe-bot
Copy link
Copy Markdown

D/S test tox -e verify-tc-requirement-polarion failed: cnv-tests-tox-executor/27437

Add test stub with STD for verifying that
kubevirt_vm_vnic_info and kubevirt_vmi_vnic_info Prometheus metrics
update their network label after swapping a VM's secondary NAD
reference. Parametrized for both metric variants.

assisted by: claude code claude-opus-4-6
Signed-off-by: Ohad <orevah@redhat.com>
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.

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

463-477: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

HIGH: Add the required module-level STP link for this new STD placeholder.

This stub follows the STD section format, but traceability is still incomplete because the module lacks an STP link in the module docstring. This rule exists to keep coverage mapping and STD-first review auditable.

Suggested fix
+"""STP: <link to the NAD reference live-update STP discussion>"""
+
 import logging

As per coding guidelines: “STP link REQUIRED in module docstring - every new feature test module MUST include an STP link for coverage tracking” and “STD docstrings must contain STP link directly in module docstring”.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/observability/metrics/test_vms_metrics.py` around lines 463 - 477, The
module is missing the required STP link in its top-level docstring; add a
module-level STP reference string (e.g., "STP: <stp-id-or-url>") to the file's
module docstring so the new test function
test_metric_kubevirt_vm_vnic_info_after_nad_swap and other STD placeholders are
traceable for coverage mapping and STD-first review; ensure the STP link is
directly in the module docstring (not inside a function/class docstring) and
follows the project's STP formatting convention.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@tests/observability/metrics/test_vms_metrics.py`:
- Around line 463-477: The module is missing the required STP link in its
top-level docstring; add a module-level STP reference string (e.g., "STP:
<stp-id-or-url>") to the file's module docstring so the new test function
test_metric_kubevirt_vm_vnic_info_after_nad_swap and other STD placeholders are
traceable for coverage mapping and STD-first review; ensure the STP link is
directly in the module docstring (not inside a function/class docstring) and
follows the project's STP formatting convention.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 202c9b79-c006-4099-a58e-4bc25b97a620

📥 Commits

Reviewing files that changed from the base of the PR and between 2ddee62 and 92a4f89.

📒 Files selected for processing (1)
  • tests/observability/metrics/test_vms_metrics.py

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

D/S test tox -e verify-tc-requirement-polarion failed: cnv-tests-tox-executor/27512

metric_name=f"kubevirt_vmi_vnic_info{{name='{windows_vm_for_test.name}'}}",
)

@pytest.mark.parametrize(
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.

can you add the stp link?
reference #4734

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.

@servolkov
Copy link
Copy Markdown
Contributor

/lgtm

Reviewed the scenario - looks ok.

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.

9 participants