From f4c50619900e2153b3a83b1cb786af0888ccba87 Mon Sep 17 00:00:00 2001 From: Junghyun Kim Date: Thu, 23 Feb 2017 12:46:18 +0900 Subject: [PATCH] ADDED: inserting data to table trbs_smoke_suite_test Fixed by Jaekyu Park Change-Id: Ie5ee33f226779a1abdc6f88615bf737e5e7a8256 Signed-off-by: Junghyun Kim --- job_trbs_test_result_receiver.py | 56 ++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/job_trbs_test_result_receiver.py b/job_trbs_test_result_receiver.py index 8b0937c..add37cd 100644 --- a/job_trbs_test_result_receiver.py +++ b/job_trbs_test_result_receiver.py @@ -12,7 +12,6 @@ import datetime import base64 import MySQLdb import MySQLdb.cursors -import re #class MySQLCursorDict(mysql.connector.cursor.MySQLCursor): @@ -112,18 +111,10 @@ if __name__ == "__main__": # build_project_id 값 확인 - #select_sr_detail = ( "SELECT id, sr_status_id, pre_build_project_id, post_build_project_id, obs_request_no, obs_request_comment, obs_request_date, obs_request_status " - #"FROM sr_status_detail " - #"WHERE sr_status_id = %s " - #"ORDER BY id DESC" ) - select_sr_detail = ("SELECT bp.id " - " FROM sr_status_detail ssd, build_project bp, info_project ip" - " WHERE ssd.sr_status_id = %s " - " AND ssd.trbs_build_project_id = bp.id" - " AND bp.info_project_id = ip.id" - " AND ip.project_name LIKE '%%:Mobile:ref:%%'" - ) - + select_sr_detail = ( "SELECT id, sr_status_id, trbs_build_project_id, post_build_project_id, obs_request_no, obs_request_comment, obs_request_date, obs_request_status " + "FROM sr_status_detail " + "WHERE sr_status_id = %s " + "ORDER BY id DESC" ) print select_sr_detail query.execute( select_sr_detail, [RESULT['sr_id']] ) @@ -135,7 +126,7 @@ if __name__ == "__main__": if len( RESULT['raw']['sr_detail'] ) < 1: sys.exit("ERROR: %s was not found in database(sr_status_detail)!" % ITEM['sr']) - RESULT['build_project_id'] = RESULT['raw']['sr_detail'][0]['id'] + RESULT['build_project_id'] = RESULT['raw']['sr_detail'][0]['trbs_build_project_id'] print "build_project_id is", RESULT['build_project_id'] @@ -146,7 +137,7 @@ if __name__ == "__main__": select_snapshot = ( "SELECT build_snapshot.id, snapshot_name, snapshot_num, snapshot_url, start_time, end_time, build_snapshot.status, info_project_id " "FROM build_snapshot " "LEFT JOIN build_project ON build_project.id = build_snapshot.build_project_id " - "WHERE build_project_id = %s ORDER BY build_snapshot.id DESC" ) + "WHERE build_project_id = %s ORDER BY snapshot_num DESC" ) query.execute( select_snapshot, [RESULT['build_project_id']] ) @@ -188,6 +179,7 @@ if __name__ == "__main__": query.execute( insert_tct, value ) dbcon.commit() + print "[Write: trbs_tct] id =", value['id'] except MySQLdb.IntegrityError: print "[Error] Duplicate entry (" + key + ")-", value @@ -202,8 +194,9 @@ if __name__ == "__main__": try: query.execute( insert_tct_suite, temp ) dbcon.commit() + print "[Write: trbs_tct_suite] id =", temp['id'] except MySQLdb.IntegrityError: - print "[Error] Duplicate entry (" + key + ")-", value + print "[Error] Duplicate entry (" + key + ")-", temp elif key == 'trbs_ref': @@ -217,6 +210,7 @@ if __name__ == "__main__": try: query.execute( insert_ref, value ) dbcon.commit() + print "[Write: trbs_ref] id =", value['id'] except MySQLdb.IntegrityError: print "[Error] Duplicate entry (" + key + ")-", value @@ -232,8 +226,9 @@ if __name__ == "__main__": try: query.execute( insert_ref_suite, temp ) dbcon.commit() + print "[Write: trbs_ref_suite] id =", temp['id'] except MySQLdb.IntegrityError: - print "[Error] Duplicate entry (" + key + ")-", value + print "[Error] Duplicate entry (" + key + ")-", temp elif key == 'trbs_smoke': @@ -247,6 +242,7 @@ if __name__ == "__main__": query.execute( insert_smoke, value ) dbcon.commit() + print "[Write: trbs_smoke] id =", value['id'] except MySQLdb.IntegrityError: print "[Error] Duplicate entry (" + key + ")-", value @@ -261,8 +257,25 @@ if __name__ == "__main__": try: query.execute( insert_smoke_suite, temp ) dbcon.commit() + print "[Write: trbs_smoke_suite] id =", temp['id'] + except MySQLdb.IntegrityError: + print "[Error] Duplicate entry (" + key + ")-", temp + + + elif key == 'trbs_smoke_suite_test': + + insert_smoke_suite_test = ( "INSERT INTO trbs_smoke_suite_test (id, trbs_smoke_suite_id, name, result) " + "VALUES ( %(id)s, %(trbs_smoke_suite_id)s, %(name)s, %(result)s )" ) + + for temp in value: + try: + + query.execute( insert_smoke_suite_test, temp ) + dbcon.commit() + print "[Write: trbs_smoke_suite_test] id =", temp['id'] + except MySQLdb.IntegrityError: - print "[Error] Duplicate entry (" + key + ")-", value + print "[Error] Duplicate entry (" + key + ")-", temp elif key == 'trbs_perf': @@ -278,6 +291,7 @@ if __name__ == "__main__": query.execute( insert_perf, value ) dbcon.commit() + print "[Write: trbs_perf] id =", value['id'] except MySQLdb.IntegrityError: print "[Error] Duplicate entry (" + key + ")-", value @@ -292,8 +306,9 @@ if __name__ == "__main__": try: query.execute( insert_perf_suite, temp ) dbcon.commit() + print "[Write: trbs_perf_suite] id =", temp['id'] except MySQLdb.IntegrityError: - print "[Error] Duplicate entry (" + key + ")-", value + print "[Error] Duplicate entry (" + key + ")-", temp elif key == 'trbs_perf_suite_test': @@ -306,8 +321,9 @@ if __name__ == "__main__": try: query.execute( insert_perf_suite_test, temp ) dbcon.commit() + print "[Write: trbs_perf_suite_test] id =", temp['id'] except MySQLdb.IntegrityError: - print "[Error] Duplicate entry (" + key + ")-", value + print "[Error] Duplicate entry (" + key + ")-", temp else: -- 2.7.4