Skip to content

make client in migration tests mandatory#4994

Open
vsibirsk wants to merge 1 commit into
RedHatQE:mainfrom
vsibirsk:vk-migration-client
Open

make client in migration tests mandatory#4994
vsibirsk wants to merge 1 commit into
RedHatQE:mainfrom
vsibirsk:vk-migration-client

Conversation

@vsibirsk
Copy link
Copy Markdown
Collaborator

@vsibirsk vsibirsk commented May 25, 2026

What this PR does / why we need it:

modified migrate_vm_and_verify func client arg to be mandatory
and update relevant calls in functions and tests

Which issue(s) this PR fixes:

Aligns migration tests with default client deprecation in python-wrapper repo
https://redhat.atlassian.net/browse/CNV-68519

Special notes for reviewer:
jira-ticket:

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

Summary by CodeRabbit

  • Tests

    • Updated VM migration test infrastructure to require explicit admin client credentials for all migration operations.
    • Standardized migration verification calls across 50+ test files to pass admin client explicitly.
  • Refactor

    • Modified core migration verification utility to enforce explicit cluster admin client parameter, removing optional client behavior.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 25, 2026

Warning

Review limit reached

@vsibirsk, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 3 minutes and 7 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: f3b51de8-b994-4e7d-a2d2-104d7190523f

📥 Commits

Reviewing files that changed from the base of the PR and between 7376869 and 0efdd7b.

📒 Files selected for processing (55)
  • tests/infrastructure/instance_types/supported_os/test_rhel_os.py
  • tests/infrastructure/instance_types/test_cpu_memory_hotplug_instancetype.py
  • tests/infrastructure/numa/conftest.py
  • tests/network/bgp/evpn/test_evpn_connectivity.py
  • tests/network/bgp/test_bgp_connectivity.py
  • tests/network/flat_overlay/conftest.py
  • tests/network/l2_bridge/rhel9_rhel10_cluster/test_connectivity.py
  • tests/network/l2_bridge/vmi_interfaces_stability/test_interfaces_stability.py
  • tests/network/libs/stuntime.py
  • tests/network/localnet/conftest.py
  • tests/network/localnet/test_default_bridge.py
  • tests/network/localnet/test_ovs_bridge.py
  • tests/network/migration/test_masquerade_connectivity_after_migration.py
  • tests/network/migration/test_migration.py
  • tests/network/service_mesh/test_service_mesh.py
  • tests/network/sriov/test_sriov.py
  • tests/network/user_defined_network/ip_specification/test_ip_specification.py
  • tests/network/user_defined_network/test_user_defined_network.py
  • tests/network/user_defined_network/test_user_defined_network_passt.py
  • tests/storage/cross_cluster_live_migration/test_cclm.py
  • tests/storage/cross_cluster_live_migration/utils.py
  • tests/storage/online_resize/test_online_resize.py
  • tests/storage/storage_migration/test_storage_class_migration.py
  • tests/storage/test_hotplug.py
  • tests/storage/upgrade/test_upgrade_storage.py
  • tests/virt/cluster/aaq/conftest.py
  • tests/virt/cluster/aaq/test_aaq_allocation_methods.py
  • tests/virt/cluster/aaq/test_arq.py
  • tests/virt/cluster/common_templates/centos/test_centos_os_support.py
  • tests/virt/cluster/common_templates/fedora/test_fedora_os_support.py
  • tests/virt/cluster/common_templates/rhel/test_rhel_os_support.py
  • tests/virt/cluster/common_templates/rhel/test_rhel_tablet_device.py
  • tests/virt/cluster/common_templates/windows/test_windows_os_support.py
  • tests/virt/cluster/longevity_tests/test_multi_vm_multi_migration.py
  • tests/virt/cluster/longevity_tests/utils.py
  • tests/virt/cluster/migration_and_maintenance/test_migration_policy.py
  • tests/virt/cluster/sysprep/test_sysprep.py
  • tests/virt/cluster/vm_cloning/test_vm_cloning.py
  • tests/virt/cluster/vm_lifecycle/test_vm_run_strategy.py
  • tests/virt/node/general/test_machinetype.py
  • tests/virt/node/general/test_windows_vtpm_bitlocker.py
  • tests/virt/node/general/test_wsl2.py
  • tests/virt/node/high_performance_vm/test_isolate_emulator_thread.py
  • tests/virt/node/hotplug/test_cpu_memory_hotplug.py
  • tests/virt/node/log_verbosity/test_log_virt_launcher.py
  • tests/virt/node/migration_and_maintenance/test_odf_vm_migration.py
  • tests/virt/node/migration_and_maintenance/test_post_copy_migration.py
  • tests/virt/node/migration_and_maintenance/test_vm_disk_load_with_migration.py
  • tests/virt/node/migration_and_maintenance/test_vm_memory_load_with_migration.py
  • tests/virt/node/readonly_disk/test_vm_with_windows_guest_tools.py
  • tests/virt/node/workload_density/test_kernel_samepage_merging.py
  • tests/virt/node/workload_density/test_swap.py
  • tests/virt/upgrade/test_upgrade_virt.py
  • tests/virt/utils.py
  • utilities/virt.py
