From cbbc33a2abb9335883d80eab67c013bc7e183e05 Mon Sep 17 00:00:00 2001 From: Taejin Woo Date: Mon, 9 Jul 2018 18:06:37 +0900 Subject: [PATCH] Add dtr_smoke tables and values Change-Id: I59697808698ca180c9ae97a594b1ba34334ce01d Signed-off-by: Taejin Woo --- dtr/job_dtr_db_write.py | 35 ++++++++++++++++ dtr/job_dtr_status.py | 108 +++++++++++++++++++++++++++++++++++++----------- 2 files changed, 120 insertions(+), 23 deletions(-) diff --git a/dtr/job_dtr_db_write.py b/dtr/job_dtr_db_write.py index ea6c463..0b0aefd 100644 --- a/dtr/job_dtr_db_write.py +++ b/dtr/job_dtr_db_write.py @@ -43,6 +43,37 @@ def dtr_target_lookup_insert_fun(TOTAL_INFO): disconnect_db() +def dtr_test_comment_insert_fun(TOTAL_INFO): + connect_db() + + query = "INSERT INTO dtr_smoke_comment_result (test_case, comments) VALUES(%s, %s)" + + query_var_list = [] + for sample_DB_values in TOTAL_INFO['smoke_comment_data']['smoke_comment_DB_values']: + query_var_list.append( sample_DB_values ) + + pprint.pprint(query_var_list) + do_many_query(query, query_var_list) + pprint.pprint(do_many_query) + + disconnect_db() + + +def dtr_smoke_result_insert_fun(TOTAL_INFO): + connect_db() + + query = "INSERT INTO dtr_smoke_envorin_result (result, test_case, smoke_comment_id , target_lookup_id) VALUES(%s, %s, %s, %s)" + + query_var_list = [] + for sample_DB_values in TOTAL_INFO['smoke_value_data']['smoke_value_DB_values']: + query_var_list.append( sample_DB_values ) + + pprint.pprint(query_var_list) + do_many_query(query, query_var_list) + pprint.pprint(do_many_query) + + disconnect_db() + def dtr_tbt_insert_fun(TOTAL_INFO): connect_db() @@ -99,6 +130,10 @@ def main(TOTAL_INFO): ## 1. Lookup table data dtr_target_lookup_insert_fun(TOTAL_INFO) + ## 2. Smoke test suite & comment data + dtr_test_comment_insert_fun(TOTAL_INFO) + dtr_smoke_result_insert_fun(TOTAL_INFO) + ## 3. TBT table dtr_tbt_insert_fun(TOTAL_INFO) diff --git a/dtr/job_dtr_status.py b/dtr/job_dtr_status.py index 96b7d24..ad01ffb 100644 --- a/dtr/job_dtr_status.py +++ b/dtr/job_dtr_status.py @@ -128,6 +128,58 @@ def dtr_smoke_menu_export(sheet, srbd_data, test_ver_info_dict): return total_results + +def dtr_smoke_result_export(sheet, srbd_data): + ncol = sheet.ncols + nrow = sheet.nrows + + total_results = {} + total_results['test_cases'] = [] + total_results['comments'] = [] + + total_results['row'] = nrow + total_results['col'] = ncol + + test_case_list = [] + comment_list = [] + for row in range(0, nrow): + test_case_list.append(sheet.cell(row, 0).value) + comment_list.append(sheet.cell(row, ncol-1).value) + + for i in range(0, len(test_case_list)): + total_results[test_case_list[i]] = [] + total_results['test_cases'].append(test_case_list[i]) + total_results['comments'].append(comment_list[i]) + + for row in range(0, nrow): + for col in range(1, ncol-1): + try: + test_suite = total_results['test_cases'][row] + total_results[test_suite].append(sheet.cell(row, col).value) + except Exception as ex: + print('error' , ex) + + return total_results + +def dtr_smoke_comment_DB_export(MIDDLE_INFO, arg_name): + total_results = {} + total_results[arg_name] = [] + + case_list = [] + comment_list = [] + + for test_case in MIDDLE_INFO['smoke_result_data']['test_cases']: + case_list.append(test_case) + for comment in MIDDLE_INFO['smoke_result_data']['comments']: + comment_list.append(comment) + + for i in range(0, len(case_list)): + total_results[arg_name].append((case_list[i],comment_list[i])) + +# pprint.pprint(total_results) + + return total_results + ##################### 1. 2. Combine ######################### def dtr_target_lookup_DB_export(MIDDLE_INFO, arg_name): total_results = {} @@ -159,35 +211,34 @@ def dtr_target_lookup_DB_export(MIDDLE_INFO, arg_name): return total_results -def dtr_smoke_result_export(sheet, srbd_data): - ncol = sheet.ncols - nrow = sheet.nrows +def dtr_smoke_value_DB_export(MIDDLE_INFO, arg_name): total_results = {} - total_results['test_cases'] = [] - total_results['comments'] = [] + total_results['var_list'] = [] + total_results['test_case'] = [] + total_results['smoke_result_list'] = [] + total_results[arg_name] = [] - total_results['row'] = nrow - total_results['col'] = ncol + for menus in MIDDLE_INFO['smoke_menu_data']['var_list']: + total_results['var_list'].append(menus) - test_case_list = [] - comment_list = [] - for row in range(0, nrow): - test_case_list.append(sheet.cell(row, 0).value) - comment_list.append(sheet.cell(row, ncol-1).value) + for test_case in MIDDLE_INFO['smoke_result_data']['test_cases']: + total_results['test_case'].append(test_case) - for i in range(0, len(test_case_list)): - total_results[test_case_list[i]] = [] - total_results['test_cases'].append(test_case_list[i]) - total_results['comments'].append(comment_list[i]) + case_list = [] + for test_case in MIDDLE_INFO['smoke_result_data']['test_cases']: + case_list.append(test_case) - for row in range(0, nrow): - for col in range(1, ncol-1): - try: - test_suite = total_results['test_cases'][row] - total_results[test_suite].append(sheet.cell(row, col).value) - except Exception as ex: - print('error' , ex) + result_list = [] + for case in case_list: + total_results['smoke_result_list'].append(MIDDLE_INFO['smoke_result_data'][case]) + + for case_idx, test_case_value in enumerate(total_results['test_case']): + tmp_value = total_results['smoke_result_list'][case_idx] + for value_idx, result_value in enumerate(tmp_value): + total_results[arg_name].append((result_value, test_case_value, case_idx+1, value_idx+1)) + +# pprint.pprint(total_results) return total_results @@ -243,6 +294,8 @@ def main(): smoke_menu_data = {} smoke_result_data = {} + smoke_comment_data = {} + smoke_value_data = {} tbt_menu_data = {} tbt_result_data = {} @@ -258,6 +311,11 @@ def main(): smoke_menu_dict = {} smoke_result_dict = {} + smoke_comment_dict = {} + smoke_result_DB_dict = {} + + dtr_target_lookup_dict = {} + dtr_smoke_result_dict = {} tbt_menu_dict = {} tbt_result_dict = {} @@ -301,6 +359,8 @@ def main(): } target_lookup_DB_dict = dtr_target_lookup_DB_export(MIDDLE_INFO, "lookup_DB_values") + smoke_comment_DB_dict = dtr_smoke_comment_DB_export(MIDDLE_INFO, "smoke_comment_DB_values") + smoke_value_DB_dict = dtr_smoke_value_DB_export(MIDDLE_INFO, "smoke_value_DB_values") ## 3. DTR TBT data tbt_menu_dict = dtr_general_menu_export(tbt_menu_sheet, tbt_menu_data, "tbt_menus") @@ -318,6 +378,8 @@ def main(): 'test_ver_info_data' : test_ver_info_dict, 'smoke_menu_data' : smoke_menu_dict, 'smoke_result_data' : smoke_result_dict, + 'smoke_comment_data' : smoke_comment_DB_dict, + 'smoke_value_data' : smoke_value_DB_dict, 'target_lookup_data' : target_lookup_DB_dict, 'tbt_menu_data' : tbt_menu_dict, 'tbt_result_data' : tbt_result_dict, -- 2.7.4