Skip to content

Commit 7b9a9a2

Browse files
OhadRevahhmeir
andauthored
Modify validate_vnic_info function to support s390x (#3205)
##### Short description: In s390x the test using this function is flaky right now because it doesn't get always the value from the metric in the first call, added sampler for it so it will be more robust and support s390x. ##### More details: ##### What this PR does / why we need it: ##### Which issue(s) this PR fixes: ##### Special notes for reviewer: ##### jira-ticket: https://issues.redhat.com/browse/CNV-75605 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Metric validation now uses a polling-and-retry approach (up to ~5 minutes, checking every ~30 seconds) to handle eventual consistency instead of a single synchronous query. * On timeout, the last observed sample is captured and surfaced to aid debugging; existing mismatch comparison logic remains unchanged. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Harel Meir <hmeir@redhat.com>
1 parent 9318ed7 commit 7b9a9a2

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tests/observability/metrics/utils.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,21 @@ def binding_name_and_type_from_vm_or_vmi(vm_interface: dict[str, str]) -> dict[s
644644

645645

646646
def validate_vnic_info(prometheus: Prometheus, vnic_info_to_compare: dict[str, str], metric_name: str) -> None:
647-
vnic_info_metric_result = prometheus.query_sampler(query=metric_name)[0].get("metric")
647+
samples = TimeoutSampler(
648+
wait_timeout=TIMEOUT_5MIN,
649+
sleep=TIMEOUT_30SEC,
650+
func=prometheus.query,
651+
query=metric_name,
652+
)
653+
sample = None
654+
try:
655+
for sample in samples:
656+
if sample and (result := sample.get("data", {}).get("result")):
657+
vnic_info_metric_result = result[0].get("metric")
658+
break
659+
except TimeoutExpiredError:
660+
LOGGER.error(f"Metric value of: {metric_name} is: {sample}, should not be empty.")
661+
raise
648662
mismatch_vnic_info = {}
649663
for info, expected_value in vnic_info_to_compare.items():
650664
actual_value = vnic_info_metric_result.get(info)

0 commit comments

Comments
 (0)