📝 Walkthrough

Walkthrough

This PR updates the migrate_vm_and_verify function to require an explicit client: DynamicClient parameter instead of accepting an optional defaulted argument. The change propagates systematically through all test utilities, fixtures, and test methods that invoke VM migration, updating 84 locations across the test and utility codebase.

Changes

Migration client requirement propagation

Layer / File(s) Summary
Core API contract change
utilities/virt.py
migrate_vm_and_verify signature updated to require client: DynamicClient instead of optional DynamicClient | None. Docstring clarified: only Cluster Admin can migrate; Namespace Admin cannot unless granted kubevirt.io:migrate RoleBinding.
Helper and utility function signatures
tests/virt/utils.py, tests/storage/cross_cluster_live_migration/utils.py, tests/virt/cluster/longevity_tests/utils.py, tests/virt/cluster/vm_lifecycle/test_vm_run_strategy.py
migrate_and_verify_multi_vms, verify_compute_live_migration_after_cclm, run_migration_loop, and migrate_validate_run_strategy_vm updated to accept and forward client parameter to migrate_vm_and_verify.
Fixture parameter propagation
tests/infrastructure/numa/conftest.py, tests/network/flat_overlay/conftest.py, tests/network/localnet/conftest.py, tests/virt/node/general/test_windows_vtpm_bitlocker.py, tests/virt/cluster/sysprep/test_sysprep.py, tests/virt/node/general/test_wsl2.py, tests/virt/node/log_verbosity/test_log_virt_launcher.py, tests/virt/node/migration_and_maintenance/test_vm_memory_load_with_migration.py, tests/virt/node/readonly_disk/test_vm_with_windows_guest_tools.py, tests/virt/node/workload_density/test_kernel_samepage_merging.py, tests/virt/cluster/aaq/conftest.py
Pytest fixtures across test domains updated to accept admin_client dependency and pass it through migrate_vm_and_verify invocations.
Migration-specific fixtures
tests/network/migration/test_masquerade_connectivity_after_migration.py, tests/network/migration/test_migration.py, tests/virt/cluster/migration_and_maintenance/test_migration_policy.py
Fixtures (migrated_vmi, migrated_vmb_*, vm_migrated_with_policy, vm_re_migrated_*) updated to depend on and propagate admin_client through migration verification.
Infrastructure and instance type tests
tests/infrastructure/instance_types/supported_os/test_rhel_os.py, tests/infrastructure/instance_types/test_cpu_memory_hotplug_instancetype.py
RHEL and CPU/memory hotplug tests add admin_client parameter and pass it to migration verification.
Network connectivity and EVPN tests
tests/network/bgp/evpn/test_evpn_connectivity.py, tests/network/bgp/test_bgp_connectivity.py, tests/network/l2_bridge/rhel9_rhel10_cluster/test_connectivity.py, tests/network/l2_bridge/vmi_interfaces_stability/test_interfaces_stability.py, tests/network/localnet/test_default_bridge.py, tests/network/localnet/test_ovs_bridge.py, tests/network/service_mesh/test_service_mesh.py, tests/network/sriov/test_sriov.py, tests/network/user_defined_network/ip_specification/test_ip_specification.py, tests/network/user_defined_network/test_user_defined_network.py, tests/network/user_defined_network/test_user_defined_network_passt.py
Network tests spanning BGP, EVPN, L2 bridge, localnet, UDN, SRIOV, and passt add admin_client and update migration calls to ensure connectivity preservation is verified with proper cluster context.
Localnet migration documentation
tests/network/localnet/conftest.py, tests/network/localnet/migration_stuntime/libstuntime.py
Localnet fixture and docstring example updated to demonstrate mandatory client parameter in migration flows.
Storage, hotplug, and upgrade tests
tests/storage/cross_cluster_live_migration/test_cclm.py, tests/storage/online_resize/test_online_resize.py, tests/storage/storage_migration/test_storage_class_migration.py, tests/storage/test_hotplug.py, tests/storage/upgrade/test_upgrade_storage.py
Storage migration, online resize, hotplug, and upgrade tests add admin_client parameter and propagate it through migration verification, covering A→B migrations, volume hotplug, and Windows VTPM scenarios.
Cluster virtualization tests
tests/virt/cluster/aaq/test_aaq_allocation_methods.py, tests/virt/cluster/aaq/test_arq.py, tests/virt/cluster/common_templates/centos/test_centos_os_support.py, tests/virt/cluster/common_templates/fedora/test_fedora_os_support.py, tests/virt/cluster/common_templates/rhel/test_rhel_os_support.py, tests/virt/cluster/common_templates/rhel/test_rhel_tablet_device.py, tests/virt/cluster/common_templates/windows/test_windows_os_support.py, tests/virt/cluster/longevity_tests/test_multi_vm_multi_migration.py, tests/virt/cluster/vm_cloning/test_vm_cloning.py
AAQ, common template OS support (CentOS, Fedora, RHEL, Windows), migration policy, VM cloning, and longevity migration-storm tests add admin_client and update migration verification calls.
Node-level virtualization tests
tests/virt/node/general/test_machinetype.py, tests/virt/node/high_performance_vm/test_isolate_emulator_thread.py, tests/virt/node/hotplug/test_cpu_memory_hotplug.py, tests/virt/node/migration_and_maintenance/test_odf_vm_migration.py, tests/virt/node/migration_and_maintenance/test_post_copy_migration.py, tests/virt/node/migration_and_maintenance/test_vm_disk_load_with_migration.py, tests/virt/node/workload_density/test_swap.py
Node-scoped tests covering machine type, emulator thread isolation, hotplug, ODF, post-copy migration, disk/memory load, and swap add admin_client and propagate it through migration calls, ensuring node-level VM migrations operate with proper authorization context.
Upgrade and post-copy migration tests
tests/virt/upgrade/test_upgrade_virt.py
Upgrade tests covering both before and after-upgrade migration scenarios (test_migration_before_upgrade, test_migration_after_upgrade, test_vm_post_copy_migration_before_upgrade, test_vm_post_copy_migration_after_upgrade) add admin_client parameter and update all migration verification calls to include explicit client context for backward-compatible upgrade flows.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

