Skip to content

net: adapt test helpers to Fedora 43#4873

Merged
rnetser merged 3 commits into
RedHatQE:mainfrom
servolkov:fix/fedora-43-fix-net
Jun 16, 2026
Merged

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

Conversation

@servolkov

@servolkov servolkov commented May 15, 2026

Copy link
Copy Markdown
Contributor
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

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

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

codecov Bot commented May 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.65%. Comparing base (a2dc143) to head (339b773).
⚠️ Report is 111 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 Harness.
📢 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 added 2 commits June 1, 2026 13:57
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

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

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

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

Thank you

Comment thread libs/vm/vm.py

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

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

@openshift-virtualization-qe-bot-3

Copy link
Copy Markdown
Contributor

/retest all

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

Overlapping files

utilities/virt.py

@rnetser rnetser left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

/approve
/lgtm

@rnetser

rnetser commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

@vsibirsk @dshchedr please review

@servolkov

Copy link
Copy Markdown
Contributor Author

/check-can-merge

@servolkov

Copy link
Copy Markdown
Contributor Author

/retest all

@rnetser

rnetser commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

this pr does not affect smoke tests; overruling the pending ci

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