Browse Source

Fix mute utils (#13624)

Kirill Rysin 1 month ago
parent
commit
623de68f01

+ 7 - 11
.github/scripts/tests/create_new_muted_ya.py

@@ -3,13 +3,10 @@ import argparse
 import configparser
 import datetime
 import os
-import posixpath
 import re
 import ydb
 import logging
 
-from get_diff_lines_of_file import get_diff_lines_of_file
-from mute_utils import pattern_to_re
 from transform_ya_junit import YaMuteCheck
 from update_mute_issues import (
     create_and_add_issue_to_project,
@@ -181,8 +178,9 @@ def apply_and_add_mutes(all_tests, output_path, mute_check):
             for test in all_tests
             if test.get('days_in_state') >= 1
             and test.get('flaky_today')
-            and (test.get('pass_count') + test.get('fail_count')) > 3
+            and (test.get('pass_count') + test.get('fail_count')) >= 3
             and test.get('fail_count') > 2
+            and test.get('fail_count')/(test.get('pass_count') + test.get('fail_count')) > 0.2 # <=80% success rate
         )
         flaky_tests = sorted(flaky_tests)
         add_lines_to_file(os.path.join(output_path, 'flaky.txt'), flaky_tests)
@@ -193,8 +191,9 @@ def apply_and_add_mutes(all_tests, output_path, mute_check):
             for test in all_tests
             if test.get('days_in_state') >= 1
             and test.get('flaky_today')
-            and (test.get('pass_count') + test.get('fail_count')) > 3
+            and (test.get('pass_count') + test.get('fail_count')) >= 3
             and test.get('fail_count') > 2
+            and test.get('fail_count')/(test.get('pass_count') + test.get('fail_count')) > 0.2 # <=80% success rate
         )
         ## тесты может запускаться 1 раз в день. если за последние 7 дней набирается трешход то мьютим
         ## падения сегодня более весомы ??  
@@ -296,7 +295,7 @@ def read_tests_from_file(file_path):
                 testsuite, testcase = line.split(" ", maxsplit=1)
                 result.append({'testsuite': testsuite, 'testcase': testcase, 'full_name': f"{testsuite}/{testcase}"})
             except ValueError:
-                log_print(f"cant parse line: {line!r}")
+                logging.warning(f"cant parse line: {line!r}")
                 continue
     return result
 
@@ -338,9 +337,8 @@ def create_mute_issues(all_tests, file_path):
     for item in prepared_tests_by_suite:
 
         title, body = generate_github_issue_title_and_body(prepared_tests_by_suite[item])
-        result = create_and_add_issue_to_project(
-            title, body, state='Muted', owner=prepared_tests_by_suite[item][0]['owner'].split('/', 1)[1]
-        )
+        owner_value = prepared_tests_by_suite[item][0]['owner'].split('/', 1)[1] if '/' in prepared_tests_by_suite[item][0]['owner'] else prepared_tests_by_suite[item][0]['owner']
+        result = create_and_add_issue_to_project(title, body, state='Muted', owner=owner_value)
         if not result:
             break
         else:
@@ -374,8 +372,6 @@ def mute_worker(args):
         credentials=ydb.credentials_from_env_variables(),
     ) as driver:
         driver.wait(timeout=10, fail_fast=True)
-        session = ydb.retry_operation_sync(lambda: driver.table_client.session().create())
-        tc_settings = ydb.TableClientSettings().with_native_date_in_result_sets(enabled=True)
 
         all_tests = execute_query(driver)
     if args.mode == 'update_muted_ya':

+ 1 - 2
.github/scripts/tests/update_mute_issues.py

@@ -329,7 +329,6 @@ def generate_github_issue_title_and_body(test_data):
     test_run_history_link = f"{CURRENT_TEST_HISTORY_DASHBOARD}{test_run_history_params}"
 
     # owner
-    owner_link = f"[{owner}](https://github.com/orgs/ydb-platform/teams/{owner.split('/',1)[1]})"
     # Тело сообщения и кодирование
     body_template = (
         f"Mute:<!--mute_list_start-->\n"
@@ -449,7 +448,7 @@ def get_muted_tests_from_issues():
     issues = get_issues_and_tests_from_project(ORG_NAME, PROJECT_ID)
     muted_tests = {}
     for issue in issues:
-        if issues[issue]["status"] == "Muted":
+        if issues[issue]["status"] == "Muted" and issues[issue]["state"] != 'CLOSED':
             for test in issues[issue]['tests']:
                 if test not in muted_tests:
                     muted_tests[test] = []