The changes are highly repetitive and follow a consistent mechanical pattern: add admin_client to function/test signatures and pass it to migrate_vm_and_verify calls. However, the scope is broad (84 locations across multiple test domains), so review effort includes verification that the pattern was applied consistently and completely across all affected code paths, with particular attention to fixture dependency chains and any special cases in helper functions.

Suggested reviewers

  • hmeir
  • OhadRevah
  • rlobillo
  • dshchedr
  • kbidarkar
  • rnetser
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: making the client argument mandatory in migration tests. It is directly related to the changeset's primary objective.
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 PR only modifies existing test function signatures to add admin_client parameter; no new test files or new test functions are added, satisfying the check's passing condition.
Description check ✅ Passed The PR description covers all required sections with clear explanations of changes, related issues, and jira ticket references.

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

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

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4994      +/-   ##
==========================================
- 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.

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

  • EdDev
  • dshchedr
  • jpeimer
  • myakove
  • rnetser
  • vsibirsk

Reviewers:

  • Ahmad-Hafe
  • Anatw
  • EdDev
  • RoniKishner
  • SamAlber
  • acinko-rh
  • akri3i
  • azhivovk
  • dalia-frank
  • dshchedr
  • ema-aka-young
  • frenzyfriday
  • geetikakay
  • hmeir
  • josemacassan
  • jpeimer
  • kgoldbla
  • kshvaika
  • mijankow
  • nirdothan
  • orelmisan
  • rlobillo
  • 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.

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

/retest all

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

Overlapping files

tests/network/l2_bridge/vmi_interfaces_stability/test_interfaces_stability.py

 - modified migrate_vm_and_verify func client arg to be mandatory
 - added type hints for affected tests/fixtures/functions
 - moved setup fixtures to @pytest.mark.usefixtures

Signed-off-by: vsibirsk <vsibirsk@redhat.com>
@jpeimer
Copy link
Copy Markdown
Contributor

jpeimer commented Jun 1, 2026

/approve
/lgtm

@geetikakay
Copy link
Copy Markdown
Contributor

/lgtm

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

/retest all

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

Overlapping files

tests/network/flat_overlay/conftest.py

from utilities.network import assert_ping_successful, network_nad
from utilities.virt import migrate_vm_and_verify

if TYPE_CHECKING:
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.

why TYPE_CHECKING is needed here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

because DynamicClient and VirtualMachineForTests are used only for typehints (no need to import them in runtime)



def migrate_validate_run_strategy_vm(vm, run_strategy):
def migrate_validate_run_strategy_vm(vm, client, run_strategy):
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.

nit
It was modified to add client but none of the parameters have type hints. Every other modified function/fixture in this PR adds type hints consistently — this one was missed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

good catch. modified only those places that coderabbit listed. will go through all modified places and update typehints

def migrated_vm_with_policy(migration_policy_with_bandwidth, vm_for_migration_progress_test):
migrate_vm_and_verify(vm=vm_for_migration_progress_test, wait_for_migration_success=False)
def migrated_vm_with_policy(
admin_client: DynamicClient, vm_for_migration_progress_test: VirtualMachineForTests
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.

why migration_policy_with_bandwidth was moved out? I think the dependency was right.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

if fixture is used only as setup (it's value not used in test/fixture), then it should be called via @pytest.mark.usefixtures

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.

if fixture is used only as setup (it's value not used in test/fixture), then it should be called via @pytest.mark.usefixtures

I agree if we talk about tests, but it is completely wrong if one fixture depends on another. When a fixture depends on another fixture purely for its side effects, listing it as an argument is the only and proper way to express that dependency. And it doesn't matter if that fixture returns or doesn't return a result.

@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/user_defined_network/test_user_defined_network_passt.py
tests/storage/cross_cluster_live_migration/utils.py
tests/virt/cluster/longevity_tests/utils.py
tests/virt/cluster/vm_lifecycle/test_vm_run_strategy.py
tests/virt/node/general/test_windows_vtpm_bitlocker.py
tests/virt/utils.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.

9 participants