net, libs: Refactor random ip address helpers - #4944
Conversation
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Container Operations
Cherry-pick Operations
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
AI Features
💡 Tips
For more information, please refer to the project documentation or contact the maintainers. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
📝 WalkthroughWalkthroughThe IP utilities now return typed ChangesTyped IP interface migration
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error)
✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
e59ba4d to
39f096b
Compare
|
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=4944
echo '=== PR refs and changed files ==='
gh pr view "$pr" --repo "$repo" --json baseRefName,baseRefOid,headRefOid,files \
--jq '{base:.baseRefName,baseOid:.baseRefOid,headOid:.headRefOid,files:[.files[].path]}'
echo '=== Diff hunk headers ==='
gh pr diff "$pr" --repo "$repo" --patch | grep -E '^(diff --git|@@)' | head -160
echo '=== Modified definitions in shared libraries ==='
git diff --unified=0 "origin/$(gh pr view "$pr" --repo "$repo" --json baseRefName --jq .baseRefName)"...HEAD -- 'libs/**' |
grep -E '^[+-][[:space:]]*(def |class )' || true
echo '=== Shared helper outline and relevant implementations ==='
ast-grep outline libs/net/ip.py --items all
rg -n -A35 -B8 '^def (random_ipv4_address|random_ipv6_address|random_cidr_addresses_by_family|random_ip_addresses_by_family)\b' libs/net/ip.py || true
echo '=== Current helper callers in tests and conftest ==='
rg -n -C2 '\b(random_ipv4_address|random_ipv6_address|random_cidr_addresses_by_family|random_ip_addresses_by_family)\s*\(' tests --glob '*.py' || true
echo '=== Fixture teardown/context wrapper evidence ==='
rg -n -C3 '(`@pytest`\.fixture|`@contextmanager`|yield from|yield\b|random_ipv4_address|random_ipv6_address|random_cidr_addresses_by_family)' tests/conftest.py tests --glob 'conftest.py' || true
echo '=== Smoke and gating marker files ==='
rg -l '`@pytest`\.mark\.smoke' tests --glob '*.py' || true
printf '%s\n' '--- gating ---'
rg -l '`@pytest`\.mark\.gating' tests --glob '*.py' || true
echo '=== Direct marker/helper overlap ==='
for f in $(rg -l '`@pytest`\.mark\.(smoke|gating)' tests --glob '*.py' || true); do
if rg -q '\b(random_ipv4_address|random_ipv6_address|random_cidr_addresses_by_family)\s*\(' "$f"; then
echo "$f"
fi
done
echo '=== First changed file patch ==='
first_file=$(gh pr view "$pr" --repo "$repo" --json files --jq '.files[0].path')
printf 'first_file=%s\n' "$first_file"
gh pr diff "$pr" --repo "$repo" --patch -- "$first_file" | sed -n '1,180p'Length of output: 178114 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='RedHatQE/openshift-virtualization-tests'
pr=4944
echo '=== Changed files ==='
gh api "repos/$repo/pulls/$pr/files?per_page=100" \
--jq '.[] | "\(.filename)\t\(.status)\t+\(.additions)/-\(.deletions)"'
echo '=== Patches for changed shared files and first changed file ==='
gh api "repos/$repo/pulls/$pr/files?per_page=100" \
--jq '.[] | select(.filename == "libs/net/apimachinery.py" or (.filename | startswith("libs/net/"))) | "FILE: \(.filename)\n\(.patch // "NO PATCH")\n"' |
sed -n '1,1000p'
echo '=== Current implementation: relevant shared helpers ==='
rg -n -A28 -B6 '^def (random_ipv4_address|random_ipv6_address|random_cidr_addresses_by_family)\b' libs/net/ip.py
echo '=== Changed caller contexts only ==='
for f in \
tests/network/nmstate/test_connectivity_after_nmstate_changes.py \
tests/network/flat_overlay/conftest.py \
tests/network/kubemacpool/utils.py \
tests/network/user_defined_network/conftest.py \
tests/storage/cdi_upload/conftest.py \
tests/network/bgp/evpn/conftest.py \
tests/network/l2_bridge/bandwidth/conftest.py \
tests/network/l2_bridge/migration_stuntime/conftest.py; do
if test -f "$f"; then
echo "--- $f"
rg -n -C3 '\b(random_ipv4_address|random_ipv6_address|random_cidr_addresses_by_family)\b|`@pytest`\.mark\.(smoke|gating)' "$f" || true
fi
done
echo '=== Affected test fixtures and test names ==='
for d in \
tests/network/flat_overlay \
tests/network/kubemacpool \
tests/network/nmstate \
tests/network/user_defined_network \
tests/storage/cdi_upload \
tests/network/bgp/evpn \
tests/network/l2_bridge; do
echo "--- $d"
rg -n -C1 '^(def test_|class Test|`@pytest`\.mark\.(smoke|gating))' "$d" --glob 'test_*.py' || true
done
echo '=== Smoke test parent conftest helper references ==='
for f in $(rg -l '`@pytest`\.mark\.smoke' tests --glob '*.py'); do
d=$(dirname "$f")
while test "$d" != "."; do
if test -f "$d/conftest.py" && rg -q '\b(random_ipv4_address|random_ipv6_address|random_cidr_addresses_by_family)\b' "$d/conftest.py"; then
echo "$f -> $d/conftest.py"
fi
d=$(dirname "$d")
done
doneLength of output: 39203 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='RedHatQE/openshift-virtualization-tests'
pr=4944
head_sha=$(gh pr view "$pr" --repo "$repo" --json headRefOid --jq '.headRefOid')
body=$(cat <<'EOF'
## Test Execution Plan
**Run smoke tests: True** — Smoke-marked tests inherit `tests/conftest.py`, which calls `random_cidr_addresses_by_family` in shared VM fixtures. `tests/storage/cdi_upload/test_upload_virtctl.py` also inherits `tests/storage/cdi_upload/conftest.py::primary_udn_for_upload` → `random_ipv4_address`. The changed helpers now return IP interface objects, and `libs/net/apimachinery.py::dict_normalization_for_dataclass` serializes these objects in list values.
**Run gating tests: True** — Verified dependency paths:
- `tests/network/flat_overlay/test_flat_overlay.py` → `vmb_ingress_multi_network_policy` in `tests/network/flat_overlay/conftest.py` → `random_ipv4_address`.
- `tests/network/kubemacpool/test_kubemacpool.py` → KubeMacPool VM setup → `tests/network/kubemacpool/utils.py::vm_network_config` → `random_ipv4_address`.
- `tests/network/nmstate/test_connectivity_after_nmstate_changes.py` → local VM fixtures → `random_ipv4_address`.
- `tests/network/user_defined_network/test_user_defined_network.py` → `namespaced_layer2_user_defined_network` → `random_ipv4_address`.
**Affected tests to run**
- `-m smoke`
- `tests/storage/cdi_upload/test_upload_virtctl.py::test_virtctl_image_upload_dv_in_pudn_namespace`
- `tests/network/flat_overlay/test_flat_overlay.py` (gating)
- `tests/network/kubemacpool/test_kubemacpool.py` (gating)
- `tests/network/nmstate/test_connectivity_after_nmstate_changes.py` (gating)
- `tests/network/user_defined_network/test_user_defined_network.py` (gating)
- `tests/network/bgp/evpn/test_evpn_connectivity.py`
- `tests/network/l2_bridge/bandwidth/test_bandwidth.py`
- `tests/network/l2_bridge/migration_stuntime/test_migration_stuntime.py`
- `tests/network/l2_bridge/nad_ref_change/test_nad_ref_change.py`
- `tests/network/l2_bridge/vmi_interfaces_stability/test_interfaces_stability.py`
- `tests/network/l2_bridge/test_bridge_nic_hot_plug.py`
**Real tests (cluster required)**
Error/fix path — validate IP-interface serialization for UDN and cloud-init lists:
`pytest tests/storage/cdi_upload/test_upload_virtctl.py::test_virtctl_image_upload_dv_in_pudn_namespace tests/network/l2_bridge/bandwidth/test_bandwidth.py`
Happy path — validate bare-address consumers and non-default prefix lengths:
`pytest tests/network/flat_overlay/test_multi_network_policy.py tests/network/nmstate/test_connectivity_after_nmstate_changes.py tests/network/kubemacpool/test_kubemacpool.py`
Expected: manifests contain valid IP or CIDR strings as required, VMs configure their secondary interfaces, and connectivity assertions pass.
EOF
)
gh api --method POST "repos/$repo/pulls/$pr/comments" \
-f body="$body" \
-f commit_id="$head_sha" \
-f path='libs/net/apimachinery.py' \
-F line=1 \
-f side='RIGHT' \
--jq '{id,path,line,side}'Length of output: 3243
You are interacting with an AI system. |
|
/retest all Auto-triggered: Files in this PR were modified by merged PR #5825. Overlapping filestests/network/bgp/evpn/libevpn.py |
|
/retest all Auto-triggered: Files in this PR were modified by merged PR #5867. Overlapping filestests/conftest.py |
|
/retest tox |
|
/retest all Auto-triggered: Files in this PR were modified by merged PR #5909. Overlapping filestests/network/user_defined_network/conftest.py |
|
/retest all Auto-triggered: Files in this PR were modified by merged PR #5834. Overlapping filestests/conftest.py |
|
Change: rebase upon main and resolve conflicts, replace 32 -> |
There was a problem hiding this comment.
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/network/flat_overlay/conftest.py`:
- Line 354: Convert SPECIFIC_HOST_MASK to an integer before passing it as
subnet_length to random_ipv4_address, preferably by changing the constant
definition if all usages accept integers; otherwise convert it at this call site
while preserving any string-based CIDR usages elsewhere.
In `@tests/network/l2_bridge/test_bridge_nic_hot_plug.py`:
- Around line 109-114: Update the ipv4_address parameter type hint of
set_secondary_static_ip_address in libl2bridge.py from str to
ipaddress.IPv4Address | str, preserving the existing behavior for both string
and IPv4Address callers.
🪄 Autofix
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 Plus
Run ID: afc19e6a-86d3-4322-81a5-2b2151b6ffa9
📒 Files selected for processing (37)
libs/net/apimachinery.pylibs/net/ip.pylibs/vm/vm.pytests/conftest.pytests/network/bgp/conftest.pytests/network/bgp/evpn/conftest.pytests/network/bgp/evpn/libevpn.pytests/network/bgp/evpn/test_evpn_connectivity.pytests/network/bond/test_l2_bridge_over_bond.pytests/network/connectivity/utils.pytests/network/flat_overlay/conftest.pytests/network/flat_overlay/utils.pytests/network/general/test_cnv_tuning_regression.pytests/network/jumbo_frame/test_bond.pytests/network/jumbo_frame/test_bridge.pytests/network/jumbo_frame/utils.pytests/network/kubemacpool/utils.pytests/network/l2_bridge/conftest.pytests/network/l2_bridge/libl2bridge.pytests/network/l2_bridge/nad_ref_change/conftest.pytests/network/l2_bridge/nad_ref_change/lib_helpers.pytests/network/l2_bridge/test_bridge_nic_hot_plug.pytests/network/l2_bridge/vmi_interfaces_stability/lib_helpers.pytests/network/libs/cloudinit.pytests/network/libs/dhcpd.pytests/network/libs/localnet.pytests/network/localnet/conftest.pytests/network/localnet/ipam/conftest.pytests/network/localnet/migration_stuntime/conftest.pytests/network/localnet/nad_ref_change/conftest.pytests/network/macspoof/conftest.pytests/network/migration/test_migration.pytests/network/nmstate/test_connectivity_after_nmstate_changes.pytests/network/sriov/libsriov.pytests/network/upgrade/conftest.pytests/network/user_defined_network/conftest.pytests/storage/cdi_upload/conftest.py
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
RedHatQE/openshift-virtualization-tests-design-docs(manual)
The random_ipv4_address and random_ipv6_address helpers previously returned plain strings, requiring callers to manually append prefix lengths and making the type opaque. Returning IPv4Interface/IPv6Interface gives callers access to the structured IP data (.ip for the bare address, .network for the subnet) without string parsing, and lets subnet_length be explicit and validated. Callers that need a non-standard mask, may call `subnet_length=` with the requested cidr. IP interface objects in list values are explicitly stringified: yaml.safe_dump cannot serialize IPv4Interface/IPv6Interface directly and raises RepresenterError without this conversion. YAML serialization is handled at the dataclass boundary so EthernetDevice callers pass interface objects directly without str() conversion. Configure dacite to cast YAML strings to IP interface objects when deserializing cloud-init network data. Signed-off-by: Asia Khromov <azhivovk@redhat.com> Assisted-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
Change: change typing of constant to fit to all addresses in flat overlay setup |
|
/verified |
Test execution plan request detailsCRITICAL: You MUST post an inline review comment on the first changed line of the first file. As an expert software testing engineer, analyze all modified files in this PR and create a targeted test execution plan. Analysis Requirements:
Output rules: Your deliverable: Test Execution Plan
Use these formats:
Real test commands (MANDATORY when changes affect session/runtime code): When the affected code runs at session/collection time (conftest fixtures, pytest plugins,
Example output for a session-startup fix: Guidelines:
Hardware-Related Checks (SR-IOV, GPU, DPDK): When PR modifies fixtures for hardware-specific resources:
CRITICAL WORKFLOW COMPLETION RULES: When responding to this test execution plan request, you MUST follow these rules EXACTLY:
ABSOLUTE PROHIBITIONS (violating these creates empty/meaningless reviews):
Remember: The pull request review is visible to users. Additional comments are redundant noise. CRITICAL — Verification rules for smoke and gating decisions: |
|
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='4944'
echo '=== PR metadata and changed files ==='
gh pr view "$pr" --repo "$repo" \
--json baseRefName,baseRefOid,headRefOid,files \
--jq '{base:.baseRefName,baseOid:.baseRefOid,headOid:.headRefOid,files:[.files[].path]}'
echo '=== Diff hunk headers ==='
gh pr diff "$pr" --repo "$repo" --patch | grep -E '^(diff --git|@@)' | head -180
echo '=== Modified definitions in libs ==='
git diff --unified=0 "origin/$(gh pr view "$pr" --repo "$repo" --json baseRefName --jq -r .baseRefName)"...HEAD -- 'libs/**' |
grep -E '^[+-][[:space:]]*(def |class )' || true
echo '=== Shared-helper definitions and same-file calls ==='
ast-grep outline libs/net/ip.py --items all
rg -n -A36 -B6 '^def (random_ipv4_address|random_ipv6_address|random_cidr_addresses_by_family|random_ip_addresses_by_family)\b' libs/net/ip.py || true
rg -n -C3 '\b(random_ipv4_address|random_ipv6_address|random_cidr_addresses_by_family|random_ip_addresses_by_family)\s*\(' libs/net/ip.py || true
echo '=== Direct helper callers in tests and conftest ==='
rg -n -C2 '\b(random_ipv4_address|random_ipv6_address|random_cidr_addresses_by_family|random_ip_addresses_by_family)\s*\(' tests --glob '*.py' || true
echo '=== Fixture yield and context-wrapper evidence ==='
rg -n -C3 '(`@pytest`\.fixture|`@contextmanager`|yield from|yield\b|random_ipv4_address|random_ipv6_address|random_cidr_addresses_by_family)' \
tests/conftest.py tests --glob 'conftest.py' || true
echo '=== Smoke and gating marker files ==='
rg -l '`@pytest`\.mark\.smoke' tests --glob '*.py' || true
echo '--- gating ---'
rg -l '`@pytest`\.mark\.gating' tests --glob '*.py' || true
echo '=== Marker/helper direct overlap ==='
for f in $(rg -l '`@pytest`\.mark\.(smoke|gating)' tests --glob '*.py' || true); do
if rg -q '\b(random_ipv4_address|random_ipv6_address|random_cidr_addresses_by_family)\s*\(' "$f"; then
printf '%s\n' "$f"
fi
done
echo '=== Parent-conftest helper paths for smoke files ==='
for f in $(rg -l '`@pytest`\.mark\.smoke' tests --glob '*.py' || true); do
d=$(dirname "$f")
while test "$d" != "."; do
if test -f "$d/conftest.py" &&
rg -q '\b(random_ipv4_address|random_ipv6_address|random_cidr_addresses_by_family)\s*\(' "$d/conftest.py"; then
printf '%s -> %s/conftest.py\n' "$f" "$d"
fi
d=$(dirname "$d")
done
doneLength of output: 172586 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='RedHatQE/openshift-virtualization-tests'
pr='4944'
base=$(gh pr view "$pr" --repo "$repo" --json baseRefName --jq -r '.baseRefName')
echo '=== Changed files ==='
gh api "repos/$repo/pulls/$pr/files?per_page=100" \
--jq '.[] | "\(.filename)\t+\(.additions)/-\(.deletions)"'
echo '=== First changed patch with valid right-side additions ==='
first=$(gh api "repos/$repo/pulls/$pr/files?per_page=100" --jq -r '.[0].filename')
printf 'FIRST=%s\n' "$first"
gh pr diff "$pr" --repo "$repo" --patch -- "$first" | sed -n '1,150p'
echo '=== Changed library patches ==='
for f in libs/net/ip.py libs/net/apimachinery.py libs/vm/vm.py; do
if git diff --quiet "origin/$base"...HEAD -- "$f"; then continue; fi
echo "--- $f"
git diff --unified=12 "origin/$base"...HEAD -- "$f"
done
echo '=== Root and changed-suite fixture definitions plus consumers ==='
rg -n -C3 '\b(random_ipv4_address|random_ipv6_address|random_cidr_addresses_by_family)\s*\(|^def (vm_upgrade_a|vm_upgrade_b|primary_udn_for_upload|vmb_ingress_multi_network_policy|ipv4_localnet_address_pool|ipv6_localnet_address_pool|namespaced_layer2_user_defined_network)\b' \
tests/conftest.py tests/storage/cdi_upload/conftest.py tests/network/flat_overlay/conftest.py \
tests/network/localnet/conftest.py tests/network/kubemacpool/utils.py tests/network/user_defined_network/conftest.py \
tests/network/nmstate/test_connectivity_after_nmstate_changes.py || true
echo '=== Test functions/classes in directly changed or fixture-dependent suites ==='
for d in tests/storage/cdi_upload tests/network/flat_overlay tests/network/kubemacpool \
tests/network/nmstate tests/network/user_defined_network tests/network/localnet \
tests/network/bgp/evpn tests/network/l2_bridge tests/network/sriov tests/network/upgrade; do
echo "--- $d"
rg -n -C1 '^(`@pytest`\.mark\.(smoke|gating)|class Test|def test_)' "$d" --glob 'test_*.py' || true
done
echo '=== Consumers of changed named fixtures ==='
rg -n -C2 '\b(vm_upgrade_a|vm_upgrade_b|primary_udn_for_upload|vmb_ingress_multi_network_policy|ipv4_localnet_address_pool|ipv6_localnet_address_pool|namespaced_layer2_user_defined_network)\b' \
tests --glob '*.py' || true
echo '=== Gating test fixture usage ==='
for f in tests/network/flat_overlay/test_flat_overlay.py tests/network/kubemacpool/test_kubemacpool.py \
tests/network/nmstate/test_connectivity_after_nmstate_changes.py tests/network/user_defined_network/test_user_defined_network.py \
tests/network/localnet/test_default_bridge.py tests/storage/cdi_upload/test_upload_virtctl.py; do
echo "--- $f"
rg -n -C2 '`@pytest`\.mark\.(smoke|gating)|\b(vmb_ingress_multi_network_policy|vm_network_config|random_ipv4_address|namespaced_layer2_user_defined_network|ipv4_localnet_address_pool|ipv6_localnet_address_pool|primary_udn_for_upload)\b' "$f" || true
doneLength of output: 3291 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='RedHatQE/openshift-virtualization-tests'
pr='4944'
base=$(gh pr view "$pr" --repo "$repo" --json baseRefName --jq -r '.baseRefName')
echo '=== Changed files ==='
gh api "repos/$repo/pulls/$pr/files?per_page=100" \
--jq '.[] | "\(.filename)\t+\(.additions)/-\(.deletions)"'
echo '=== First changed file and patch ==='
gh api "repos/$repo/pulls/$pr/files?per_page=100" \
--jq '.[0] | "FIRST=\(.filename)\n\(.patch // "PATCH_UNAVAILABLE")"'
echo '=== Changed library patches ==='
for f in libs/net/ip.py libs/net/apimachinery.py libs/vm/vm.py; do
if git diff --quiet "origin/$base"...HEAD -- "$f"; then continue; fi
echo "--- $f"
git diff --unified=12 "origin/$base"...HEAD -- "$f"
done
echo '=== Root and changed-suite fixture definitions plus helper calls ==='
rg -n -C3 '\b(random_ipv4_address|random_ipv6_address|random_cidr_addresses_by_family)\s*\(|^def (vm_upgrade_a|vm_upgrade_b|primary_udn_for_upload|vmb_ingress_multi_network_policy|ipv4_localnet_address_pool|ipv6_localnet_address_pool|namespaced_layer2_user_defined_network)\b' \
tests/conftest.py tests/storage/cdi_upload/conftest.py tests/network/flat_overlay/conftest.py \
tests/network/localnet/conftest.py tests/network/kubemacpool/utils.py tests/network/user_defined_network/conftest.py \
tests/network/nmstate/test_connectivity_after_nmstate_changes.py || true
echo '=== Test functions/classes in affected suites ==='
for d in tests/storage/cdi_upload tests/network/flat_overlay tests/network/kubemacpool \
tests/network/nmstate tests/network/user_defined_network tests/network/localnet \
tests/network/bgp/evpn tests/network/l2_bridge tests/network/sriov tests/network/upgrade; do
echo "--- $d"
rg -n -C1 '^(`@pytest`\.mark\.(smoke|gating)|class Test|def test_)' "$d" --glob 'test_*.py' || true
done
echo '=== Consumers of changed named fixtures ==='
rg -n -C2 '\b(vm_upgrade_a|vm_upgrade_b|primary_udn_for_upload|vmb_ingress_multi_network_policy|ipv4_localnet_address_pool|ipv6_localnet_address_pool|namespaced_layer2_user_defined_network)\b' \
tests --glob '*.py' || true
echo '=== Relevant gating-test fixture usage ==='
for f in tests/network/flat_overlay/test_flat_overlay.py tests/network/kubemacpool/test_kubemacpool.py \
tests/network/nmstate/test_connectivity_after_nmstate_changes.py tests/network/user_defined_network/test_user_defined_network.py \
tests/network/localnet/test_default_bridge.py tests/storage/cdi_upload/test_upload_virtctl.py; do
echo "--- $f"
rg -n -C2 '`@pytest`\.mark\.(smoke|gating)|\b(vmb_ingress_multi_network_policy|vm_network_config|random_ipv4_address|namespaced_layer2_user_defined_network|ipv4_localnet_address_pool|ipv6_localnet_address_pool|primary_udn_for_upload)\b' "$f" || true
doneLength of output: 3192 🏁 Script executed: #!/bin/bash
set -euo pipefail
gh api 'repos/RedHatQE/openshift-virtualization-tests/pulls/4944/files?per_page=100' \
--jq '.[] | {filename, additions, deletions, patch}'Length of output: 57185 🏁 Script executed: #!/bin/bash
set -euo pipefail
repo='RedHatQE/openshift-virtualization-tests'
pr='4944'
head_sha=$(gh pr view "$pr" --repo "$repo" --json headRefOid --jq -r '.headRefOid')
body=$(cat <<'EOF'
## Test Execution Plan
**Run smoke tests: True** — `tests/storage/cdi_upload/test_upload_virtctl.py` → `tests/storage/cdi_upload/conftest.py::primary_udn_for_upload` → `random_ipv4_address`. The test also inherits `tests/conftest.py`, where upgrade VM fixtures call `random_cidr_addresses_by_family`. The helpers now return interface objects, and `dict_normalization_for_dataclass` serializes interface objects in address lists.
**Run gating tests: True** — Verified dependency paths:
- `tests/network/flat_overlay/test_flat_overlay.py` → `tests/network/flat_overlay/conftest.py::vmb_ingress_multi_network_policy` → `random_ipv4_address(subnet_length=32)`.
- `tests/network/kubemacpool/test_kubemacpool.py` → KubeMacPool VM setup → `tests/network/kubemacpool/utils.py::vm_network_config` → `random_ipv4_address(...).ip`.
- `tests/network/nmstate/test_connectivity_after_nmstate_changes.py` → local VM fixtures → `random_ipv4_address`.
- `tests/network/user_defined_network/test_user_defined_network.py` → `tests/network/user_defined_network/conftest.py::namespaced_layer2_user_defined_network` → `random_ipv4_address`.
**Affected tests to run**
- `tests/storage/cdi_upload/test_upload_virtctl.py::test_virtctl_image_upload_dv_in_pudn_namespace` (smoke, gating)
- `tests/network/flat_overlay/test_flat_overlay.py` (gating)
- `tests/network/kubemacpool/test_kubemacpool.py` (gating)
- `tests/network/nmstate/test_connectivity_after_nmstate_changes.py` (gating)
- `tests/network/user_defined_network/test_user_defined_network.py` (gating)
- `tests/network/localnet/test_default_bridge.py` (gating)
- `tests/network/bgp/evpn/test_evpn_connectivity.py`
- `tests/network/l2_bridge/bandwidth/test_bandwidth.py`
- `tests/network/l2_bridge/migration_stuntime/test_migration_stuntime.py`
- `tests/network/l2_bridge/nad_ref_change/test_nad_ref_change.py`
- `tests/network/l2_bridge/vmi_interfaces_stability/test_interfaces_stability.py`
- `tests/network/l2_bridge/test_bridge_nic_hot_plug.py`
- `-m smoke`
- `-m gating`
**Real tests (cluster required)**
Error/fix path — verify IP-interface serialization for cloud-init address lists and UDN subnets:
`pytest tests/storage/cdi_upload/test_upload_virtctl.py::test_virtctl_image_upload_dv_in_pudn_namespace tests/network/l2_bridge/bandwidth/test_bandwidth.py`
Happy path — verify bare-address consumers and the `/32` prefix path:
`pytest tests/network/flat_overlay/test_flat_overlay.py tests/network/nmstate/test_connectivity_after_nmstate_changes.py tests/network/kubemacpool/test_kubemacpool.py`
Expected: manifests contain valid IP or CIDR values, VM secondary interfaces configure successfully, and connectivity assertions pass.
EOF
)
gh api --method POST "repos/$repo/pulls/$pr/comments" \
-f body="$body" \
-f commit_id="$head_sha" \
-f path='libs/net/apimachinery.py' \
-F line=1 \
-f side='RIGHT' \
--jq '{id,path,line,side}'Length of output: 3427 🏁 Script executed: #!/bin/bash
set -euo pipefail
gh api 'repos/RedHatQE/openshift-virtualization-tests/pulls/4944' \
--jq '.head.sha'Length of output: 297 🏁 Script executed: #!/bin/bash
set -euo pipefail
body=$(cat <<'EOF'
## Test Execution Plan
**Run smoke tests: True** — `tests/storage/cdi_upload/test_upload_virtctl.py` → `tests/storage/cdi_upload/conftest.py::primary_udn_for_upload` → `random_ipv4_address`. The test also inherits `tests/conftest.py`, where upgrade VM fixtures call `random_cidr_addresses_by_family`. The helpers now return interface objects, and `dict_normalization_for_dataclass` serializes interface objects in address lists.
**Run gating tests: True** — Verified dependency paths:
- `tests/network/flat_overlay/test_flat_overlay.py` → `tests/network/flat_overlay/conftest.py::vmb_ingress_multi_network_policy` → `random_ipv4_address(subnet_length=32)`.
- `tests/network/kubemacpool/test_kubemacpool.py` → KubeMacPool VM setup → `tests/network/kubemacpool/utils.py::vm_network_config` → `random_ipv4_address(...).ip`.
- `tests/network/nmstate/test_connectivity_after_nmstate_changes.py` → local VM fixtures → `random_ipv4_address`.
- `tests/network/user_defined_network/test_user_defined_network.py` → `tests/network/user_defined_network/conftest.py::namespaced_layer2_user_defined_network` → `random_ipv4_address`.
**Affected tests to run**
- `tests/storage/cdi_upload/test_upload_virtctl.py::test_virtctl_image_upload_dv_in_pudn_namespace` (smoke, gating)
- `tests/network/flat_overlay/test_flat_overlay.py` (gating)
- `tests/network/kubemacpool/test_kubemacpool.py` (gating)
- `tests/network/nmstate/test_connectivity_after_nmstate_changes.py` (gating)
- `tests/network/user_defined_network/test_user_defined_network.py` (gating)
- `tests/network/localnet/test_default_bridge.py` (gating)
- `tests/network/bgp/evpn/test_evpn_connectivity.py`
- `tests/network/l2_bridge/bandwidth/test_bandwidth.py`
- `tests/network/l2_bridge/migration_stuntime/test_migration_stuntime.py`
- `tests/network/l2_bridge/nad_ref_change/test_nad_ref_change.py`
- `tests/network/l2_bridge/vmi_interfaces_stability/test_interfaces_stability.py`
- `tests/network/l2_bridge/test_bridge_nic_hot_plug.py`
- `-m smoke`
- `-m gating`
**Real tests (cluster required)**
Error/fix path — verify IP-interface serialization for cloud-init address lists and UDN subnets:
`pytest tests/storage/cdi_upload/test_upload_virtctl.py::test_virtctl_image_upload_dv_in_pudn_namespace tests/network/l2_bridge/bandwidth/test_bandwidth.py`
Happy path — verify bare-address consumers and the `/32` prefix path:
`pytest tests/network/flat_overlay/test_flat_overlay.py tests/network/nmstate/test_connectivity_after_nmstate_changes.py tests/network/kubemacpool/test_kubemacpool.py`
Expected: manifests contain valid IP or CIDR values, VM secondary interfaces configure successfully, and connectivity assertions pass.
EOF
)
gh api --method POST 'repos/RedHatQE/openshift-virtualization-tests/pulls/4944/comments' \
-f body="$body" \
-f commit_id='bca7853aebee66873f0de777ff4191a712100991' \
-f path='libs/net/apimachinery.py' \
-F line=1 \
-f side='RIGHT'Length of output: 8379 You are interacting with an AI system. |
|
/rerun-smoke |
|
/retest all Auto-triggered: Files in this PR were modified by merged PR #5898. Overlapping filestests/conftest.py |
|
/retest all Auto-triggered: Files in this PR were modified by merged PR #5922. Overlapping filestests/conftest.py |
|
@EdDev Please revisit |
|
/retest all Auto-triggered: Files in this PR were modified by merged PR #5672. Overlapping filestests/conftest.py |
|
We should keep in mind this PR - #5798 - once merged we'll need to add it to the current PR. |
|
@EdDev Please revisit |
|
/retest all Auto-triggered: Files in this PR were modified by merged PR #5970. Overlapping filestests/network/l2_bridge/libl2bridge.py |
|
/retest all Auto-triggered: Files in this PR were modified by merged PR #5674. Overlapping filestests/conftest.py |
What this PR does / why we need it:
The
random_ipv4_addressandrandom_ipv6_addresshelpers previously returned plain strings, requiring callers to manually append prefix lengths and making the type opaque.Returning IPv4Interface/IPv6Interface gives callers access to the structured IP data (.ip for the bare address, .network for the subnet) without string parsing, and lets subnet_length be explicit and validated.
Callers that need a non-standard mask, may call
subnet_length=with the requested cidr.Which issue(s) this PR fixes: -
Special notes for reviewer:
Reuested follow-up PR by approvers
jira-ticket: -
Summary by CodeRabbit
New Features
Bug Fixes