Files
qdrant/tests/consensus_tests/assertions.py
Jojii 1fded093b7 Measure hardware IO for update operations (#5922)
* Measure update operations hardware IO

* Add support for distributed setups

* also measure update_local

* Add consensus tests for HW metrics of update operations

* add test for upserting without waiting

* Disable HW usage reporting when not waiting for update API

* Review remarks

* Fix resharding collecting hw measurements

* Fix metric type

* New struct HardwareData for better accumulation

* Ensure we always apply CPU multiplier

* Apply suggestions from code review

* Update src/actix/api/update_api.rs

Co-authored-by: Tim Visée <tim+github@visee.me>

* Fix assert_with_upper_bound_error threshold calculation.

* Clarifying why we don't measure shard cleanup

---------

Co-authored-by: Tim Visée <tim+github@visee.me>
2025-03-06 15:03:23 +01:00

29 lines
1.0 KiB
Python

import itertools
import requests
def assert_http_ok(response: requests.Response):
if response.status_code != 200:
base_msg = f"HTTP request to {response.url} failed with status code {response.status_code} after {response.elapsed.total_seconds()}s"
if not response.content:
raise Exception(f"{base_msg} and without response body")
else:
raise Exception(
f"{base_msg} with response body:\n{response.json()}")
def assert_hw_measurements_equal(left: dict[str, int], right: dict[str, int]):
keys = set([key for key in itertools.chain(left.keys(), right.keys())])
for key in keys:
if key in left and left[key] > 0:
assert right.get(key) == left[key]
if key in right and right[key] > 0:
assert left.get(key) == right[key]
def assert_hw_measurements_equal_many(left_list: list[dict[str, int]], right_list: list[dict[str, int]]):
for left,right in zip(left_list, right_list):
assert_hw_measurements_equal(left, right)