[VIRT] Refactor descheduler tests#4739
Conversation
📝 WalkthroughWalkthroughReworked descheduler tests to replace a drain-based flow with a cordon/uncordon flow: added fixtures that cordon and later uncordon a selected schedulable node, removed fixtures that computed drain targets and waited for per-VM failover, and removed tests asserting "no migration storm", updating test dependencies accordingly. ChangesDescheduler Node Management Refactoring
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
|
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. |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/virt/node/descheduler/conftest.py`:
- Around line 141-145: The uncordon_node fixture yields immediately after
running "oc adm uncordon" which causes a race; after calling run(...) in the
uncordon_node fixture, call the helper
wait_for_node_schedulable_status(cordoned_node_for_vm_deployment, True) (or
equivalent API used elsewhere) to wait until cordoned_node_for_vm_deployment
becomes schedulable before yielding, so tests like
assert_vms_distribution_after_failover observe the updated schedulable state
reliably.
- Line 2: Replace the forbidden subprocess.run usage and import with
pyhelper_utils.shell.run_command: remove "from subprocess import run" and import
run_command from pyhelper_utils.shell, then change the call sites that use
subprocess.run(..., shell=True, f"...") to run_command([...]) providing the
command and arguments as a list (no shell string interpolation) and
propagate/handle the returned result similarly; specifically update any
references to subprocess.run and the f-string command construction to use
run_command([...]) to eliminate shell=True and command-injection risk.
In `@tests/virt/node/descheduler/test_descheduler.py`:
- Line 50: Add a brief explanatory comment above the pytest.mark.dependency
decorator that states why the test depends on
test_descheduler_evicts_vm_after_drain_uncordon (for example: that the earlier
test sets up/validates VM drain/uncordon state required by this test), update
the decorator usage at the occurrence referencing
f"{TESTS_CLASS_NAME}::test_descheduler_evicts_vm_after_drain_uncordon" and apply
the same explanatory-comment pattern to the other dependency instance (the one
at the later occurrence around line 94) so both decorators have the required
rationale comment.
🪄 Autofix (Beta)
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
Run ID: e414306f-a6b1-494d-9885-a011e9246b59
📒 Files selected for processing (2)
tests/virt/node/descheduler/conftest.pytests/virt/node/descheduler/test_descheduler.py
26d9304 to
40cd85b
Compare
40cd85b to
a538b08
Compare
|
New container for quay.io/openshift-cnv/openshift-virtualization-tests:pr-4739 published |
c5b0963 to
75a6e54
Compare
|
Clean rebase detected — no code changes compared to previous head ( |
The node_to_run_stress fixture was picking the first node with any VMs, which could result in insufficient load. Now select the node with the MOST VMs to maximize stress load and ensure the overutilization threshold. Signed-off-by: Denys Shchedrivyi <dshchedr@redhat.com>
75a6e54 to
ce064cc
Compare
|
Clean rebase detected — no code changes compared to previous head ( |
|
/build-and-push-container |
|
New container for quay.io/openshift-cnv/openshift-virtualization-tests:pr-4739 published |
|
/wip cancel |
What this PR does / why we need it:
Remove flaky and duplicate tests.
Remove test_no_migrations_storm tests - flaky, cascading migrations are legitimate rebalancing behavior
Remove TestDeschedulerEvictsVMAfterDrainUncordon - basically it duplicates the utilization imbalance test, just with different setup
Fix flaky PSI metrics tests by selecting node with most VMs
Summary by CodeRabbit
Tests
Chores