Skip to content

net, localnet: Adjust tests to IPv6#3974

Open
azhivovk wants to merge 1 commit intoRedHatQE:mainfrom
azhivovk:adjust_ipv6_localnet
Open

net, localnet: Adjust tests to IPv6#3974
azhivovk wants to merge 1 commit intoRedHatQE:mainfrom
azhivovk:adjust_ipv6_localnet

Conversation

@azhivovk
Copy link
Contributor

@azhivovk azhivovk commented Feb 25, 2026

Localnet tests need adjustments to run on
IPv6 single stack clusters:

  • Add random IPv6 address to vlan and non-vlan interface on tested VM
  • Run extra iperf3 server to test IPv6 tcp connectivity

test_vmi_reports_ip_on_secondary_interface_without_vlan test was also adjusted but quarantined due to a bug in which the requested assigned IP addresses on the tested VM are not visible in VMI status

jira-ticket: https://issues.redhat.com/browse/CNV-78445

Summary by CodeRabbit

  • Tests

    • Improved test coverage for dual-stack (IPv4/IPv6) local network connectivity.
    • Enhanced testing across multiple IP addresses during VM migrations and interface state changes.
    • Expanded jumbo frame testing to support multi-address scenarios.
  • Refactor

    • Restructured test infrastructure to support simultaneous IPv4 and IPv6 configurations.
    • Added utilities for dynamic address handling and header size calculations.

@openshift-virtualization-qe-bot-5

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, conflict labels
  5. Verified: PR must be marked as verified (if verification is enabled)

📊 Review Process

Approvers and Reviewers

Approvers:

  • EdDev

Reviewers:

  • Anatw
  • EdDev
  • azhivovk
  • servolkov
  • yossisegev
Available Labels
  • hold
  • verified
  • wip
  • lgtm
  • approve

💡 Tips

  • WIP Status: Use /wip when your PR is not ready for review
  • Verification: The verified label is automatically removed on each new commit
  • 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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 25, 2026

📝 Walkthrough

Walkthrough

This PR introduces dual-stack IPv4/IPv6 support to network localnet tests by adding IP utility functions, refactoring fixture signatures to support IPv6 address pools and cluster flags, and updating test logic to validate connectivity and configuration per destination address rather than per VM.

Changes

Cohort / File(s) Summary
IP utilities
tests/network/libs/ip.py
Added ip_header_size() function that returns appropriate header size based on IP version (4 or 6).
Fixture infrastructure
tests/network/localnet/conftest.py, tests/network/localnet/liblocalnet.py
Refactored fixture scaffolding to support dual-stack addressing: renamed PRIMARY_INTERFACE_NAMEFIRST_IFACE_NAME, introduced SECOND_IFACE_NAME, added IPv6 address pool support, updated 7+ fixture signatures to include IPv6 pool and cluster support flags, replaced legacy server/client fixtures with ovs_bridge_localnet_active_connections, added random_ip_addresses() utility.
Default bridge tests
tests/network/localnet/test_default_bridge.py
Updated test functions to use lookup_iface_status (replacing lookup_iface_status_ip), introduced per-address connectivity validation via subtests, added filter_link_local_addresses filtering, enabled xfail marker for quarantined scenario.
Jumbo frame tests
tests/network/localnet/test_jumbo_frames.py
Refactored to iterate over all destination addresses with per-address MTU/header-size calculations using ip_header_size(), replaced single connectivity check with per-address jumbo ping and iperf3 tests using client_server_active_connection, removed IPv4-only assumptions.
OVS bridge tests
tests/network/localnet/test_ovs_bridge.py
Updated test fixtures to use ovs_bridge_localnet_active_connections, added per-address TCP connectivity assertions within subtests, replaced direct server/client pairs with new active connection fixtures that handle multiple destination IPs.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Rationale: Multiple heterogeneous changes across 6 files with substantial structural refactoring (fixture signatures, constants renamed, behavioral logic rewritten). Key concerns include: (1) fixture signature proliferation with new parameters across conftest.py requiring validation of all propagations, (2) per-address test logic patterns introduced across 3 test files demanding review of subtest correctness and IP family handling, (3) removal of legacy fixtures requiring confirmation of all callsites updated, (4) new utility functions (ip_header_size, random_ip_addresses, client_server_active_connection) requiring validation of logic and usage patterns.

Possibly related PRs

  • PR #2119: Adds TCP_HEADER_SIZE and other header constants to tests/network/libs/ip.py that are consumed by the new ip_header_size() function.
  • PR #3273: Adds random_ipv6_address and IPv6 utilities to tests/network/libs/ip.py, complementing the dual-stack utilities introduced here.
  • PR #2370: Modifies tests/network/localnet/conftest.py fixture scaffolding for multi-network handling, foundational to this PR's fixture signature extensions.

Suggested labels

size/L, branch-main

Suggested reviewers

  • dshchedr
  • rnetser
  • vsibirsk
  • yossisegev
  • RoniKishner
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.04% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description covers the core objectives (IPv6 adjustments, dual-stack addressing, iperf3 changes, test quarantine) and includes the Jira ticket, but lacks detailed explanations of implementation strategies and testing validation.
Title check ✅ Passed The title 'net, localnet: Adjust tests to IPv6' directly and clearly summarizes the main change: adapting network tests to support IPv6, which aligns with all the substantial modifications across test fixtures and test files.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

