From: jiseob.jang Date: Wed, 30 Aug 2017 05:35:05 +0000 (+0900) Subject: [Tizen.Net] add inserting the app list related to run app in test. X-Git-Tag: submit/trunk/20190927.012743~297^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=08397b1f93bd7e9a98a14984491a9003b36d7c96;p=services%2Fjenkins-scripts.git [Tizen.Net] add inserting the app list related to run app in test. Change-Id: I39856ce08b517d97426a2f124f753f6d3d0bbcfd Signed-off-by: jiseob.jang --- diff --git a/job_add_dotnet_launching_performance_test.py b/job_add_dotnet_launching_performance_test.py index 4ba0dea..d2b8bf4 100644 --- a/job_add_dotnet_launching_performance_test.py +++ b/job_add_dotnet_launching_performance_test.py @@ -121,14 +121,16 @@ def main(): mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['select_build_snapshot']) build_snapshot_id = MYSQL['cursor'].fetchone()['id'] print "[Write] build_snapshot id =", build_snapshot_id - + # insert build_image MYSQL['query']['insert_build_image'] = "INSERT INTO build_image (build_snapshot_id, repository, device_name, start_time, end_time, status, image_size, image_url) SELECT '%s', '%s', '%s', FROM_UNIXTIME(UNIX_TIMESTAMP()), FROM_UNIXTIME(UNIX_TIMESTAMP()), 'succeeded', 300000000, '%s' FROM DUAL WHERE NOT EXISTS ( SELECT * FROM build_image WHERE build_snapshot_id=%s );" % (build_snapshot_id, repository, device_name, snapshot_name, build_snapshot_id) mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_build_image']) # get build_image_id - MYSQL['query']['select_build_image'] = "SELECT id FROM build_image WHERE build_snapshot_id=%s AND repository='%s' AND device_name='%s'" % (build_snapshot_id, repository, device_name) + MYSQL['query']['select_build_image'] = "SELECT id FROM build_image \ + WHERE build_snapshot_id=%s AND repository='%s' AND device_name='%s'" \ + % (build_snapshot_id, repository, device_name) mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['select_build_image']) build_image_id = MYSQL['cursor'].fetchone()['id'] print "[Write] build_image id =", build_image_id @@ -139,7 +141,10 @@ def main(): pkg_id = app_info['pkg_id'] app_id = app_info['app_id'] app_type = app_info['app_type'] - MYSQL['query']['insert_application_info'] = "INSERT INTO application_info (name, app_id, pkg_id, app_type) SELECT '%s', '%s', '%s', '%s' FROM DUAL WHERE NOT EXISTS ( SELECT * FROM application_info WHERE app_id='%s' AND pkg_id='%s' );" % (pkg_id, app_id, pkg_id, app_type, app_id, pkg_id) + MYSQL['query']['insert_application_info'] = "INSERT INTO application_info \ + (name, app_id, pkg_id, app_type) SELECT '%s', '%s', '%s', '%s' FROM DUAL WHERE NOT EXISTS \ + ( SELECT * FROM application_info WHERE app_id='%s' AND pkg_id='%s' );" \ + % (pkg_id, app_id, pkg_id, app_type, app_id, pkg_id) mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_application_info']) # get launching_performance_test_id @@ -153,16 +158,39 @@ def main(): tpk_dotnet_app_count = TEST_DATA['tpk_dotnet_app_count'] installed_dotnet_app_count = TEST_DATA['installed_dotnet_app_count'] launched_dotnet_app_count = TEST_DATA['launched_dotnet_app_count'] - MYSQL['query']['insert_launching_performance_test'] = "INSERT INTO launching_performance_test (build_image_id, average_time, tpk_dotnet_app_count, installed_dotnet_app_count, launched_dotnet_app_count, test_date) SELECT %s, %s, %s, %s, %s, FROM_UNIXTIME(UNIX_TIMESTAMP()) FROM DUAL WHERE NOT EXISTS ( SELECT * FROM launching_performance_test WHERE build_image_id=%s AND average_time=%s );" % (build_image_id, average_time, tpk_dotnet_app_count, installed_dotnet_app_count, launched_dotnet_app_count, build_image_id, average_time) -# MYSQL['query']['insert_launching_performance_test'] = "INSERT INTO launching_performance_test (build_image_id, average_time, test_date) VALUES (%s, %s, FROM_UNIXTIME(UNIX_TIMESTAMP()) );" % (build_image_id, average_time) + MYSQL['query']['insert_launching_performance_test'] = "INSERT INTO launching_performance_test \ + (build_image_id, average_time, tpk_dotnet_app_count, installed_dotnet_app_count, launched_dotnet_app_count, test_date) \ + SELECT %s, %s, %s, %s, %s, FROM_UNIXTIME(UNIX_TIMESTAMP()) ON DUPLICATE KEY UPDATE build_image_id=%s;" \ + % (build_image_id, average_time, tpk_dotnet_app_count, installed_dotnet_app_count, launched_dotnet_app_count, build_image_id) mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_launching_performance_test']) # get launching_performance_test_id - MYSQL['query']['select_launching_performance_test'] = "SELECT id FROM launching_performance_test WHERE build_image_id=%s AND average_time=%s;" % (build_image_id, average_time) + MYSQL['query']['select_launching_performance_test'] = "SELECT id FROM launching_performance_test WHERE build_image_id=%s AND average_time=%s;" \ + % (build_image_id, average_time) mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['select_launching_performance_test']) launching_performance_test_id = MYSQL['cursor'].fetchone()['id'] print "[Write] launching_performance_test id =", launching_performance_test_id + # delete launching_performance data with the same build_image_id to prevent duplicate insertion. + MYSQL['query']['delete_launching_performance_conditionally'] = "DELETE FROM \ + launching_performance WHERE build_image_id=%d;" % (build_image_id) + mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['delete_launching_performance_conditionally']) + + # delete launching_performance_test_tpk_app data with the same build_image_id to prevent duplicate insertion. + MYSQL['query']['delete_launching_performance_test_tpk_app_conditionally'] = "DELETE FROM \ + launching_performance_test_tpk_app WHERE build_image_id=%d;" % (build_image_id) + mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['delete_launching_performance_test_tpk_app_conditionally']) + + # delete launching_performance_test_installed_app data with the same build_image_id to prevent duplicate insertion. + MYSQL['query']['delete_launching_performance_test_installed_app_conditionally'] = "DELETE FROM \ + launching_performance_test_installed_app WHERE build_image_id=%d;" % (build_image_id) + mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['delete_launching_performance_test_installed_app_conditionally']) + + # delete launching_performance_test_launched_app data with the same build_image_id to prevent duplicate insertion. + MYSQL['query']['delete_launching_performance_test_launched_app_conditionally'] = "DELETE FROM \ + launching_performance_test_launched_app WHERE build_image_id=%d;" % (build_image_id) + mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['delete_launching_performance_test_launched_app_conditionally']) + # get application_info_id app_info_ids = {} MYSQL['query']['select_application_info'] = "SELECT id, app_id FROM application_info;" @@ -186,10 +214,47 @@ def main(): # application_info_id = MYSQL['cursor'].fetchone()['id'] # print "[Write] application_info id =", application_info_id - MYSQL['query']['insert_launching_performance'] = "INSERT INTO launching_performance (launching_performance_test_id, build_image_id, application_info_id, launching_time) SELECT %s, %s, %s, %s FROM DUAL WHERE NOT EXISTS ( SELECT * FROM launching_performance WHERE launching_performance_test_id=%s AND application_info_id=%s );" % (launching_performance_test_id, build_image_id, application_info_id, launching_time, launching_performance_test_id, application_info_id) # MYSQL['query']['insert_launching_performance'] = "INSERT INTO launching_performance (launching_performance_test_id, build_image_id, application_info_id, launching_time) VALUES (%s, %s, %s, %s);" % (launching_performance_test_id, build_image_id, application_info_id, launching_time) + # insert launching_performance + MYSQL['query']['insert_launching_performance'] = "INSERT INTO launching_performance \ + (launching_performance_test_id, build_image_id, application_info_id, launching_time) \ + SELECT %s, %s, %s, %s FROM DUAL WHERE NOT EXISTS \ + ( SELECT * FROM launching_performance WHERE launching_performance_test_id=%s AND application_info_id=%s );" \ + % (launching_performance_test_id, build_image_id, application_info_id, launching_time, launching_performance_test_id, application_info_id) mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_launching_performance']) + # insert launching_performance_test_launched_app + MYSQL['query']['insert_launching_performance_test_launched_app'] = "INSERT INTO launching_performance_test_launched_app \ + (build_image_id, test_id, application_info_id) \ + SELECT %s, %s, %s FROM DUAL WHERE NOT EXISTS \ + ( SELECT * FROM launching_performance_test_launched_app WHERE test_id=%s AND application_info_id=%s );" \ + % (build_image_id, launching_performance_test_id, application_info_id, launching_performance_test_id, application_info_id) + mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_launching_performance_test_launched_app']) + + # insert launching_performance_test_installed_app + installed_app_list = TEST_DATA['installed_app_list'] + for installed_app in installed_app_list: + app_id = installed_app['app_id'] + pkg_id = installed_app['pkg_id'] + application_info_id = app_info_ids[app_id] + MYSQL['query']['insert_launching_performance_test_installed_app'] = "INSERT INTO launching_performance_test_installed_app \ + (build_image_id, test_id, application_info_id) \ + SELECT %s, %s, %s FROM DUAL WHERE NOT EXISTS \ + ( SELECT * FROM launching_performance_test_installed_app WHERE test_id=%s AND application_info_id=%s );" \ + % (build_image_id, launching_performance_test_id, application_info_id, launching_performance_test_id, application_info_id) + mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_launching_performance_test_installed_app']) + + # insert launching_performance_test_tpk_app + for app_info in app_list: + app_id = app_info['app_id'] + application_info_id = app_info_ids[app_id] + MYSQL['query']['insert_launching_performance_test_tpk_app'] = "INSERT INTO launching_performance_test_tpk_app \ + (build_image_id, test_id, application_info_id) \ + SELECT %s, %s, %s FROM DUAL WHERE NOT EXISTS \ + ( SELECT * FROM launching_performance_test_tpk_app WHERE test_id=%s AND application_info_id=%s );" \ + % (build_image_id, launching_performance_test_id, application_info_id, launching_performance_test_id, application_info_id) + mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_launching_performance_test_tpk_app']) + ### insert memory usage data ### # get launching_memory_usage_test_id # MYSQL['query']['select_launching_memory_usage_test'] = "SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name = 'launching_memory_usage_test' AND table_schema = DATABASE( ) ;" @@ -201,15 +266,27 @@ def main(): memory_usage_sum = TEST_DATA['memory_sum'] app_count = TEST_DATA['memory_count'] average_memory_usage = memory_usage_sum / app_count - MYSQL['query']['insert_launching_memory_usage_test'] = "INSERT INTO launching_memory_usage_test (build_image_id, average_memory_usage, memory_usage_sum, app_count, test_date) SELECT %s, %s, %s, %s, FROM_UNIXTIME(UNIX_TIMESTAMP()) FROM DUAL WHERE NOT EXISTS ( SELECT * FROM launching_memory_usage_test WHERE build_image_id=%s AND average_memory_usage=%s );" % (build_image_id, average_memory_usage, memory_usage_sum, app_count, build_image_id, average_memory_usage) + MYSQL['query']['insert_launching_memory_usage_test'] = "INSERT INTO launching_memory_usage_test \ + (build_image_id, average_memory_usage, memory_usage_sum, app_count, test_date) \ + SELECT %s, %s, %s, %s, FROM_UNIXTIME(UNIX_TIMESTAMP()) ON DUPLICATE KEY UPDATE build_image_id=%s;" \ + % (build_image_id, average_memory_usage, memory_usage_sum, app_count, build_image_id) mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_launching_memory_usage_test']) # get launching_memory_usage_test_id - MYSQL['query']['select_launching_memory_usage_test'] = "SELECT id FROM launching_memory_usage_test WHERE build_image_id=%s AND average_memory_usage=%s;" % (build_image_id, average_memory_usage) + MYSQL['query']['select_launching_memory_usage_test'] = "SELECT id FROM launching_memory_usage_test \ + WHERE build_image_id=%s AND average_memory_usage=%s;" % (build_image_id, average_memory_usage) mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['select_launching_memory_usage_test']) launching_memory_usage_test_id = MYSQL['cursor'].fetchone()['id'] print "[Write] launching_memory_usage_test id =", launching_memory_usage_test_id + # delete launching_memory_usage and launching_memory_object data with the same build_image_id to prevent duplicate insertion. + MYSQL['query']['delete_launching_memory_object_conditionally'] = "DELETE FROM launching_memory_object WHERE build_image_id=%d;" \ + % (build_image_id) + mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['delete_launching_memory_object_conditionally']) + + MYSQL['query']['delete_launching_memory_usage_conditionally'] = "DELETE FROM launching_memory_usage WHERE build_image_id=%d;" \ + % (build_image_id) + mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['delete_launching_memory_usage_conditionally']) # insert launching memory usage and insert launching memory object launching_memory_list = TEST_DATA['memory_performance'] @@ -222,11 +299,17 @@ def main(): pkg_id = launching_memory['pkg_id'] application_info_id = app_info_ids[app_id] - MYSQL['query']['select_launching_memory_usage'] = "SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name = 'launching_memory_usage' AND table_schema = DATABASE( ) ;" + MYSQL['query']['select_launching_memory_usage'] = "SELECT AUTO_INCREMENT FROM information_schema.tables \ + WHERE table_name = 'launching_memory_usage' AND table_schema = DATABASE( ) ;" mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['select_launching_memory_usage']) launching_memory_usage_id = MYSQL['cursor'].fetchone()['AUTO_INCREMENT'] - MYSQL['query']['insert_launching_memory_usage'] = "INSERT INTO launching_memory_usage (launching_memory_usage_test_id, build_image_id, application_info_id, memory_usage, pss, 3d, gem) SELECT %s, %s, %s, %s, %s, %s, %s FROM DUAL WHERE NOT EXISTS ( SELECT * FROM launching_memory_usage WHERE launching_memory_usage_test_id=%s AND application_info_id=%s );" % (launching_memory_usage_test_id, build_image_id, application_info_id, usage, pss, memory_3d, gem, launching_memory_usage_test_id, application_info_id) + MYSQL['query']['insert_launching_memory_usage'] = "INSERT INTO launching_memory_usage \ + (launching_memory_usage_test_id, build_image_id, application_info_id, memory_usage, pss, 3d, gem) \ + SELECT %s, %s, %s, %s, %s, %s, %s FROM DUAL WHERE NOT EXISTS \ + ( SELECT * FROM launching_memory_usage WHERE launching_memory_usage_test_id=%s AND application_info_id=%s );" \ + % (launching_memory_usage_test_id, build_image_id, application_info_id, usage, pss, memory_3d, gem, \ + launching_memory_usage_test_id, application_info_id) # MYSQL['query']['insert_launching_memory_usage'] = "INSERT INTO launching_memory_usage (launching_memory_usage_test_id, build_image_id, application_info_id, memory_usage, pss, 3d, gem) VALUES (%s, %s, %s, %s, %s, %s, %s);" % (launching_memory_usage_test_id, build_image_id, application_info_id, usage, pss, memory_3d, gem) mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_launching_memory_usage']) @@ -235,7 +318,10 @@ def main(): object_name = object_memory['object_name'] pcode_pdata = object_memory['pcode_pdata'] - MYSQL['query']['insert_launching_memory_object'] = "INSERT INTO launching_memory_object (launching_memory_usage_test_id, launching_memory_usage_id, build_image_id, application_info_id, object_name, pcode_pdata) VALUES (%s, %s, %s, %s, '%s', %s);" % (launching_memory_usage_test_id, launching_memory_usage_id, build_image_id, application_info_id, object_name, pcode_pdata) + MYSQL['query']['insert_launching_memory_object'] = "INSERT INTO launching_memory_object \ + (launching_memory_usage_test_id, launching_memory_usage_id, build_image_id, application_info_id, object_name, pcode_pdata) \ + VALUES (%s, %s, %s, %s, '%s', %s);" \ + % (launching_memory_usage_test_id, launching_memory_usage_id, build_image_id, application_info_id, object_name, pcode_pdata) mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_launching_memory_object']) BINARY_DATA = TEST_DATA['dotnet_binary'] @@ -243,7 +329,10 @@ def main(): all_binary_count = BINARY_DATA['binary_count']['all_binary_count'] selective_aot_dll_count = BINARY_DATA['binary_count']['selective_aot_dll_count'] full_aot_dll_count = BINARY_DATA['binary_count']['full_aot_dll_count'] - MYSQL['query']['insert_dotnet_binary_count'] = "INSERT INTO dotnet_binary_count (build_image_id, all_binary_count, selective_aot_dll_count, full_aot_dll_count) SELECT %s, %s, %s, %s FROM DUAL WHERE NOT EXISTS ( SELECT * FROM dotnet_binary_count WHERE build_image_id=%s );" % (build_image_id, all_binary_count, selective_aot_dll_count, full_aot_dll_count, build_image_id) + MYSQL['query']['insert_dotnet_binary_count'] = "INSERT INTO dotnet_binary_count \ + (build_image_id, all_binary_count, selective_aot_dll_count, full_aot_dll_count) \ + SELECT %s, %s, %s, %s FROM DUAL WHERE NOT EXISTS ( SELECT * FROM dotnet_binary_count WHERE build_image_id=%s );" \ + % (build_image_id, all_binary_count, selective_aot_dll_count, full_aot_dll_count, build_image_id) mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_dotnet_binary_count']) # insert dotnet_binary_summary @@ -253,7 +342,10 @@ def main(): original_size = binary_summary['original_size'] selective_aot_size = binary_summary['selective_aot_size'] full_aot_size = binary_summary['full_aot_size'] - MYSQL['query']['insert_dotnet_binary_summary'] = "INSERT INTO dotnet_binary_summary (build_image_id, category, original_size, selective_aot_size, full_aot_size) SELECT %s, '%s', %s, %s, %s FROM DUAL WHERE NOT EXISTS ( SELECT * FROM dotnet_binary_summary WHERE build_image_id=%s );" % (build_image_id, category, original_size, selective_aot_size, full_aot_size, build_image_id) + MYSQL['query']['insert_dotnet_binary_summary'] = "INSERT INTO dotnet_binary_summary \ + (build_image_id, category, original_size, selective_aot_size, full_aot_size) \ + SELECT %s, '%s', %s, %s, %s FROM DUAL WHERE NOT EXISTS ( SELECT * FROM dotnet_binary_summary WHERE build_image_id=%s );" \ + % (build_image_id, category, original_size, selective_aot_size, full_aot_size, build_image_id) mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_dotnet_binary_summary']) # insert dotnet_binary_info @@ -263,7 +355,10 @@ def main(): category = binary_info['category'] binary_dir = binary_info['binary_dir'] binary_type = binary_info['binary_type'] - MYSQL['query']['insert_dotnet_binary_info'] = "INSERT INTO dotnet_binary_info (binary_name, category, binary_dir, binary_type) SELECT '%s', '%s', '%s', '%s' FROM DUAL WHERE NOT EXISTS ( SELECT * FROM dotnet_binary_info WHERE binary_name='%s' AND category='%s' );" % (binary_name, category, binary_dir, binary_type, binary_name, category) + MYSQL['query']['insert_dotnet_binary_info'] = "INSERT INTO dotnet_binary_info \ + (binary_name, category, binary_dir, binary_type) SELECT '%s', '%s', '%s', '%s' FROM DUAL WHERE NOT EXISTS \ + ( SELECT * FROM dotnet_binary_info WHERE binary_name='%s' AND category='%s' );" \ + % (binary_name, category, binary_dir, binary_type, binary_name, category) mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_dotnet_binary_info']) # get dotnet_binary_info @@ -302,10 +397,12 @@ def main(): is_selective_aot = binary_aot_dll['is_selective_aot'] size_comparative_percentage = binary_aot_dll['size_comparative_percentage'] dotnet_binary_info_id = binary_info_ids[category][binary_name] - MYSQL['query']['insert_dotnet_binary_aot_dll'] = "INSERT INTO dotnet_binary_aot_dll "\ - + "(dotnet_binary_info_id, build_image_id, aot_dll_name, is_selective_aot, original_binary_size, aot_binary_size, size_comparative_percentage) "\ - "SELECT %s, %s, '%s', %s, %s, %s, %s FROM DUAL WHERE NOT EXISTS ( SELECT * FROM dotnet_binary_aot_dll WHERE build_image_id=%s AND dotnet_binary_info_id=%s );" \ - % (dotnet_binary_info_id, build_image_id, aot_dll_name, is_selective_aot, original_binary_size, aot_binary_size, size_comparative_percentage, build_image_id, dotnet_binary_info_id) + MYSQL['query']['insert_dotnet_binary_aot_dll'] = "INSERT INTO dotnet_binary_aot_dll \ + (dotnet_binary_info_id, build_image_id, aot_dll_name, is_selective_aot, original_binary_size, aot_binary_size, size_comparative_percentage) \ + SELECT %s, %s, '%s', %s, %s, %s, %s FROM DUAL WHERE NOT EXISTS \ + ( SELECT * FROM dotnet_binary_aot_dll WHERE build_image_id=%s AND dotnet_binary_info_id=%s );" \ + % (dotnet_binary_info_id, build_image_id, aot_dll_name, is_selective_aot, original_binary_size, aot_binary_size, size_comparative_percentage, \ + build_image_id, dotnet_binary_info_id) mysql_excute_query(MYSQL['connection'], MYSQL['cursor'], MYSQL['query']['insert_dotnet_binary_aot_dll']) MYSQL['cursor'].close()