forked from TrueCloudLab/frostfs-testlib
63 lines
2.8 KiB
Python
63 lines
2.8 KiB
Python
import logging
|
|
|
|
from frostfs_testlib.load.load_config import LoadParams, LoadScenario
|
|
from frostfs_testlib.load.load_metrics import get_metrics_object
|
|
|
|
logger = logging.getLogger("NeoLogger")
|
|
|
|
|
|
class LoadVerifier:
|
|
def __init__(self, load_params: LoadParams) -> None:
|
|
self.load_params = load_params
|
|
|
|
def verify_summaries(self, load_summary, verification_summary) -> None:
|
|
exceptions = []
|
|
|
|
if not verification_summary or not load_summary:
|
|
logger.info("Can't check load results due to missing summary")
|
|
|
|
load_metrics = get_metrics_object(self.load_params.scenario, load_summary)
|
|
|
|
writers = self.load_params.writers or self.load_params.preallocated_writers or 0
|
|
readers = self.load_params.readers or self.load_params.preallocated_readers or 0
|
|
deleters = self.load_params.deleters or self.load_params.preallocated_deleters or 0
|
|
|
|
objects_count = load_metrics.write_success_iterations
|
|
fails_count = load_metrics.write_failed_iterations
|
|
|
|
if writers > 0:
|
|
if objects_count < 1:
|
|
exceptions.append("Total put objects should be greater than 0")
|
|
if fails_count > 0:
|
|
exceptions.append(f"There were {fails_count} failed write operations")
|
|
|
|
if readers > 0:
|
|
read_count = load_metrics.read_success_iterations
|
|
read_fails_count = load_metrics.read_failed_iterations
|
|
if read_count < 1:
|
|
exceptions.append("Total read operations should be greater than 0")
|
|
if read_fails_count > 0:
|
|
exceptions.append(f"There were {read_fails_count} failed read operations")
|
|
|
|
if deleters > 0:
|
|
delete_count = load_metrics.delete_success_iterations
|
|
delete_fails_count = load_metrics.delete_failed_iterations
|
|
if delete_count < 1:
|
|
exceptions.append("Total delete operations should be greater than 0")
|
|
if delete_fails_count > 0:
|
|
exceptions.append(f"There were {delete_fails_count} failed delete operations")
|
|
|
|
if verification_summary:
|
|
verify_metrics = get_metrics_object(LoadScenario.VERIFY, verification_summary)
|
|
verified_objects = verify_metrics.read_success_iterations
|
|
invalid_objects = verify_metrics.read_failed_iterations
|
|
|
|
if invalid_objects > 0:
|
|
exceptions.append(f"There were {invalid_objects} verification fails")
|
|
# Due to interruptions we may see total verified objects to be less than written on writers count
|
|
if abs(objects_count - verified_objects) > writers:
|
|
exceptions.append(
|
|
f"Verified objects is less than total objects. Total: {objects_count}, Verified: {verified_objects}. Writers: {writers}."
|
|
)
|
|
|
|
assert not exceptions, "\n".join(exceptions)
|