Skip to content

Commit 4f74d06

Browse files
[fix] get_final_benchmark_config is error agnostic (#281)
1 parent 5da338a commit 4f74d06

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
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.6.16"
3+
version = "0.6.17"
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/utils/benchmark_config.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ def prepare_benchmark_definitions(args):
6262
) = get_defaults(defaults_filename)
6363
for usecase_filename in files:
6464
with open(usecase_filename, "r") as stream:
65-
benchmark_config, test_name = get_final_benchmark_config(
65+
result, benchmark_config, test_name = get_final_benchmark_config(
6666
default_kpis, stream, usecase_filename
6767
)
68-
benchmark_definitions[test_name] = benchmark_config
68+
if result:
69+
benchmark_definitions[test_name] = benchmark_config
6970
return (
7071
benchmark_definitions,
7172
default_metrics,
@@ -109,15 +110,28 @@ def get_defaults(defaults_filename):
109110

110111

111112
def get_final_benchmark_config(default_kpis, stream, usecase_filename):
112-
os.path.dirname(os.path.abspath(usecase_filename))
113-
benchmark_config = yaml.safe_load(stream)
114-
kpis_keyname = "kpis"
115-
if default_kpis is not None:
116-
merge_default_and_specific_properties_dict_type(
117-
benchmark_config, default_kpis, kpis_keyname, usecase_filename
113+
result = False
114+
benchmark_config = None
115+
test_name = None
116+
try:
117+
os.path.dirname(os.path.abspath(usecase_filename))
118+
benchmark_config = yaml.safe_load(stream)
119+
kpis_keyname = "kpis"
120+
if default_kpis is not None:
121+
merge_default_and_specific_properties_dict_type(
122+
benchmark_config, default_kpis, kpis_keyname, usecase_filename
123+
)
124+
test_name = benchmark_config["name"]
125+
result = True
126+
except Exception as e:
127+
logging.error(
128+
"while loading file {} and error was returned: {}".format(
129+
usecase_filename, e.__str__()
130+
)
118131
)
119-
test_name = benchmark_config["name"]
120-
return benchmark_config, test_name
132+
pass
133+
134+
return result, benchmark_config, test_name
121135

122136

123137
def merge_default_and_specific_properties_dict_type(

tests/test_common.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def test_extract_test_feasible_setups():
369369
) = get_defaults(defaults_filename)
370370
usecase_filename = "./tests/test_data/tsbs-devops-ingestion-scale100-4days-v2.yml"
371371
with open(usecase_filename, "r") as stream:
372-
benchmark_config, test_name = get_final_benchmark_config(
372+
_, benchmark_config, test_name = get_final_benchmark_config(
373373
default_kpis, stream, usecase_filename
374374
)
375375
assert cluster_config == {
@@ -409,6 +409,14 @@ def test_extract_test_feasible_setups():
409409
assert osscluster_setup_type == t
410410
assert osscluster_shard_count == c
411411

412+
# wrong read
413+
res, benchmark_config, test_name = get_final_benchmark_config(
414+
default_kpis, stream, "dont exist"
415+
)
416+
assert res == False
417+
assert benchmark_config == None
418+
assert benchmark_config == None
419+
412420

413421
def test_check_dbconfig_tool_requirement():
414422
with open(

0 commit comments

Comments
 (0)