|
1 | 1 | import datetime as dt |
2 | 2 | import logging |
3 | | -import re |
4 | | - |
5 | | -import yaml |
6 | 3 |
|
7 | 4 | from redisbench_admin.run.redis_benchmark.redis_benchmark import ( |
8 | 5 | prepare_redis_benchmark_command, |
|
15 | 12 | ) |
16 | 13 | from redisbench_admin.run.ycsb.ycsb import prepare_ycsb_benchmark_command |
17 | 14 | from redisbench_admin.utils.benchmark_config import ( |
18 | | - parse_exporter_metrics_definition, |
19 | | - parse_exporter_timemetric_definition, |
20 | 15 | parse_exporter_timemetric, |
21 | 16 | ) |
22 | 17 | from redisbench_admin.utils.remote import ( |
|
28 | 23 | ) |
29 | 24 |
|
30 | 25 |
|
31 | | -def extract_benchmark_tool_settings(benchmark_config): |
32 | | - benchmark_tool = None |
33 | | - benchmark_tool_source = None |
34 | | - benchmark_tool_source_inner_path = None |
35 | | - benchmark_min_tool_version = None |
36 | | - benchmark_min_tool_version_major = None |
37 | | - benchmark_min_tool_version_minor = None |
38 | | - benchmark_min_tool_version_patch = None |
39 | | - |
40 | | - for entry in benchmark_config["clientconfig"]: |
41 | | - if "tool" in entry: |
42 | | - benchmark_tool = entry["tool"] |
43 | | - if "tool_source" in entry: |
44 | | - for inner_entry in entry["tool_source"]: |
45 | | - if "remote" in inner_entry: |
46 | | - benchmark_tool_source = inner_entry["remote"] |
47 | | - if "bin_path" in inner_entry: |
48 | | - benchmark_tool_source_inner_path = inner_entry["bin_path"] |
49 | | - |
50 | | - if "min-tool-version" in entry: |
51 | | - benchmark_min_tool_version = entry["min-tool-version"] |
52 | | - p = re.compile(r"(\d+)\.(\d+)\.(\d+)") |
53 | | - m = p.match(benchmark_min_tool_version) |
54 | | - if m is None: |
55 | | - logging.error( |
56 | | - "Unable to extract semversion from 'min-tool-version'." |
57 | | - " Will not enforce version" |
58 | | - ) |
59 | | - benchmark_min_tool_version = None |
60 | | - else: |
61 | | - benchmark_min_tool_version_major = m.group(1) |
62 | | - benchmark_min_tool_version_minor = m.group(2) |
63 | | - benchmark_min_tool_version_patch = m.group(3) |
64 | | - return ( |
65 | | - benchmark_min_tool_version, |
66 | | - benchmark_min_tool_version_major, |
67 | | - benchmark_min_tool_version_minor, |
68 | | - benchmark_min_tool_version_patch, |
69 | | - benchmark_tool, |
70 | | - benchmark_tool_source, |
71 | | - benchmark_tool_source_inner_path, |
72 | | - ) |
73 | | - |
74 | | - |
75 | 26 | def prepare_benchmark_parameters( |
76 | 27 | benchmark_config, |
77 | 28 | benchmark_tool, |
@@ -183,85 +134,6 @@ def run_remote_benchmark( |
183 | 134 | return remote_run_result |
184 | 135 |
|
185 | 136 |
|
186 | | -def merge_default_and_specific_properties_dict_type( |
187 | | - benchmark_config, default_properties, propertygroup_keyname, usecase_filename |
188 | | -): |
189 | | - if propertygroup_keyname not in benchmark_config: |
190 | | - benchmark_config[propertygroup_keyname] = default_properties |
191 | | - logging.info( |
192 | | - "Using exclusively default '{}' properties (total={}) given the file {} had no '{}' property group".format( |
193 | | - propertygroup_keyname, |
194 | | - len(benchmark_config[propertygroup_keyname].keys()), |
195 | | - usecase_filename, |
196 | | - propertygroup_keyname, |
197 | | - ) |
198 | | - ) |
199 | | - else: |
200 | | - usecase_kpi = None |
201 | | - use_case_specific_properties = benchmark_config[propertygroup_keyname] |
202 | | - for default_property in default_properties: |
203 | | - default_rule, default_details = list(default_property.items())[0] |
204 | | - default_condition = list(default_details.values())[0] |
205 | | - comparison_key = "{}{}".format(default_rule, default_condition) |
206 | | - found = False |
207 | | - for usecase_kpi in use_case_specific_properties: |
208 | | - usecase_rule, usecase_details = list(usecase_kpi.items())[0] |
209 | | - usecase_condition = list(usecase_details.values())[0] |
210 | | - usecase_comparison_key = "{}{}".format(usecase_rule, usecase_condition) |
211 | | - if comparison_key == usecase_comparison_key: |
212 | | - found = True |
213 | | - if found: |
214 | | - logging.info( |
215 | | - "Skipping to add default '{}' property ({}) given the file {}" |
216 | | - " had the same specific property ({})".format( |
217 | | - propertygroup_keyname, |
218 | | - default_property, |
219 | | - usecase_filename, |
220 | | - usecase_kpi, |
221 | | - ) |
222 | | - ) |
223 | | - else: |
224 | | - use_case_specific_properties.append(default_property) |
225 | | - logging.info( |
226 | | - "Adding a default '{}' property ({}) given the file {} did not had the specific property".format( |
227 | | - propertygroup_keyname, default_property, usecase_filename |
228 | | - ) |
229 | | - ) |
230 | | - |
231 | | - |
232 | | -def process_default_yaml_properties_file( |
233 | | - default_kpis, default_metrics, defaults_filename, exporter_timemetric_path, stream |
234 | | -): |
235 | | - default_config = yaml.safe_load(stream) |
236 | | - if "exporter" in default_config: |
237 | | - default_metrics = parse_exporter_metrics_definition(default_config["exporter"]) |
238 | | - if len(default_metrics) > 0: |
239 | | - logging.info( |
240 | | - "Found RedisTimeSeries default metrics specification." |
241 | | - " Will include the following metrics on all benchmarks {}".format( |
242 | | - " ".join(default_metrics) |
243 | | - ) |
244 | | - ) |
245 | | - exporter_timemetric_path = parse_exporter_timemetric_definition( |
246 | | - default_config["exporter"] |
247 | | - ) |
248 | | - if exporter_timemetric_path is not None: |
249 | | - logging.info( |
250 | | - "Found RedisTimeSeries default time metric specification." |
251 | | - " Will use the following JSON path to retrieve the test time {}".format( |
252 | | - exporter_timemetric_path |
253 | | - ) |
254 | | - ) |
255 | | - if "kpis" in default_config: |
256 | | - logging.info( |
257 | | - "Loading default KPIs specifications from file: {}".format( |
258 | | - defaults_filename |
259 | | - ) |
260 | | - ) |
261 | | - default_kpis = default_config["kpis"] |
262 | | - return default_kpis, default_metrics, exporter_timemetric_path |
263 | | - |
264 | | - |
265 | 137 | def common_exporter_logic( |
266 | 138 | deployment_type, |
267 | 139 | exporter_timemetric_path, |
|
0 commit comments