archiver_test.archivers_test_set#

This module lets you run a collection of tests against the data in multiple archiver clusters.

Module Contents#

Classes#

ArchiversTestSet

Represents data needed to run a compare test between two archiver clusters.

TestResult

Result of a test and method to pretty print as tables.

Functions#

import_test_sets(→ list[ArchiversTestSet])

Loads a config file in json. Files are created via the [store_test_set] method.

truncate_repr(→ str)

check_equal(→ bool)

human_readable(→ list[str])

sets_check(→ list[TestResult])

Tests from a list of parameters:

event_rate_same(→ bool)

Calculates if the event rates are effectively the same.

Attributes#

archiver_test.archivers_test_set.LOG: logging.Logger[source]#
class archiver_test.archivers_test_set.ArchiversTestSet[source]#

Represents data needed to run a compare test between two archiver clusters.

Returns:

Storage of the configuration of a test.

Return type:

ArchiversTestSet

msg: str[source]#
pvs: list[str][source]#
sop: datetime.datetime[source]#
eop: datetime.datetime[source]#
archiver_old: str[source]#
archiver_new: str[source]#
archiver_old_data: list[pathlib.Path] | None[source]#
async export(output_folder: pathlib.Path) pathlib.Path[source]#

Stores the configuration for a test run, with the result.

Parameters:

output_folder – Path to store the config.

async store(datasets: dict[str, dict[str, archiver_test.pv_archive_events.PVArchiveEvents]], output_folder: pathlib.Path) None[source]#

Store data from running a test for use in future tests, without redownloading the data.

Parameters:
  • datasets – Data from running test_set

  • output_folder – Path of folder to store the output data.

async load_old_data() dict[str, archiver_test.pv_archive_events.PVArchiveEvents][source]#

Loads old data

async check(output_folder: pathlib.Path | None) TestResult[source]#

Tests a single ArchiverTestSet

Parameters:

output_folder – Path where to store the data from the run.

archiver_test.archivers_test_set.import_test_sets(config: pathlib.Path) list[ArchiversTestSet][source]#

Loads a config file in json. Files are created via the [store_test_set] method.

Parameters:

config – The file path of the config file.

archiver_test.archivers_test_set.MAX_LEN_DISPLAY_VAL_STR = 10[source]#
class archiver_test.archivers_test_set.TestResult[source]#

Bases: NamedTuple

Result of a test and method to pretty print as tables.

test_set: ArchiversTestSet[source]#
old_version: str[source]#
new_version: str[source]#
old_data_set: dict[str, archiver_test.pv_archive_events.PVArchiveEvents][source]#
new_data_set: dict[str, archiver_test.pv_archive_events.PVArchiveEvents][source]#
comparisons: dict[str, archiver_test.pv_archive_events.DataSetDiff][source]#
get_reason(pv: str) archiver_test.fail_reasons.Reason[source]#

Calculates a possible Reason why two archivers have different data.

Parameters:

pv – The pv with test failure.

check_protocol_difference(pv: str, old_details: dict[archiver_test.details.Detail, str], new_details: dict[archiver_test.details.Detail, str]) bool[source]#

Checks if the reason for the test failure is inherent to the protocols being different. In this case, if the only thing different in the differences is the alarm status.

Parameters:
  • pv (str) – pv name

  • old_details (dict[Detail, str]) – old details

  • new_details (dict[Detail, str]) – new details

Returns:

result of check

Return type:

bool

check_capacity_full(pv: str, old_details: dict[archiver_test.details.Detail, str]) bool[source]#
If there are many lost events in the old

And the difference in number of events is not larger than 10% of number of the old archiver test period events.

Parameters:
  • pv (str) – pv name

  • old_details (dict[Detail, str]) – details from old archiver

Returns:

if true

Return type:

bool

check_not_archiving(old_details: dict[archiver_test.details.Detail, str], new_details: dict[archiver_test.details.Detail, str]) bool[source]#
check_no_events(pv: str) bool[source]#
check_types(pv: str) bool[source]#
result_message(pv: str) str[source]#

Returns a message saying pass or failure with a reason.

Parameters:

pv – PV to check.

print_pv_result(console: rich.console.Console, pv: str) None[source]#

Prints a summary of a test to console for a single PV.

Parameters:
  • console – Where to print the summary.

  • pv – Which PV for the summary.

print_result() None[source]#

Prints the test result as a colleciton of summary tables.

create_summary_table() rich.table.Table[source]#

Creates a rich.Table summarizing the test results. With columns Number of events, Events different, Events Same, Mean difference and the test result.

Returns:

A table of summary test result information.

Return type:

Table

print_time_summary(console: rich.console.Console) None[source]#

Print summary of the time period to the console.

Parameters:

console (Console) – console to print in

archiver_test.archivers_test_set.MAX_LEN_DISPLAY_ARCHIVE_EVENT_STR = 1000[source]#
archiver_test.archivers_test_set.truncate_repr(event: epicsarchiver.ArchiveEvent, amount: int = MAX_LEN_DISPLAY_ARCHIVE_EVENT_STR) str[source]#
archiver_test.archivers_test_set.check_equal(pair: tuple[epicsarchiver.ArchiveEvent, epicsarchiver.ArchiveEvent]) bool[source]#
archiver_test.archivers_test_set.human_readable(delta: dateutil.relativedelta.relativedelta) list[str][source]#
async archiver_test.archivers_test_set.sets_check(sets: list[ArchiversTestSet], output_folder: pathlib.Path | None) list[TestResult][source]#

Tests from a list of parameters:

Parameters:
  • sets – list of test sets

  • output_folder – Where to store any data.

Return dictionary of results keys of test_set.msg:

archiver_test.archivers_test_set.ACCEPTABLE_EVENT_RATE_DIFF = 0.1[source]#
archiver_test.archivers_test_set.event_rate_same(old: dict[archiver_test.details.Detail, str], new: dict[archiver_test.details.Detail, str]) bool[source]#

Calculates if the event rates are effectively the same.

Parameters:
  • old – Old Archiver details.

  • new – New Archvier details

Returns:

Returns true or false if the same.