Ejemplo n.º 1
0
def generate_triage_history_data(db_conn, project_name, file_path):
    # triage_history_sql = "SELECT * FROM `automation_case_results` where triage_result is not NULL and error_type_id in (select id from error_types where name in ('Product Error', 'Product Change')) and automation_script_result_id in (select id from automation_script_results where triage_result is not NULL and automation_script_id in (select id from automation_scripts where project_id=2))"
    # triage_history_sql = "SELECT * FROM `automation_case_results` where error_type_id in (select id from error_types) and automation_script_result_id in (select id from automation_script_results where automation_script_id in (select id from automation_scripts where project_id=2))"
    triage_history_sql = """
        SELECT tr.id as round_id, acr.automation_case_id, asr.automation_script_id, te.name as env, b.name as browser, et.name as triage_type, acr.error_message, (UNIX_TIMESTAMP(asr.end_time)-UNIX_TIMESTAMP(asr.start_time)) as script_duration FROM `automation_case_results` as acr
        left join `automation_script_results` as asr on acr.automation_script_result_id=asr.id
        left join `test_rounds` as tr on asr.test_round_id=tr.id
        left join `test_environments` as te on tr.test_environment_id=te.id
        left join `browsers` as b on tr.browser_id=b.id
        left join `projects` as p on p.id=tr.project_id
        left join `error_types` as et on et.id=acr.error_type_id
        where p.name='%s' and et.name is not NULL  
        ORDER BY `round_id`  ASC
    """ % project_name
    print("generate triage history data of project: %s" % project_name)
    triage_history_data = db_conn.get_all_results_from_database(
        triage_history_sql)
    if len(triage_history_data) == 0:
        print("no triage history in project: %s" % project_name)
        return False
    else:
        FileHelper.save_db_query_result_to_csv(triage_history_data, file_path)
        print(
            "there are %d rows in database when query the triage history of project: %s\n"
            % (len(triage_history_data), project_name))
        return True
Ejemplo n.º 2
0
def generate_test_round_results_data(db_conn,
                                     file_path,
                                     round_id=None,
                                     script_id=None,
                                     case_id=None):
    # test_round_results_sql = "SELECT * FROM automation_case_results where automation_script_result_id in (2609677, 2609831, 2609879, 2609971, 2610080, 2610095, 2610333, 2610366, 2610380, 2610415, 2609629, 2609636, 2609638, 2609644, 2609651, 2609663);"
    if case_id:
        test_round_results_sql = "SELECT * FROM automation_case_results where id=%d;" % int(
            case_id)
    elif script_id:
        test_round_results_sql = "SELECT * FROM automation_case_results where automation_script_result_id=%d;" % int(
            script_id)
    else:
        test_round_results_sql = "SELECT * FROM automation_case_results where automation_script_result_id in (select id from automation_script_results where test_round_id=%d);" % int(
            round_id)
    print("generate test round all results data")
    test_round_results = db_conn.get_all_results_from_database(
        test_round_results_sql)
    if len(test_round_results) == 0:
        print("no result in this test round with id: %d" % int(round_id))
        return False
    else:
        FileHelper.save_db_query_result_to_csv(test_round_results, file_path)
        print(
            "there are %d rows in database when query the round all results\n"
            % len(test_round_results))
        return True
Ejemplo n.º 3
0
 def generate_regression_history_data(db_conn, project_id, file_path):
     generate_flag = Config.load_env("generate_regression_history")
     if not os.path.exists(file_path):
         generate_flag = True
     if generate_flag:
         print("generate history regression data")
         # select history data of 12 month for reference
         period_regression_sql = "select * from test_rounds where project_id=%d and DATE_SUB(CURDATE(), INTERVAL 12 MONTH) <= date(start_time) and end_time is not NULL;" % int(project_id)
         period_regression_history = db_conn.get_all_results_from_database(period_regression_sql)
         FileHelper.save_db_query_result_to_csv(period_regression_history, file_path)
         print("there are %d rows in database when query the history\n" % len(period_regression_history))
     else:
         print("NOT generate history regression data\n")
Ejemplo n.º 4
0
def generate_test_round_errors_data(db_conn, round_id, file_path):
    test_round_errors_sql = "SELECT * FROM automation_case_results where automation_script_result_id in (select id from automation_script_results where test_round_id=%d) and result = 'failed';" % int(
        round_id)
    print("generate test round errors data")
    test_round_errors = db_conn.get_all_results_from_database(
        test_round_errors_sql)
    if len(test_round_errors) == 0:
        print("no errors in this test round with id: %d" % int(round_id))
        return False
    else:
        FileHelper.save_db_query_result_to_csv(test_round_errors, file_path)
        print("there are %d rows in database when query the round error\n" %
              len(test_round_errors))
        return True
Ejemplo n.º 5
0
def generate_triage_history_data(db_conn, project_name, file_path):
    # triage_history_sql = "SELECT * FROM `automation_case_results` where triage_result is not NULL and error_type_id in (select id from error_types where name in ('Product Error', 'Product Change')) and automation_script_result_id in (select id from automation_script_results where triage_result is not NULL and automation_script_id in (select id from automation_scripts where project_id=2))"
    # triage_history_sql = "SELECT * FROM `automation_case_results` where error_type_id in (select id from error_types) and automation_script_result_id in (select id from automation_script_results where automation_script_id in (select id from automation_scripts where project_id=2))"
    triage_history_sql = "select * from prejudge_seeds where project_name='%s'" % project_name
    print("generate triage history data")
    triage_history = db_conn.get_all_results_from_database(triage_history_sql)
    if len(triage_history) == 0:
        print("no triage history in project: %s" % project_name)
        return False
    else:
        FileHelper.save_db_query_result_to_csv(triage_history, file_path)
        print(
            "there are %d rows in database when query the triage history of project: %s\n"
            % (len(triage_history), project_name))
        return True