20
20
update_comment_if_needed ,
21
21
create_new_pr_comment ,
22
22
check_github_available_and_actionable ,
23
+ check_regression_comment ,
23
24
)
24
25
from redis_benchmarks_specification .__compare__ .args import create_compare_arguments
25
26
@@ -165,45 +166,9 @@ def compare_command_logic(args, project_name, project_version):
165
166
username = args .redistimeseries_user ,
166
167
)
167
168
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
+ )
207
172
208
173
tf_github_org = args .github_org
209
174
tf_github_repo = args .github_repo
@@ -300,25 +265,7 @@ def compare_command_logic(args, project_name, project_version):
300
265
) = check_github_available_and_actionable (
301
266
fn , github_token , pull_request , tf_github_org , tf_github_repo , verbose
302
267
)
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"
322
269
323
270
(
324
271
detected_regressions ,
@@ -358,7 +305,71 @@ def compare_command_logic(args, project_name, project_version):
358
305
use_metric_context_path ,
359
306
running_platform ,
360
307
)
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
+ ):
362
373
if total_comparison_points > 0 :
363
374
comment_body = "### Automated performance analysis summary\n \n "
364
375
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):
386
397
)
387
398
if total_regressions > 0 :
388
399
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
390
401
)
391
402
392
403
comment_body += comparison_summary
@@ -430,19 +441,6 @@ def compare_command_logic(args, project_name, project_version):
430
441
zset_project_pull_request , comparison_branch , res
431
442
)
432
443
)
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
- )
446
444
447
445
if contains_regression_comment :
448
446
update_comment_if_needed (
@@ -457,26 +455,47 @@ def compare_command_logic(args, project_name, project_version):
457
455
458
456
else :
459
457
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
- )
469
458
470
459
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
480
499
481
500
482
501
def compute_regression_table (
@@ -996,7 +1015,8 @@ def get_test_names_from_db(rts, tags_regex_string, test_names, used_key):
996
1015
test_names .sort ()
997
1016
final_test_names = []
998
1017
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 ()
1000
1020
match_obj = re .search (tags_regex_string , test_name )
1001
1021
if match_obj is not None :
1002
1022
final_test_names .append (test_name )
0 commit comments