Skip to content

Commit 20e30ef

Browse files
Adding regression comment in case of PR run of coordinator
1 parent 5177da0 commit 20e30ef

File tree

5 files changed

+341
-153
lines changed

5 files changed

+341
-153
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 = "redis-benchmarks-specification"
3-
version = "0.1.94"
3+
version = "0.1.101"
44
description = "The Redis benchmarks specification describes the cross-language/tools requirements and expectations to foster performance and observability standards around redis related technologies. Members from both industry and academia, including organizations and individuals are encouraged to contribute."
55
authors = ["filipecosta90 <[email protected]>","Redis Performance Group <[email protected]>"]
66
readme = "Readme.md"

redis_benchmarks_specification/__common__/github.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
from github import Github
33

44

5+
def check_regression_comment(comments):
6+
res = False
7+
pos = -1
8+
for n, comment in enumerate(comments):
9+
body = comment.body
10+
if "Comparison between" in body and "Time Period from" in body:
11+
res = True
12+
pos = n
13+
return res, pos
14+
15+
516
def generate_build_started_pr_comment(
617
build_datetime,
718
commit_datetime,

redis_benchmarks_specification/__compare__/compare.py

Lines changed: 112 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
update_comment_if_needed,
2121
create_new_pr_comment,
2222
check_github_available_and_actionable,
23+
check_regression_comment,
2324
)
2425
from redis_benchmarks_specification.__compare__.args import create_compare_arguments
2526

@@ -165,45 +166,9 @@ def compare_command_logic(args, project_name, project_version):
165166
username=args.redistimeseries_user,
166167
)
167168
rts.ping()
168-
default_baseline_branch = None
169-
default_metrics_str = ""
170-
if args.defaults_filename != "" and os.path.exists(args.defaults_filename):
171-
logging.info(
172-
"Loading configuration from defaults file: {}".format(
173-
args.defaults_filename
174-
)
175-
)
176-
with open(args.defaults_filename) as yaml_fd:
177-
defaults_dict = yaml.safe_load(yaml_fd)
178-
if "exporter" in defaults_dict:
179-
exporter_dict = defaults_dict["exporter"]
180-
if "comparison" in exporter_dict:
181-
comparison_dict = exporter_dict["comparison"]
182-
if "metrics" in comparison_dict:
183-
metrics = comparison_dict["metrics"]
184-
logging.info("Detected defaults metrics info. reading metrics")
185-
default_metrics = []
186-
187-
for metric in metrics:
188-
if metric.startswith("$."):
189-
metric = metric[2:]
190-
logging.info("Will use metric: {}".format(metric))
191-
default_metrics.append(metric)
192-
if len(default_metrics) == 1:
193-
default_metrics_str = default_metrics[0]
194-
if len(default_metrics) > 1:
195-
default_metrics_str = "({})".format(
196-
",".join(default_metrics)
197-
)
198-
logging.info("Default metrics: {}".format(default_metrics_str))
199-
200-
if "baseline-branch" in comparison_dict:
201-
default_baseline_branch = comparison_dict["baseline-branch"]
202-
logging.info(
203-
"Detected baseline branch in defaults file. {}".format(
204-
default_baseline_branch
205-
)
206-
)
169+
default_baseline_branch, default_metrics_str = extract_default_branch_and_metric(
170+
args.defaults_filename
171+
)
207172

208173
tf_github_org = args.github_org
209174
tf_github_repo = args.github_repo
@@ -300,25 +265,7 @@ def compare_command_logic(args, project_name, project_version):
300265
) = check_github_available_and_actionable(
301266
fn, github_token, pull_request, tf_github_org, tf_github_repo, verbose
302267
)
303-
304-
grafana_dashboards_uids = {
305-
"redisgraph": "SH9_rQYGz",
306-
"redisbloom": "q4-5sRR7k",
307-
"redisearch": "3Ejv2wZnk",
308-
"redisjson": "UErSC0jGk",
309-
"redistimeseries": "2WMw61UGz",
310-
}
311-
uid = None
312-
if tf_github_repo.lower() in grafana_dashboards_uids:
313-
uid = grafana_dashboards_uids[tf_github_repo.lower()]
314-
grafana_link_base = None
315-
if uid is not None:
316-
grafana_link_base = "{}/{}".format(grafana_base_dashboard, uid)
317-
logging.info(
318-
"There is a grafana dashboard for this repo. Base link: {}".format(
319-
grafana_link_base
320-
)
321-
)
268+
grafana_link_base = "https://benchmarksredisio.grafana.net/d/1fWbtb7nz/experimental-oss-spec-benchmarks"
322269

323270
(
324271
detected_regressions,
@@ -358,7 +305,71 @@ def compare_command_logic(args, project_name, project_version):
358305
use_metric_context_path,
359306
running_platform,
360307
)
361-
comment_body = ""
308+
prepare_regression_comment(
309+
auto_approve,
310+
baseline_branch,
311+
baseline_tag,
312+
comparison_branch,
313+
comparison_tag,
314+
contains_regression_comment,
315+
github_pr,
316+
grafana_link_base,
317+
is_actionable_pr,
318+
old_regression_comment_body,
319+
pr_link,
320+
regression_comment,
321+
rts,
322+
running_platform,
323+
table_output,
324+
tf_github_org,
325+
tf_github_repo,
326+
tf_triggering_env,
327+
total_comparison_points,
328+
total_improvements,
329+
total_regressions,
330+
total_stable,
331+
total_unstable,
332+
verbose,
333+
args.regressions_percent_lower_limit,
334+
)
335+
return (
336+
detected_regressions,
337+
"",
338+
total_improvements,
339+
total_regressions,
340+
total_stable,
341+
total_unstable,
342+
total_comparison_points,
343+
)
344+
345+
346+
def prepare_regression_comment(
347+
auto_approve,
348+
baseline_branch,
349+
baseline_tag,
350+
comparison_branch,
351+
comparison_tag,
352+
contains_regression_comment,
353+
github_pr,
354+
grafana_link_base,
355+
is_actionable_pr,
356+
old_regression_comment_body,
357+
pr_link,
358+
regression_comment,
359+
rts,
360+
running_platform,
361+
table_output,
362+
tf_github_org,
363+
tf_github_repo,
364+
tf_triggering_env,
365+
total_comparison_points,
366+
total_improvements,
367+
total_regressions,
368+
total_stable,
369+
total_unstable,
370+
verbose,
371+
regressions_percent_lower_limit,
372+
):
362373
if total_comparison_points > 0:
363374
comment_body = "### Automated performance analysis summary\n\n"
364375
comment_body += "This comment was automatically generated given there is performance data available.\n\n"
@@ -386,7 +397,7 @@ def compare_command_logic(args, project_name, project_version):
386397
)
387398
if total_regressions > 0:
388399
comparison_summary += "- Detected a total of {} regressions bellow the regression water line {}.\n".format(
389-
total_regressions, args.regressions_percent_lower_limit
400+
total_regressions, regressions_percent_lower_limit
390401
)
391402

392403
comment_body += comparison_summary
@@ -430,19 +441,6 @@ def compare_command_logic(args, project_name, project_version):
430441
zset_project_pull_request, comparison_branch, res
431442
)
432443
)
433-
user_input = "n"
434-
html_url = "n/a"
435-
(
436-
baseline_str,
437-
by_str_baseline,
438-
comparison_str,
439-
by_str_comparison,
440-
) = get_by_strings(
441-
baseline_branch,
442-
comparison_branch,
443-
baseline_tag,
444-
comparison_tag,
445-
)
446444

447445
if contains_regression_comment:
448446
update_comment_if_needed(
@@ -457,26 +455,47 @@ def compare_command_logic(args, project_name, project_version):
457455

458456
else:
459457
logging.error("There was no comparison points to produce a table...")
460-
return (
461-
detected_regressions,
462-
comment_body,
463-
total_improvements,
464-
total_regressions,
465-
total_stable,
466-
total_unstable,
467-
total_comparison_points,
468-
)
469458

470459

471-
def check_regression_comment(comments):
472-
res = False
473-
pos = -1
474-
for n, comment in enumerate(comments):
475-
body = comment.body
476-
if "Comparison between" in body and "Time Period from" in body:
477-
res = True
478-
pos = n
479-
return res, pos
460+
def extract_default_branch_and_metric(defaults_filename):
461+
default_baseline_branch = "unstable"
462+
default_metrics_str = ""
463+
if defaults_filename != "" and os.path.exists(defaults_filename):
464+
logging.info(
465+
"Loading configuration from defaults file: {}".format(defaults_filename)
466+
)
467+
with open(defaults_filename) as yaml_fd:
468+
defaults_dict = yaml.safe_load(yaml_fd)
469+
if "exporter" in defaults_dict:
470+
exporter_dict = defaults_dict["exporter"]
471+
if "comparison" in exporter_dict:
472+
comparison_dict = exporter_dict["comparison"]
473+
if "metrics" in comparison_dict:
474+
metrics = comparison_dict["metrics"]
475+
logging.info("Detected defaults metrics info. reading metrics")
476+
default_metrics = []
477+
478+
for metric in metrics:
479+
if metric.startswith("$."):
480+
metric = metric[2:]
481+
logging.info("Will use metric: {}".format(metric))
482+
default_metrics.append(metric)
483+
if len(default_metrics) == 1:
484+
default_metrics_str = default_metrics[0]
485+
if len(default_metrics) > 1:
486+
default_metrics_str = "({})".format(
487+
",".join(default_metrics)
488+
)
489+
logging.info("Default metrics: {}".format(default_metrics_str))
490+
491+
if "baseline-branch" in comparison_dict:
492+
default_baseline_branch = comparison_dict["baseline-branch"]
493+
logging.info(
494+
"Detected baseline branch in defaults file. {}".format(
495+
default_baseline_branch
496+
)
497+
)
498+
return default_baseline_branch, default_metrics_str
480499

481500

482501
def compute_regression_table(
@@ -996,7 +1015,8 @@ def get_test_names_from_db(rts, tags_regex_string, test_names, used_key):
9961015
test_names.sort()
9971016
final_test_names = []
9981017
for test_name in test_names:
999-
test_name = test_name.decode()
1018+
if not isinstance(test_name, str):
1019+
test_name = test_name.decode()
10001020
match_obj = re.search(tags_regex_string, test_name)
10011021
if match_obj is not None:
10021022
final_test_names.append(test_name)

redis_benchmarks_specification/__self_contained_coordinator__/args.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import argparse
2+
import datetime
23
import os
34
from redis_benchmarks_specification.__common__.env import (
45
MACHINE_CPU_COUNT,
@@ -19,6 +20,10 @@
1920
PROFILERS_DEFAULT,
2021
ALLOWED_PROFILERS,
2122
)
23+
from redis_benchmarks_specification.__compare__.args import (
24+
START_TIME_NOW_UTC,
25+
START_TIME_LAST_SIX_MONTHS_UTC,
26+
)
2227

2328
PERFORMANCE_GH_TOKEN = os.getenv("PERFORMANCE_GH_TOKEN", None)
2429

0 commit comments

Comments
 (0)