-
Story
-
Resolution: Unresolved
-
Major
-
None
-
None
-
Quality / Stability / Reliability
-
0.42
-
False
-
-
False
-
None
-
-
CNV I/U Operators Sprint 281, CNV I/U Operators Sprint 282
-
None
Test Files
All 5 json_patch metrics tests fail with identical root cause
- test_json_patch_annotation_cdi.py - test_cdi_json_patch_metrics
- test_json_patch_annotation_cnao.py - test_cnao_json_patch_metrics
- test_json_patch_annotation_kubevirt.py - test_kubevirt_json_patch_metrics
- test_json_patch_annotation_multiple_updates.py - test_multiple_json_patch_metrics
- test_json_patch_annotation_ssp.py - test_ssp_json_patch_metrics
Issue
Tests crash with TypeError when verifying kubevirt_hco_unsafe_modifications metric increments.
Error message: unsupported operand type(s) for plus NoneType and int
The filter_metric_by_component function returns None when no baseline metric exists, then wait_for_metrics_value_update attempts None plus 1 causing the crash.
Root Cause
File: tests/install_upgrade_operators/json_patch/utils.py lines 63-67
The function returns None implicitly when metric not found because line 67 has no return statement for the not-found case.
This causes crash at utils.py line 81 when attempting previous_value plus 1 with previous_value equals None.
Evidence
- Jenkins Build test-pytest-cnv-4.18-iuo-ocs number 117
- ReportPortal Launch 149913 - All 5 tests marked ti001 To Investigate
- First Occurrence Build 117 on 2025-12-10 - tests executed for first time
- Historical Builds 102-116 did not execute these tests
- Affected Branches cnv-4.18, cnv-4.19, main - bug present in all
Code Inconsistency
In the same file utils.py, another function handles this correctly at line 60 using ternary operator to return 0 when no results found.
But filter_metric_by_component returns None - this is an internal inconsistency.
Proposed Fix
File: tests/install_upgrade_operators/json_patch/utils.py line 68
Add explicit return 0 statement after the for loop to match the pattern used in get_metrics_value_with_annotation function.
Single line addition at end of function body.
Branches to Fix
This single-line fix must be applied to all three branches:
- cnv-4.18 - used by Jenkins - PRIORITY
- cnv-4.19 - current release
- main - future releases
All three branches have identical code with the same bug from commit 71e9583.
Validation Steps
- Apply fix to cnv-4.18 branch
- Run locally: uv run pytest -m tier2 and iuo tests/install_upgrade_operators/json_patch/
- Verify all 5 tests pass
- Confirm Jenkins build passes with fix
- Cherry-pick to cnv-4.19 and main
Why Tests Started Failing Now
Tests were always included in selection but never executed in builds 102-116. Most likely Prometheus metrics fixtures had setup errors in previous builds. Build 117 fixtures worked revealing the latent bug that existed since original code.
Additional Context
- Components Tested: CDI, CNAO, KubeVirt, SSP, Multiple
- Metrics Validated: kubevirt_hco_unsafe_modifications
- Test Purpose: Verify HCO tracks unsafe JSON patch modifications
- Polarion IDs: CNV-8717, CNV-8715, CNV-8689, CNV-8718, CNV-8690
Impact
- Frequency: 100 percent - 5 of 5 tests fail consistently
- Jobs Affected: test-pytest-cnv-4.18-iuo-ocs TIER-2
- Severity: Tests cannot execute due to TypeError crash
- CI Impact: 5 of 7 failures in build 117
- links to