Copy link
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: 5

🤖 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/network/libs/ip.py`:
- Around line 98-99: Add a Google-style docstring to the public helper function
ip_header_size that describes accepted input types (ipaddress.IPv4Address or
ipaddress.IPv6Address), explains behavior (returns IPV4_HEADER_SIZE for IPv4 and
IPV6_HEADER_SIZE for IPv6), and states the return units (bytes) and type (int);
place the docstring immediately under the def ip_header_size(...) line and
include brief examples or edge-case notes if needed (e.g., what happens for
unexpected types).

In `@tests/network/localnet/liblocalnet.py`:
- Around line 35-47: The function random_ip_addresses currently uses boolean
flags (ipv4_supported_cluster, ipv6_supported_cluster) which triggers Ruff
FBT001 and hides intent; change the signature to accept a clear collection of
supported protocols (e.g., supported_protocols: Iterable[str] or an Enum like
Protocol.{IPv4,IPv6}) instead of boolean parameters, update the body to check
membership (e.g., if "ipv4" in supported_protocols:
addresses.append(next(ipv4_localnet_address_pool))) and update all callers to
pass the protocol list/enum; also add a Google-format docstring to
random_ip_addresses that documents the generator side effect (it advances
ipv4_localnet_address_pool and ipv6_localnet_address_pool via next()) and
precise return value, and tighten the type hints for the generators to
Generator[str, None, None].

In `@tests/network/localnet/test_default_bridge.py`:
- Around line 46-56: The loop over destinations can be vacuous if
filter_link_local_addresses returns no non-link-local addresses; modify the test
in tests/network/localnet/test_default_bridge.py to assert there is at least one
address before entering the for loop (use the result of
filter_link_local_addresses(ip_addresses=iface.ipAddresses) and fail the test if
empty), then proceed with the existing per-address subtests using
client_server_active_connection with migrated_localnet_vm, base_localnet_vm,
LOCALNET_BR_EX_INTERFACE, port 8888 and ip_family=dst_ip.version; reference
lookup_iface_status and is_tcp_connection unchanged.
- Around line 78-82: The test compares ordered lists reported_ips and
expected_ips but address ordering across families can vary; update the assertion
to compare unordered sets instead (e.g., convert reported_ips and expected_ips
into sets of canonical values such as their string representations or
ip_interface objects) so the quarantined dual-stack check passes regardless of
IPv4/IPv6 ordering; locate the code building reported_ips via
filter_link_local_addresses(ip_interface(...)) and the expected_ips from
vm_localnet_1_no_vlan_iface_addresses and change the final assert to compare
set(reported_ips) == set(expected_ips).

In `@tests/network/localnet/test_ovs_bridge.py`:
- Around line 47-55: The test loop over filter_link_local_addresses can be
vacuously skipped if it returns an empty list, causing false positives; before
iterating, capture the filtered list (e.g., dst_ips =
list(filter_link_local_addresses(ip_addresses=iface.ipAddresses)) ) and assert
or fail the test if dst_ips is empty (use the test harness failure method in
this file, e.g., self.fail or an assert), otherwise iterate over dst_ips in the
existing for-loop that calls subtests.test and client_server_active_connection
(referencing filter_link_local_addresses, iface.ipAddresses, subtests.test,
client_server_active_connection, and LOCALNET_OVS_BRIDGE_INTERFACE).

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cff796e and a14f418.

📒 Files selected for processing (6)
  • tests/network/libs/ip.py
  • tests/network/localnet/conftest.py
  • tests/network/localnet/liblocalnet.py
  • tests/network/localnet/test_default_bridge.py
  • tests/network/localnet/test_jumbo_frames.py
  • tests/network/localnet/test_ovs_bridge.py

@azhivovk
Copy link
Contributor Author

azhivovk commented Mar 2, 2026

/wip

@openshift-virtualization-qe-bot-2 openshift-virtualization-qe-bot-2 changed the title net, localnet: Adjust tests to IPv6 WIP: net, localnet: Adjust tests to IPv6 Mar 2, 2026
Localnet tests need adjustments to run on
IPv6 single stack clusters:
- Add random IPv6 address to vlan and non-vlan
  interface on tested VM
- Run extra iperf3 server to test IPv6 tcp connectivity

test_vmi_reports_ip_on_secondary_interface_without_vlan test was
also adjusted but quarantined due to a bug in which the requested
assigned IP addresses on the tested VM are not visible in VMI
status

Signed-off-by: Asia Khromov <azhivovk@redhat.com>
@azhivovk
Copy link
Contributor Author

azhivovk commented Mar 2, 2026

Changes:

  • Rename constants
  • Add iperf server constants
  • Refactor client-server context manager usage in fixtures
  • Remove unused helpers
  • Edit subtest messaged

@azhivovk
Copy link
Contributor Author

azhivovk commented Mar 2, 2026

/wip cancel

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants