Add job for lookup table
authorTaejin Woo <tt.woo@samsung.com>
Tue, 3 Jul 2018 02:59:09 +0000 (11:59 +0900)
committerYonghee Han <onstudy@samsung.com>
Thu, 31 Jan 2019 01:21:23 +0000 (10:21 +0900)
Change-Id: Ie9ffdbe99d59c7aea70f016aa195450fb13242a8
Signed-off-by: Taejin Woo <tt.woo@samsung.com>
dtr/job_dtr_db_write.py
dtr/job_dtr_status.py

index 7a49ddf..a63016a 100644 (file)
@@ -26,7 +26,23 @@ import pprint
 from common.buildmonitor_db import do_query, get_value_from_query_data, do_many_query, connect_db, disconnect_db
 from common.buildmonitor_extention import BuildMonitorExtention
 
-def DTR_ver_info_fun(TOTAL_INFO, key_test_date):
+def dtr_target_lookup_insert_fun(TOTAL_INFO):
+    connect_db()
+
+    query = "INSERT INTO dtr_target_lookup (test_info, tizen_version, tizen_environ, tizen_target, test_date, tizen_release_version) \
+                   VALUES(%s, %s, %s, %s, %s, %s)"
+
+    query_var_list = []
+    for target_lookup_DB_values in TOTAL_INFO['target_lookup_data']['lookup_DB_values']:
+        query_var_list.append( target_lookup_DB_values )
+
+    pprint.pprint(query_var_list)
+    do_many_query(query, query_var_list)
+    pprint.pprint(do_many_query)
+
+    disconnect_db()
+
+def dtr_ver_info_fun(TOTAL_INFO, key_test_date):
     connect_db()
 
     query = "INSERT INTO dtr_main_info (id, test_date, tizen_release_version) VALUES(%s, %s, %s)"
@@ -40,7 +56,7 @@ def DTR_ver_info_fun(TOTAL_INFO, key_test_date):
 
     disconnect_db()
 
-def DTR_tbt_insert_fun(TOTAL_INFO):
+def dtr_tbt_insert_fun(TOTAL_INFO):
     connect_db()
 
     query = "INSERT INTO dtr_tbt_result (test_date, tizen_version, environment, target_name, tbt_test_date, packages, grand_total, pass, fail, fns, nt, comment) \
@@ -57,7 +73,7 @@ def DTR_tbt_insert_fun(TOTAL_INFO):
     disconnect_db()
 
 
-def DTR_sample_insert_fun(TOTAL_INFO):
+def dtr_sample_insert_fun(TOTAL_INFO):
     connect_db()
 
     query = "INSERT INTO dtr_sample_app_result (test_date, num, profile, target_name, tizen_version, \
@@ -74,7 +90,7 @@ def DTR_sample_insert_fun(TOTAL_INFO):
     disconnect_db()
 
 
-def DTR_unresovled_insert_fun(TOTAL_INFO):
+def dtr_unresovled_insert_fun(TOTAL_INFO):
     connect_db()
 
     query = "INSERT INTO dtr_unresolved_jira (test_date, jira_key, issue_date, issue_title) \
@@ -94,16 +110,19 @@ def main(TOTAL_INFO):
     key_test_date = TOTAL_INFO['test_ver_info_data']['test_date']
 
     ## 1. DTR ver. info data (complete)
-    DTR_ver_info_fun(TOTAL_INFO['test_ver_info_data'], key_test_date, DTR_DB)
+    dtr_ver_info_fun(TOTAL_INFO['test_ver_info_data'], key_test_date, DTR_DB)
+
+    ## 1. lookup table data
+    dtr_target_lookup_insert_fun(TOTAL_INFO)
 
     ## 3. TBT data
-    DTR_tbt_insert_fun(TOTAL_INFO)
+    dtr_tbt_insert_fun(TOTAL_INFO)
 
     ## 4. Sample data
-    DTR_sample_insert_fun(TOTAL_INFO)
+    dtr_sample_insert_fun(TOTAL_INFO)
 
     ## 5. unresovled data
-    DTR_unresovled_insert_fun(TOTAL_INFO)
+    dtr_unresovled_insert_fun(TOTAL_INFO)
 
     return 0
 
index 9d2fc59..0809971 100644 (file)
@@ -122,6 +122,37 @@ def dtr_smoke_menu_export(sheet, srbd_data):
 
     return total_results
 
+##################### 1. 2. Combine #########################
+def dtr_target_lookup_DB_export(MIDDLE_INFO, arg_name):
+    total_results = {}
+    total_results[arg_name] = []
+    var_list = ["test_info", "tizen_version", "tizen_environ", "tizen_target", "test_date", "tizen_release_version"]
+
+    lookup_temp_list = []
+    for menu in MIDDLE_INFO['smoke_menu_data']['var_list']:
+        lookup_temp_list.append(menu)
+        for i in range(0, len(MIDDLE_INFO['smoke_menu_data'][menu])):
+            lookup_temp_list.append(MIDDLE_INFO['smoke_menu_data'][menu][i])
+
+
+    lookup_var_list = []
+    col = MIDDLE_INFO['smoke_menu_data']['col']
+    row = MIDDLE_INFO['smoke_menu_data']['row']
+
+
+    for i in range (0, col):
+        test_info             = lookup_temp_list[i*len(var_list)]
+        tizen_version         = lookup_temp_list[i*len(var_list) + 1]
+        tizen_environ         = lookup_temp_list[i*len(var_list) + 2]
+        tizen_target          = lookup_temp_list[i*len(var_list) + 3]
+        test_date             = lookup_temp_list[i*len(var_list) + 4]
+        tizen_release_version = lookup_temp_list[i*len(var_list) + 5]
+
+        total_results[arg_name].append( (test_info, tizen_version, tizen_environ, tizen_target, test_date, tizen_release_version) )
+
+#    pprint.pprint(total_results)
+
+    return total_results
 
 def dtr_smoke_result_export(sheet, srbd_data):
     ncol = sheet.ncols
@@ -259,6 +290,15 @@ def main():
     smoke_menu_list         = dtr_smoke_menu_export(smoke_menu_sheet, smoke_menu_data)
     smoke_result_list       = dtr_smoke_result_export(smoke_result_sheet, smoke_result_data)
 
+    MIDDLE_INFO = {
+        'test_ver_info_data'     :  test_ver_info_dict,
+        'smoke_menu_data'        :  smoke_menu_dict,
+        'smoke_result_data'      :  smoke_result_dict,
+        'smoke_menu_result_data'      :  smoke_menu_result_dict,
+    }
+
+    target_lookup_DB_dict   = dtr_target_lookup_DB_export(MIDDLE_INFO, "lookup_DB_values")
+
     ## 3. DTR TBT data
     tbt_menu_list           = dtr_general_menu_export(tbt_menu_sheet, tbt_menu_data, "tbt_menus")
     tbt_result_list         = dtr_general_result_export(tbt_result_sheet, tbt_result_data, "tbt_DB_values")
@@ -275,6 +315,7 @@ def main():
         'test_ver_info_data'     :  test_ver_info_list,
         'smoke_menu_data'        :  smoke_menu_list,
         'smoke_result_data'      :  smoke_result_list,
+        'target_lookup_data'     :  target_lookup_DB_dict,
         'tbt_menu_data'          :  tbt_menu_list,
         'tbt_result_data'        :  tbt_result_list,
         'sample_menu_data'       :  sample_menu_list,