Skip to content

net: adapt test helpers to Fedora 43#4873

Open
servolkov wants to merge 3 commits into
RedHatQE:mainfrom
servolkov:fix/fedora-43-fix-net
Open

net: adapt test helpers to Fedora 43#4873
servolkov wants to merge 3 commits into
RedHatQE:mainfrom
servolkov:fix/fedora-43-fix-net

Conversation

@servolkov
Copy link
Copy Markdown
Contributor

@servolkov servolkov commented May 15, 2026

What this PR does / why we need it:

Fix test failures caused by the Fedora 41 → 43 container image upgrade (PR #4322):

  1. Console output parsing broken — Fedora 43 (systemd 256+) emits OSC 8003
    session-tracking escape sequences. The ANSI regex in vm_console_run_commands
    only stripped CSI sequences, leaving OSC markers in parsed output. This caused
    json.loads() to fail in test_vm_is_started_with_successful_connectivity.

  2. IP lookup race conditionget_ip_from_vm_or_virt_handler_pod read
    vmi.interfaces[0]["ipAddresses"] once without waiting. Fedora 43's guest agent
    reports IPs slower than Fedora 41, so ipAddresses was still None right after
    AgentConnected became True, crashing test_connectivity_over_pod_network.

Which issue(s) this PR fixes:

failures from PR #4322

Special notes for reviewer:

Importing lookup_iface_status_ip from libs/net/vmspec into utilities/network.py was
blocked by the circular dependency caused by IfaceNotFound living in utilities/network.py.
IfaceNotFound was a single exception incorrectly covering both spec and status lookup
failures with a misleading "Interface not found for NAD" message. Replaced each usage
with the semantically correct exception.

Removing IfaceNotFound is a prerequisite for the race condition fix.

jira-ticket:

NONE

Summary by CodeRabbit

  • Bug Fixes

    • Cleaner VM console output by extending terminal escape sequence removal.
  • Refactor

    • Standardized exception handling for VM network/interface operations across the codebase.
    • Improved type-checking imports for maintainability.
  • Tests

    • Updated tests to align with the standardized exception behavior for interface status errors.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

Review Change Stack

Caution

Review failed

Failed to post review comments

📝 Walkthrough

Walkthrough

Centralizes interface-related exceptions in libs/net/vmspec, defers a runtime VM type import, updates VM and network utilities to use vmspec lookup/error helpers (including IP resolution via lookup_iface_status_ip), updates tests to expect the new exceptions, and extends console escape stripping.

Changes

Exception Centralization and Network Utility Refactoring

Layer / File(s) Summary
vmspec typing deferral
libs/net/vmspec.py
Adds from __future__ import annotations, imports TYPE_CHECKING, and moves BaseVirtualMachine import into a TYPE_CHECKING block.
VM interface state exception migration
libs/vm/vm.py
Imports VMInterfaceSpecNotFoundError and changes BaseVirtualMachine.set_interface_state to raise VMInterfaceSpecNotFoundError when domain.devices is missing or the requested interface isn't found.
Network utility exception and IP resolution updates
utilities/network.py
Imports IpNotFound, VMInterfaceStatusNotFoundError, and lookup_iface_status_ip; get_vmi_mac_address_by_iface_name() now raises VMInterfaceStatusNotFoundError; get_ip_from_vm_or_virt_handler_pod() derives iface_name from vm.vmi.interfaces[0]["name"], maps family→ip_family, calls lookup_iface_status_ip(), returns None on IpNotFound, otherwise returns the resolved IP string.
Test imports and expectation updates
tests/network/l2_bridge/libl2bridge.py, tests/network/l2_bridge/test_bridge_nic_hot_plug.py
Tests import VMInterfaceStatusNotFoundError from libs.net.vmspec, remove IfaceNotFound imports, and change raised/expected IfaceNotFound occurrences to VMInterfaceStatusNotFoundError for interface resolution and hot-plug/unplug assertions.
Console escape stripping
utilities/virt.py
vm_console_run_commands regex extended to also remove OSC sequences in addition to CSI sequences from captured console output.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • nirdothan
  • orelmisan
  • yossisegev
  • EdDev
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed Title accurately describes the change: fixing test helpers (exception imports and ANSI regex) for Fedora 43 compatibility.
Description check ✅ Passed Description comprehensively covers both defects (console output parsing and IP lookup race), explains root causes, references the triggering PR, and documents the circular dependency resolution.
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 No new test files or test functions added; PR only modifies imports/exceptions in existing test_bridge_nic_hot_plug.py.

✏️ 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

Stopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a @coderabbit review after the pipeline has finished.


Linked repositories: Couldn't analyze RedHatQE/openshift-virtualization-tests-design-docs - clone failed: Clone operation failed: Cloning into '/home/jailuser/git'...
warning: templates not found in /usr/share/git-core/templates
fatal: unable to access 'https://github.com/RedHatQE/openshift-virtualization-tests-design-docs.git/': Failed to connect to github.com port 443 after 135068 ms: Couldn't connect to server


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:

  • EdDev
  • dshchedr
  • myakove
  • rnetser
  • vsibirsk

Reviewers:

  • Anatw
  • EdDev
  • RoniKishner
  • azhivovk
  • dshchedr
  • frenzyfriday
  • geetikakay
  • nirdothan
  • orelmisan
  • rnetser
  • servolkov
  • vsibirsk
  • yossisegev
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 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.65%. Comparing base (a2dc143) to head (339b773).
⚠️ Report is 77 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4873      +/-   ##
==========================================
- Coverage   98.67%   98.65%   -0.02%     
==========================================
  Files          25       25              
  Lines        2487     2459      -28     
==========================================
- Hits         2454     2426      -28     
  Misses         33       33              
Flag Coverage Δ
utilities 98.65% <ø> (-0.02%) ⬇️

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.

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 15, 2026
@servolkov
Copy link
Copy Markdown
Contributor Author

servolkov commented May 29, 2026

/verified

this

Also verified same tests but with old fedora-41 - all PASSED.

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

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

@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 Test Execution Plan with the smoke tests recommendation.
Do NOT submit a formal review - just post the inline comment directly.

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, and fixture inheritance
  5. Detect new tests introduced in the PR
  6. Smoke Test Impact Analysis: Determine if any changes could affect smoke tests by checking:
    • Changes to files/functions used by tests marked with @pytest.mark.smoke
    • Changes to fixtures or utilities imported by smoke tests
    • Changes to conftest.py files that may affect smoke test execution
    • Changes to core infrastructure code (utilities/, libs/) that smoke tests depend on

Your deliverable:
Your change request comment will be based on the following requirements:

Test Execution Plan

  • Run smoke tests: True / False (Based on your smoke test impact analysis - True if any changes may affect smoke tests)
  • 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 specific marker(s) can be used to cover multiple cases.

Guidelines:

  • Include only tests directly affected by the changes
  • Use a full file path only if ALL tests in that file require verification
  • Use file path + test name if only specific tests are needed
  • If a test marker can cover multiple files/tests, provide the marker
  • Balance coverage vs over-testing - Keep descriptions minimal

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 an inline review 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 submitting the review fails 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: Before setting "Run smoke tests: True", you MUST use shell scripts to:
- Trace the actual fixture dependency chain from smoke tests to changed fixtures
- Verify that smoke tests actually import/use changed utilities or functions
- Confirm the dependency path exists; do NOT assume based on scope or semantics
- Be conservative: Session-scoped fixtures or infrastructure-sounding names do NOT
automatically mean smoke test impact. Only flag smoke test impact when you can
demonstrate a concrete dependency path.
WRONG: "This session-scoped storage fixture might affect smoke tests"
RIGHT: "Smoke test X uses fixture Y, which depends on the changed fixture Z"

Comment thread libs/net/vmspec.py
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2026

Tip

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Get current changed files and diff for position mapping
echo "=== Changed files ==="
gh pr diff 4873 --name-only

echo "=== PR head SHA ==="
gh pr view 4873 --json headRefOid -q '.headRefOid'

echo "=== Full diff (first 80 lines) ==="
gh pr diff 4873 | head -80

echo "=== Check smoke test dependencies on changed functions (virt.py, network.py) ==="
echo "-- Files with vm_console_run_commands and smoke --"
rg -l "vm_console_run_commands" tests/ --type py | xargs grep -l "pytest.mark.smoke" 2>/dev/null || echo "NONE"

echo "-- Files with get_ip_from_vm_or_virt_handler_pod and smoke --"
rg -l "get_ip_from_vm_or_virt_handler_pod" tests/ --type py | xargs grep -l "pytest.mark.smoke" 2>/dev/null || echo "NONE"

echo "-- Direct smoke marks in l2_bridge tests --"
rg -n "pytest.mark.smoke" tests/network/l2_bridge/ --type py || echo "NONE"

Length of output: 4648


🏁 Script executed:

#!/bin/bash
# Post inline review comment with Test Execution Plan on first changed line of libs/net/vmspec.py
gh api \
  --method POST \
  -H "Accept: application/vnd.github+json" \
  /repos/RedHatQE/openshift-virtualization-tests/pulls/4873/reviews \
  -f commit_id="fb3143cd0a8a55fc956bdd8ba455cc4ad0cce87f" \
  -f body="" \
  -f event="COMMENT" \
  -f "comments[][path]=libs/net/vmspec.py" \
  -F "comments[][position]=1" \
  -f "comments[][body]=## Test Execution Plan

**Run smoke tests: False**
> Verified: no \`@pytest.mark.smoke\`-marked tests import or depend on \`vm_console_run_commands\` or \`get_ip_from_vm_or_virt_handler_pod\`. No smoke marks exist in \`tests/network/l2_bridge/\`.

---

### Tests to run

| Test | Reason |
|------|--------|
| \`tests/network/l2_bridge/test_bridge_nic_hot_plug.py\` | \`IfaceNotFound\`\`VMInterfaceSpecNotFoundError\` rename; import updated here and in \`libl2bridge.py\` |
| \`tests/network/connectivity/test_pod_network.py\` | \`get_ip_from_vm_or_virt_handler_pod\` race-condition fix directly affects pod-network connectivity tests |
| \`tests/network/\` files using \`vm_console_run_commands\` | OSC 8003 regex fix in \`utilities/virt.py\` affects all console-output parsing (e.g., migration, jumbo-frame, service-mesh tests)"

Length of output: 3068



servolkov added 3 commits June 1, 2026 13:57
IfaceNotFound was a single exception incorrectly covering both spec
and status lookup failures with a misleading "Interface not found for
NAD" message. Replace each usage with the semantically correct
exception:

- VMInterfaceSpecNotFoundError for spec.domain.devices.interfaces
  lookups (libs/vm/vm.py)
- VMInterfaceStatusNotFoundError for vmi.status.interfaces lookups
  (utilities/network.py, tests/network/l2_bridge/)

This also eliminates the only libs/ -> utilities/network import,
breaking the circular dependency that prevented utilities/network.py
from importing libs/net/vmspec.

Signed-off-by: Sergei Volkov <sevolkov@redhat.com>
Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
Fedora 43 (systemd 256+) emits OSC 8003 session-tracking escape
sequences in the terminal. The existing regex in vm_console_run_commands
only stripped CSI sequences (ESC[…), leaving OSC sequences (ESC]…) in
the parsed output. This broke any caller that parses console output,
e.g. json.loads() in ip_specification tests.

Extend the regex to also strip OSC sequences terminated by BEL or ST,
per ECMA-48 specification.

Signed-off-by: Sergei Volkov <sevolkov@redhat.com>
Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
The function read vm.vmi.interfaces[0]["ipAddresses"] once without
waiting. With Fedora 43 the guest agent reports IPs slower than
Fedora 41, so ipAddresses is still None right after AgentConnected
becomes True, causing TypeError on iteration.

Delegate the VM branch to lookup_iface_status_ip which polls the VMI
with a watcher until IPs are reported.

Signed-off-by: Sergei Volkov <sevolkov@redhat.com>
Assisted-by: Claude Opus 4.6 <noreply@anthropic.com>
@servolkov servolkov force-pushed the fix/fedora-43-fix-net branch from fb3143c to 339b773 Compare June 1, 2026 11:57
@openshift-virtualization-qe-bot-3
Copy link
Copy Markdown
Contributor

Clean rebase detected — no code changes compared to previous head (fb3143c).
The following labels were preserved: verified, commented-coderabbitai[bot].

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

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 1, 2026

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

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

/retest all

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

Overlapping files

tests/network/l2_bridge/libl2bridge.py

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

/retest all

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

Overlapping files

tests/network/l2_bridge/libl2bridge.py
tests/network/l2_bridge/test_bridge_nic_hot_plug.py

Copy link
Copy Markdown
Contributor

@yossisegev yossisegev left a comment

Choose a reason for hiding this comment

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

Thank you

Comment thread libs/vm/vm.py
Copy link
Copy Markdown
Contributor

@Anatw Anatw left a comment

Choose a reason for hiding this comment

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

Thank you Sergei for making or code base better

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

/retest all

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

Overlapping files

utilities/virt.py

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

/retest all

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

Overlapping files

utilities/virt.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.