Skip to content

Commit c3eccd6

Browse files
Updated watchdog to avoid crash on missing Tags (#423)
* Added support for spot instance setups * Fixed CI tests based uppon latest changes of tools * Updating spot/full-price counter * Further improved the comparison str generated between baseline/comparison data * Updated watchdog to avoid crash on missing Tags
1 parent 7405674 commit c3eccd6

File tree

13 files changed

+68
-23
lines changed

13 files changed

+68
-23
lines changed

.github/workflows/tox.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ jobs:
99
pytest:
1010
strategy:
1111
matrix:
12-
python-version: [ '3.7', '3.8', '3.9', '3.10' ]
12+
python-version: [ '3.9', '3.10' ]
13+
fail-fast: false
1314
env:
1415
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
1516
USING_COVERAGE: "3.10"

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "redisbench-admin"
3-
version = "0.10.17"
3+
version = "0.10.19"
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/compare/compare.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ def get_by_strings(
649649
baseline_str = baseline_branch
650650
if comparison_branch is not None:
651651
comparison_covered = True
652-
by_str_baseline = "branch"
652+
by_str_comparison = "branch"
653653
comparison_str = comparison_branch
654654

655655
if baseline_tag is not None:
@@ -960,7 +960,12 @@ def check_multi_value_filter(baseline_str):
960960

961961

962962
def prepare_value_str(baseline_pct_change, baseline_v, baseline_values, simplify_table):
963-
baseline_v_str = " {:.0f}".format(baseline_v)
963+
if baseline_v < 1.0:
964+
baseline_v_str = " {:.2f}".format(baseline_v)
965+
elif baseline_v < 10.0:
966+
baseline_v_str = " {:.1f}".format(baseline_v)
967+
else:
968+
baseline_v_str = " {:.0f}".format(baseline_v)
964969
stamp_b = ""
965970
if baseline_pct_change > 10.0:
966971
stamp_b = "UNSTABLE "

redisbench_admin/run_remote/remote_env.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def remote_env_setup(
3131
tf_override_name=None,
3232
tf_folder_path=None,
3333
spot_instance_error=False,
34+
spot_price_counter=0,
35+
full_price_counter=0,
3436
):
3537
server_plaintext_port = args.db_port
3638
db_ssh_port = args.db_ssh_port
@@ -85,6 +87,7 @@ def remote_env_setup(
8587
tf_folder_spot_path,
8688
)
8789
spot_available_and_used = True
90+
spot_price_counter = spot_price_counter + 1
8891
except TerraformCommandError as error:
8992
spot_instance_error = True
9093
logging.error(
@@ -95,7 +98,7 @@ def remote_env_setup(
9598
pass
9699
else:
97100
logging.warning(
98-
f"Even though there is a spot instance config, avoiding deploying it."
101+
"Even though there is a spot instance config, avoiding deploying it."
99102
)
100103
if spot_available_and_used is False:
101104
(
@@ -121,6 +124,7 @@ def remote_env_setup(
121124
tf_override_name,
122125
tf_folder_path,
123126
)
127+
full_price_counter = full_price_counter + 1
124128
logging.info("Using the following connection addresses.")
125129
logging.info(f"client_public_ip={client_public_ip}")
126130
logging.info(f"server_public_ip={server_public_ip}")
@@ -134,4 +138,6 @@ def remote_env_setup(
134138
client_ssh_port,
135139
username,
136140
spot_instance_error,
141+
spot_price_counter,
142+
full_price_counter,
137143
)

redisbench_admin/run_remote/remote_helpers.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,12 @@ def post_process_remote_run(
286286
start_time_str,
287287
stdout,
288288
)
289-
with open(local_benchmark_output_filename, "r") as json_file:
290-
results_dict = json.load(json_file)
289+
try:
290+
with open(local_benchmark_output_filename, "r") as json_file:
291+
results_dict = json.load(json_file)
292+
except json.decoder.JSONDecodeError as e:
293+
logging.error("Received error while decoding JSON: {}".format(e.__str__()))
294+
pass
291295
# check KPIs
292296
return_code = results_dict_kpi_check(benchmark_config, results_dict, return_code)
293297
# if the benchmark tool is redisgraph-benchmark-go and

redisbench_admin/run_remote/run_remote.py

+29-2
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ def run_remote_command_logic(args, project_name, project_version):
306306

307307
# Used to only deploy spot once per run
308308
spot_instance_error = False
309+
ts_key_spot_price = f"ts:{tf_triggering_env}:tests:spot_price"
310+
ts_key_full_price = f"ts:{tf_triggering_env}:tests:full_price"
309311

310312
for benchmark_type, bench_by_dataset_map in benchmark_runs_plan.items():
311313
if return_code != 0 and args.fail_fast:
@@ -418,6 +420,8 @@ def run_remote_command_logic(args, project_name, project_version):
418420
client_ssh_port,
419421
username,
420422
spot_instance_error,
423+
spot_price_counter,
424+
full_price_counter,
421425
) = remote_env_setup(
422426
args,
423427
benchmark_config,
@@ -435,16 +439,37 @@ def run_remote_command_logic(args, project_name, project_version):
435439
TF_OVERRIDE_NAME,
436440
TF_OVERRIDE_REMOTE,
437441
spot_instance_error,
442+
0,
443+
0,
438444
)
439445

440446
# after we've created the env, even on error we should always teardown
441447
# in case of some unexpected error we fail the test
442448
try:
443449
(
444450
_,
445-
_,
451+
start_time_setup_ms,
446452
testcase_start_time_str,
447453
) = get_start_time_vars()
454+
if args.push_results_redistimeseries:
455+
logging.info(
456+
f"Updating overall spot price tests counter {ts_key_spot_price}"
457+
)
458+
rts.ts().add(
459+
ts_key_spot_price,
460+
start_time_setup_ms,
461+
spot_price_counter,
462+
duplicate_policy="sum",
463+
)
464+
logging.info(
465+
f"Updating overall spot price full counter {ts_key_spot_price}"
466+
)
467+
rts.ts().add(
468+
ts_key_full_price,
469+
start_time_setup_ms,
470+
full_price_counter,
471+
duplicate_policy="sum",
472+
)
448473
logname = "{}_{}.log".format(
449474
test_name, testcase_start_time_str
450475
)
@@ -871,7 +896,9 @@ def run_remote_command_logic(args, project_name, project_version):
871896
)
872897
return_code |= 1
873898
raise Exception(
874-
"Failed to run remote benchmark."
899+
"Failed to run remote benchmark. {}".format(
900+
e.__str__()
901+
)
875902
)
876903

877904
if setup_details["env"] is None:

redisbench_admin/utils/benchmark_config.py

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def parse_exporter_timemetric(metric_path: str, results_dict: dict):
4949
logging.error(
5050
"Unable to parse time-metric {}. Error: {}".format(metric_path, e.__str__())
5151
)
52+
pass
5253
return datapoints_timestamp
5354

5455

redisbench_admin/utils/remote.py

-2
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,6 @@ def fetch_remote_setup_from_config(
578578
setup_type = remote_setup_property["type"]
579579
if "setup" in remote_setup_property:
580580
setup = remote_setup_property["setup"]
581-
if "spot_instance" in remote_setup_property:
582-
spot_path = "/terraform/" + remote_setup_property["spot_instance"]
583581
# fetch terraform folder
584582
path = "/terraform/{}-{}".format(setup_type, setup)
585583
terraform_working_dir = common_tf(branch, path, repo)

redisbench_admin/watchdog/watchdog.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ def get_ci_ec2_instances_by_state(ec2_client, ci_machines_prefix, requested_stat
4545
def get_vname_timeout_secs(instance):
4646
vm_name = ""
4747
timeout_secs = None
48-
for tag_dict in instance["Tags"]:
49-
key = tag_dict["Key"]
50-
key_v = tag_dict["Value"]
51-
if key == "Name":
52-
vm_name = key_v
53-
if key == "timeout_secs":
54-
timeout_secs = int(key_v)
48+
if "Tags" in instance:
49+
for tag_dict in instance["Tags"]:
50+
key = tag_dict["Key"]
51+
key_v = tag_dict["Value"]
52+
if key == "Name":
53+
vm_name = key_v
54+
if key == "timeout_secs":
55+
timeout_secs = int(key_v)
5556
return vm_name, timeout_secs
5657

5758

@@ -94,7 +95,8 @@ def termination_check(
9495
total_instances,
9596
vm_name,
9697
):
97-
if ci_machines_prefix in vm_name:
98+
# terminates also VMs without name set
99+
if ci_machines_prefix in vm_name or vm_name == "":
98100
total_instances = total_instances + 1
99101
elapsed = current_datetime - launch_time
100102
will_terminate = False

tests/test_common.py

+1
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ def test_extract_test_feasible_setups():
366366
defaults_filename = "./tests/test_data/common-properties-v0.3.yml"
367367
(
368368
default_kpis,
369+
_,
369370
default_metrics,
370371
exporter_timemetric_path,
371372
default_specs,

tests/test_compare.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def test_compare_command_logic():
134134
assert total_improvements == 0
135135
assert detected_regressions == []
136136
# ensure that we have testcases date
137-
assert "(1 datapoints)" in comment_body
137+
assert "0.0%" in comment_body
138138
assert (
139139
"Detected a total of {} stable tests between versions".format(total_tests)
140140
in comment_body

tests/test_export.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_export_command_logic():
9090
args = parser.parse_args(
9191
args=[
9292
"--benchmark-result-file",
93-
"./tests/test_data/result_report_1690282709.835491.json",
93+
"./tests/test_data/results/result_report_1690282709.835491.json",
9494
"--exporter-spec-file",
9595
"./tests/test_data/common-properties-enterprise.yml",
9696
"--redistimeseries_host",

tests/test_local.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def test_generate_standalone_redis_server_args():
124124
"--dir",
125125
".",
126126
"--loadmodule",
127-
os.path.abspath(local_module_file),
127+
local_module_file,
128128
]
129129

130130
cmd = generate_standalone_redis_server_args(
@@ -156,7 +156,7 @@ def test_generate_standalone_redis_server_args():
156156
"--dir",
157157
".",
158158
"--loadmodule",
159-
os.path.abspath(local_module_file),
159+
local_module_file,
160160
"CHUNK_SIZE_BYTES",
161161
"128",
162162
]

0 commit comments

Comments
 (0)