blob: 724422585c67434e1cfefc9074ac8911a7ef0bd1 [file] [log] [blame]
koder aka kdanilov7f59d562016-12-26 01:34:23 +02001import abc
koder aka kdanilov23e6bdf2016-12-24 02:18:54 +02002import array
koder aka kdanilov7f59d562016-12-26 01:34:23 +02003from typing import Dict, List, Any, Tuple, Optional, Union, Type
koder aka kdanilov70227062016-11-26 23:23:21 +02004
5
koder aka kdanilov23e6bdf2016-12-24 02:18:54 +02006class TimeSerie:
7 name = None # type: str
8 start_at = None # type: int
9 step = None # type: int
10 data = None # type: List[int]
11 second_axis_size = None # type: int
12 raw = None # type: Optional[bytes]
koder aka kdanilov70227062016-11-26 23:23:21 +020013
koder aka kdanilov23e6bdf2016-12-24 02:18:54 +020014 def __init__(self, name: str, raw: Optional[bytes], second_axis_size: int,
15 start_at: int, step: int, data: array.array) -> None:
16 self.name = name
17 self.start_at = start_at
18 self.step = step
19 self.second_axis_size = second_axis_size
20 self.data = data # type: ignore
21 self.raw = raw
koder aka kdanilov70227062016-11-26 23:23:21 +020022
koder aka kdanilov23e6bdf2016-12-24 02:18:54 +020023 def meta(self) -> Dict[str, Any]:
24 return {
25 "start_at": self.start_at,
26 "step": self.step,
27 "second_axis_size": self.second_axis_size
28 }
koder aka kdanilov70227062016-11-26 23:23:21 +020029
30
31class SensorInfo:
32 """Holds information from a single sensor from a single node"""
33 node_id = None # type: str
34 source_id = None # type: str
35 sensor_name = None # type: str
36 begin_time = None # type: int
37 end_time = None # type: int
koder aka kdanilov23e6bdf2016-12-24 02:18:54 +020038 data = None # type: List[int]
koder aka kdanilov70227062016-11-26 23:23:21 +020039
40 def __init__(self, node_id: str, source_id: str, sensor_name: str) -> None:
41 self.node_id = node_id
42 self.source_id = source_id
43 self.sensor_name = sensor_name
44
45
46class TestInfo:
47 """Contains done test information"""
48 name = None # type: str
49 iteration_name = None # type: str
50 nodes = None # type: List[str]
51 start_time = None # type: int
52 stop_time = None # type: int
53 params = None # type: Dict[str, Any]
54 config = None # type: str
55 node_ids = None # type: List[str]
56
57
koder aka kdanilov23e6bdf2016-12-24 02:18:54 +020058class NodeTestResults:
59 name = None # type: str
60 node_id = None # type: str
61 summary = None # type: str
62
63 load_start_at = None # type: int
64 load_stop_at = None # type: int
65
66 series = None # type: Dict[str, TimeSerie]
67
68 def __init__(self, name: str, node_id: str, summary: str) -> None:
69 self.name = name
70 self.node_id = node_id
71 self.summary = summary
72 self.series = {}
73 self.extra_logs = {} # type: Dict[str, bytes]
74
75
koder aka kdanilov70227062016-11-26 23:23:21 +020076class FullTestResult:
77 test_info = None # type: TestInfo
78
79 # TODO(koder): array.array or numpy.array?
80 # {(node_id, perf_metrics_name): values}
koder aka kdanilov23e6bdf2016-12-24 02:18:54 +020081 performance_data = None # type: Dict[Tuple[str, str], List[int]]
koder aka kdanilov70227062016-11-26 23:23:21 +020082
83 # {(node_id, perf_metrics_name): values}
84 sensors_data = None # type: Dict[Tuple[str, str, str], SensorInfo]
koder aka kdanilov7f59d562016-12-26 01:34:23 +020085
86
87class IStorable(metaclass=abc.ABCMeta):
88 """Interface for type, which can be stored"""
89
90 @abc.abstractmethod
91 def raw(self) -> Dict[str, Any]:
92 pass
93
94 @abc.abstractclassmethod
95 def fromraw(cls, data: Dict[str, Any]) -> 'IStorable':
96 pass
97
98
99Basic = Union[int, str, bytes, bool, None]
100Storable = Union[IStorable, Dict[str, Any], List[Any], int, str, bytes, bool, None]
101