Skip to content

Commit c926325

Browse files
Fixes per SPEC usage of api (#253)
* [fix] Fixed redis.exceptions.DataError and extended logging * [fix] Fixes per SPEC usage of api
1 parent f4e4877 commit c926325

File tree

5 files changed

+97
-88
lines changed

5 files changed

+97
-88
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "redisbench-admin"
3-
version = "0.5.26"
3+
version = "0.5.27"
44
description = "Redis benchmark run helper. A wrapper around Redis and Redis Modules benchmark tools ( ftsb_redisearch, memtier_benchmark, redis-benchmark, aibench, etc... )."
55
authors = ["filipecosta90 <[email protected]>","Redis Performance Group <[email protected]>"]
66
readme = "README.md"

redisbench_admin/run/common.py

Lines changed: 60 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -231,77 +231,68 @@ def common_exporter_logic(
231231
testcase_metric_context_paths = []
232232
version_target_tables = None
233233
branch_target_tables = None
234+
used_ts = datapoints_timestamp
234235

235-
if exporter_timemetric_path is not None and len(metrics) > 0:
236-
if datapoints_timestamp is None:
237-
# extract timestamp
238-
datapoints_timestamp = parse_exporter_timemetric(
239-
exporter_timemetric_path, results_dict
240-
)
241-
if datapoints_timestamp is None:
242-
datapoints_timestamp = int(
243-
datetime.datetime.now(datetime.timezone.utc).timestamp() * 1000.0
244-
)
245-
logging.warning(
246-
"Error while trying to parse datapoints timestamp. Using current system timestamp Error: {}".format(
247-
datapoints_timestamp
248-
)
249-
)
250-
if (
251-
artifact_version is not None
252-
and artifact_version != ""
253-
and artifact_version != "N/A"
254-
):
255-
# extract per-version datapoints
256-
(
257-
_,
258-
per_version_time_series_dict,
259-
version_target_tables,
260-
) = extract_perversion_timeseries_from_results(
261-
datapoints_timestamp,
262-
metrics,
263-
results_dict,
264-
artifact_version,
265-
tf_github_org,
266-
tf_github_repo,
267-
deployment_name,
268-
deployment_type,
269-
test_name,
270-
tf_triggering_env,
271-
metadata_tags,
272-
build_variant_name,
273-
running_platform,
274-
testcase_metric_context_paths,
275-
)
276-
if tf_github_branch is not None and tf_github_branch != "":
277-
# extract per branch datapoints
278-
(
279-
_,
280-
per_branch_time_series_dict,
281-
branch_target_tables,
282-
) = extract_perbranch_timeseries_from_results(
283-
datapoints_timestamp,
284-
metrics,
285-
results_dict,
286-
str(tf_github_branch),
287-
tf_github_org,
288-
tf_github_repo,
289-
deployment_name,
290-
deployment_type,
291-
test_name,
292-
tf_triggering_env,
293-
metadata_tags,
294-
build_variant_name,
295-
running_platform,
296-
testcase_metric_context_paths,
297-
)
298-
else:
299-
logging.warning(
300-
"Requested to push data to RedisTimeSeries but no git"
301-
" branch definition was found. git branch value {}".format(
302-
tf_github_branch
303-
)
236+
if exporter_timemetric_path is not None and used_ts is None:
237+
# extract timestamp
238+
used_ts = parse_exporter_timemetric(exporter_timemetric_path, results_dict)
239+
240+
if used_ts is None:
241+
used_ts = int(datetime.datetime.now(datetime.timezone.utc).timestamp() * 1000.0)
242+
logging.warning(
243+
"Error while trying to parse datapoints timestamp. Using current system timestamp Error: {}".format(
244+
used_ts
304245
)
246+
)
247+
assert used_ts != None
248+
if (
249+
artifact_version is not None
250+
and artifact_version != ""
251+
and artifact_version != "N/A"
252+
):
253+
# extract per-version datapoints
254+
(
255+
_,
256+
per_version_time_series_dict,
257+
version_target_tables,
258+
) = extract_perversion_timeseries_from_results(
259+
used_ts,
260+
metrics,
261+
results_dict,
262+
artifact_version,
263+
tf_github_org,
264+
tf_github_repo,
265+
deployment_name,
266+
deployment_type,
267+
test_name,
268+
tf_triggering_env,
269+
metadata_tags,
270+
build_variant_name,
271+
running_platform,
272+
testcase_metric_context_paths,
273+
)
274+
if tf_github_branch is not None and tf_github_branch != "":
275+
# extract per branch datapoints
276+
(
277+
_,
278+
per_branch_time_series_dict,
279+
branch_target_tables,
280+
) = extract_perbranch_timeseries_from_results(
281+
used_ts,
282+
metrics,
283+
results_dict,
284+
str(tf_github_branch),
285+
tf_github_org,
286+
tf_github_repo,
287+
deployment_name,
288+
deployment_type,
289+
test_name,
290+
tf_triggering_env,
291+
metadata_tags,
292+
build_variant_name,
293+
running_platform,
294+
testcase_metric_context_paths,
295+
)
305296
else:
306297
logging.error(
307298
"Requested to push data to RedisTimeSeries but "

redisbench_admin/run/redistimeseries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,11 @@ def timeseries_test_sucess_flow(
303303
for (
304304
branch_target_table_keyname,
305305
branch_target_table_dict,
306-
) in version_target_tables.items():
306+
) in branch_target_tables.items():
307307

308308
logging.info(
309309
"Setting target table by branch on key {}".format(
310-
version_target_table_keyname
310+
branch_target_table_keyname
311311
)
312312
)
313313
if "contains-target" in branch_target_table_dict:

redisbench_admin/utils/benchmark_config.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,26 @@ def extract_redis_dbconfig_parameters(benchmark_config, dbconfig_keyname):
178178
dbconfig_present = False
179179
if dbconfig_keyname in benchmark_config:
180180
dbconfig_present = True
181-
for k in benchmark_config[dbconfig_keyname]:
182-
if "configuration-parameters" in k:
183-
cp = k["configuration-parameters"]
184-
for item in cp:
185-
for k, v in item.items():
186-
redis_configuration_parameters[k] = v
187-
if "dataset_load_timeout_secs" in k:
188-
dataset_load_timeout_secs = k["dataset_load_timeout_secs"]
189-
if "dataset_name" in k:
190-
dataset_name = k["dataset_name"]
181+
if type(benchmark_config[dbconfig_keyname]) == list:
182+
for k in benchmark_config[dbconfig_keyname]:
183+
if "configuration-parameters" in k:
184+
cp = k["configuration-parameters"]
185+
for item in cp:
186+
for k, v in item.items():
187+
redis_configuration_parameters[k] = v
188+
if "dataset_load_timeout_secs" in k:
189+
dataset_load_timeout_secs = k["dataset_load_timeout_secs"]
190+
if "dataset_name" in k:
191+
dataset_name = k["dataset_name"]
192+
if type(benchmark_config[dbconfig_keyname]) == dict:
193+
if "configuration-parameters" in benchmark_config[dbconfig_keyname]:
194+
cp = benchmark_config[dbconfig_keyname]["configuration-parameters"]
195+
for k, v in cp.items():
196+
redis_configuration_parameters[k] = v
197+
if "dataset_load_timeout_secs" in cp:
198+
dataset_load_timeout_secs = cp["dataset_load_timeout_secs"]
199+
if "dataset_name" in cp:
200+
dataset_name = cp["dataset_name"]
191201

192202
return (
193203
dbconfig_present,

redisbench_admin/utils/remote.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -512,12 +512,20 @@ def push_data_to_redistimeseries(rts, time_series_dict: dict):
512512
exporter_create_ts(rts, time_series, timeseries_name)
513513
for timestamp, value in time_series["data"].items():
514514
try:
515-
rts.add(
516-
timeseries_name,
517-
timestamp,
518-
value,
519-
duplicate_policy="last",
520-
)
515+
if timestamp is None:
516+
logging.warning("The provided timestamp is null. Using auto-ts")
517+
rts.add(
518+
timeseries_name,
519+
value,
520+
duplicate_policy="last",
521+
)
522+
else:
523+
rts.add(
524+
timeseries_name,
525+
timestamp,
526+
value,
527+
duplicate_policy="last",
528+
)
521529
datapoint_inserts += 1
522530
except redis.exceptions.DataError:
523531
logging.warning(

0 commit comments

Comments
 (0)