CherryPicked: [cnv-4.21] Fixed return None on missing metric for filter_metric_by_component#3906
Conversation
…3645) ##### Short description: `test_cdi_json_patch_metrics` uses the function `filter_metric_by_component` which returns None instead of 0 if the metric isn't found. The None value is used in later addition in `wait_for_metrics_value_update`, causing a type error ##### More details: having trouble reproducing issue on local cluster, so trying to future-proof with a warning and new return statement ##### What this PR does / why we need it: part of detecting early 4.99 failures for 4.22.0 ##### Which issue(s) this PR fixes: ##### Special notes for reviewer: ##### jira-ticket: https://issues.redhat.com/browse/CNV-78331 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Improved metric handling in test utilities: missing or malformed metrics now log a warning and return a safe default numeric value. * Sampling logic tightened to ignore empty or falsy samples before performing comparisons to prevent false positives. * Timeout failures are now logged and re-raised so test harnesses reliably detect and handle timing issues. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (4)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
|
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
💡 Tips
For more information, please refer to the project documentation or contact the maintainers. |
|
/build-and-push-container |
|
New container for quay.io/openshift-cnv/openshift-virtualization-tests:pr-3906 published |
|
/lgtm |
|
/retest build-container |
|
/lgtm |
|
/lgtm |
|
/verified tests-runner #4532 with |
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:
Your deliverable: Test Execution Plan
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: Before setting "Run smoke tests: True", you MUST use shell scripts to: |
| for metric in metrics: | ||
| if metric["metric"]["annotation_name"] == annotation_name and metric["metric"]["__name__"] == metric_name: | ||
| return int(metric["value"][1]) | ||
| if ( |
There was a problem hiding this comment.
Test Execution Plan
Run smoke tests: False
This PR fixes a bug in filter_metric_by_component where missing metric data could cause KeyError exceptions. The function now uses defensive .get() calls and returns 0 instead of None when no matching metric is found.
Affected tests (all tests using filter_metric_by_component):
tests/install_upgrade_operators/json_patch/test_json_patch_annotation_ssp.pytests/install_upgrade_operators/json_patch/test_json_patch_annotation_kubevirt.pytests/install_upgrade_operators/json_patch/test_json_patch_annotation_cdi.pytests/install_upgrade_operators/json_patch/test_json_patch_annotation_cnao.pytests/install_upgrade_operators/json_patch/test_json_patch_annotation_multiple_updates.py
Rationale: The bug fix changes error handling in metric filtering. All tests that use this function should be verified to ensure they handle the new return value (0) correctly when metrics are missing and that the defensive coding prevents KeyError exceptions.
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 51 🏁 Script executed: Length of output: 1702 🏁 Script executed: Length of output: 9149 🏁 Script executed: Length of output: 403 🏁 Script executed: Length of output: 0 🏁 Script executed: Length of output: 272 🏁 Script executed: Length of output: 1735 🧠 Learnings used |
cherry-pick #3645 into cnv-4.21
requested-by by target-branch label