How to use test_finished_time method in autotest

Best Python code snippet using autotest_python

031_rename_tko_tables.py

Source:031_rename_tko_tables.py Github

copy

Full Screen

1import common2from autotest_lib.database import db_utils3RECREATE_VIEWS_UP = """4CREATE VIEW tko_test_view AS5SELECT tko_tests.test_idx,6 tko_tests.job_idx,7 tko_tests.test,8 tko_tests.subdir,9 tko_tests.kernel_idx,10 tko_tests.status,11 tko_tests.reason,12 tko_tests.machine_idx,13 tko_tests.started_time AS test_started_time,14 tko_tests.finished_time AS test_finished_time,15 tko_jobs.tag AS job_tag,16 tko_jobs.label AS job_label,17 tko_jobs.username AS job_username,18 tko_jobs.queued_time AS job_queued_time,19 tko_jobs.started_time AS job_started_time,20 tko_jobs.finished_time AS job_finished_time,21 tko_machines.hostname AS machine_hostname,22 tko_machines.machine_group,23 tko_machines.owner AS machine_owner,24 tko_kernels.kernel_hash,25 tko_kernels.base AS kernel_base,26 tko_kernels.printable AS kernel_printable,27 tko_status.word AS status_word28FROM tko_tests29INNER JOIN tko_jobs ON tko_jobs.job_idx = tko_tests.job_idx30INNER JOIN tko_machines ON tko_machines.machine_idx = tko_jobs.machine_idx31INNER JOIN tko_kernels ON tko_kernels.kernel_idx = tko_tests.kernel_idx32INNER JOIN tko_status ON tko_status.status_idx = tko_tests.status;33CREATE VIEW tko_perf_view AS34SELECT tko_tests.test_idx,35 tko_tests.job_idx,36 tko_tests.test,37 tko_tests.subdir,38 tko_tests.kernel_idx,39 tko_tests.status,40 tko_tests.reason,41 tko_tests.machine_idx,42 tko_tests.started_time AS test_started_time,43 tko_tests.finished_time AS test_finished_time,44 tko_jobs.tag AS job_tag,45 tko_jobs.label AS job_label,46 tko_jobs.username AS job_username,47 tko_jobs.queued_time AS job_queued_time,48 tko_jobs.started_time AS job_started_time,49 tko_jobs.finished_time AS job_finished_time,50 tko_machines.hostname AS machine_hostname,51 tko_machines.machine_group,52 tko_machines.owner AS machine_owner,53 tko_kernels.kernel_hash,54 tko_kernels.base AS kernel_base,55 tko_kernels.printable AS kernel_printable,56 tko_status.word AS status_word,57 tko_iteration_result.iteration,58 tko_iteration_result.attribute AS iteration_key,59 tko_iteration_result.value AS iteration_value60FROM tko_tests61INNER JOIN tko_jobs ON tko_jobs.job_idx = tko_tests.job_idx62INNER JOIN tko_machines ON tko_machines.machine_idx = tko_jobs.machine_idx63INNER JOIN tko_kernels ON tko_kernels.kernel_idx = tko_tests.kernel_idx64INNER JOIN tko_status ON tko_status.status_idx = tko_tests.status65INNER JOIN tko_iteration_result ON66 tko_iteration_result.test_idx = tko_tests.test_idx;67CREATE VIEW tko_test_view_2 AS68SELECT tko_tests.test_idx,69 tko_tests.job_idx,70 tko_tests.test AS test_name,71 tko_tests.subdir,72 tko_tests.kernel_idx,73 tko_tests.status AS status_idx,74 tko_tests.reason,75 tko_tests.machine_idx,76 tko_tests.started_time AS test_started_time,77 tko_tests.finished_time AS test_finished_time,78 tko_jobs.tag AS job_tag,79 tko_jobs.label AS job_name,80 tko_jobs.username AS job_owner,81 tko_jobs.queued_time AS job_queued_time,82 tko_jobs.started_time AS job_started_time,83 tko_jobs.finished_time AS job_finished_time,84 tko_jobs.afe_job_id AS afe_job_id,85 tko_machines.hostname AS hostname,86 tko_machines.machine_group AS platform,87 tko_machines.owner AS machine_owner,88 tko_kernels.kernel_hash,89 tko_kernels.base AS kernel_base,90 tko_kernels.printable AS kernel,91 tko_status.word AS status92FROM tko_tests93INNER JOIN tko_jobs ON tko_jobs.job_idx = tko_tests.job_idx94INNER JOIN tko_machines ON tko_machines.machine_idx = tko_jobs.machine_idx95INNER JOIN tko_kernels ON tko_kernels.kernel_idx = tko_tests.kernel_idx96INNER JOIN tko_status ON tko_status.status_idx = tko_tests.status;97CREATE VIEW tko_test_view_outer_joins AS98SELECT tko_tests.test_idx,99 tko_tests.job_idx,100 tko_tests.test AS test_name,101 tko_tests.subdir,102 tko_tests.kernel_idx,103 tko_tests.status AS status_idx,104 tko_tests.reason,105 tko_tests.machine_idx,106 tko_tests.started_time AS test_started_time,107 tko_tests.finished_time AS test_finished_time,108 tko_jobs.tag AS job_tag,109 tko_jobs.label AS job_name,110 tko_jobs.username AS job_owner,111 tko_jobs.queued_time AS job_queued_time,112 tko_jobs.started_time AS job_started_time,113 tko_jobs.finished_time AS job_finished_time,114 tko_machines.hostname AS hostname,115 tko_machines.machine_group AS platform,116 tko_machines.owner AS machine_owner,117 tko_kernels.kernel_hash,118 tko_kernels.base AS kernel_base,119 tko_kernels.printable AS kernel,120 tko_status.word AS status121FROM tko_tests122LEFT OUTER JOIN tko_jobs ON tko_jobs.job_idx = tko_tests.job_idx123LEFT OUTER JOIN tko_machines ON tko_machines.machine_idx = tko_jobs.machine_idx124LEFT OUTER JOIN tko_kernels ON tko_kernels.kernel_idx = tko_tests.kernel_idx125LEFT OUTER JOIN tko_status ON tko_status.status_idx = tko_tests.status;126CREATE VIEW tko_perf_view_2 AS127SELECT tko_tests.test_idx,128 tko_tests.job_idx,129 tko_tests.test AS test_name,130 tko_tests.subdir,131 tko_tests.kernel_idx,132 tko_tests.status AS status_idx,133 tko_tests.reason,134 tko_tests.machine_idx,135 tko_tests.started_time AS test_started_time,136 tko_tests.finished_time AS test_finished_time,137 tko_jobs.tag AS job_tag,138 tko_jobs.label AS job_name,139 tko_jobs.username AS job_owner,140 tko_jobs.queued_time AS job_queued_time,141 tko_jobs.started_time AS job_started_time,142 tko_jobs.finished_time AS job_finished_time,143 tko_machines.hostname AS hostname,144 tko_machines.machine_group AS platform,145 tko_machines.owner AS machine_owner,146 tko_kernels.kernel_hash,147 tko_kernels.base AS kernel_base,148 tko_kernels.printable AS kernel,149 tko_status.word AS status,150 tko_iteration_result.iteration,151 tko_iteration_result.attribute AS iteration_key,152 tko_iteration_result.value AS iteration_value153FROM tko_tests154LEFT OUTER JOIN tko_jobs ON tko_jobs.job_idx = tko_tests.job_idx155LEFT OUTER JOIN tko_machines ON tko_machines.machine_idx = tko_jobs.machine_idx156LEFT OUTER JOIN tko_kernels ON tko_kernels.kernel_idx = tko_tests.kernel_idx157LEFT OUTER JOIN tko_status ON tko_status.status_idx = tko_tests.status158LEFT OUTER JOIN tko_iteration_result ON159 tko_iteration_result.test_idx = tko_tests.test_idx;160"""161RECREATE_VIEWS_DOWN = """162CREATE VIEW test_view AS163SELECT tests.test_idx,164 tests.job_idx,165 tests.test,166 tests.subdir,167 tests.kernel_idx,168 tests.status,169 tests.reason,170 tests.machine_idx,171 tests.started_time AS test_started_time,172 tests.finished_time AS test_finished_time,173 jobs.tag AS job_tag,174 jobs.label AS job_label,175 jobs.username AS job_username,176 jobs.queued_time AS job_queued_time,177 jobs.started_time AS job_started_time,178 jobs.finished_time AS job_finished_time,179 machines.hostname AS machine_hostname,180 machines.machine_group,181 machines.owner AS machine_owner,182 kernels.kernel_hash,183 kernels.base AS kernel_base,184 kernels.printable AS kernel_printable,185 status.word AS status_word186FROM tests187INNER JOIN jobs ON jobs.job_idx = tests.job_idx188INNER JOIN machines ON machines.machine_idx = jobs.machine_idx189INNER JOIN kernels ON kernels.kernel_idx = tests.kernel_idx190INNER JOIN status ON status.status_idx = tests.status;191CREATE VIEW perf_view AS192SELECT tests.test_idx,193 tests.job_idx,194 tests.test,195 tests.subdir,196 tests.kernel_idx,197 tests.status,198 tests.reason,199 tests.machine_idx,200 tests.started_time AS test_started_time,201 tests.finished_time AS test_finished_time,202 jobs.tag AS job_tag,203 jobs.label AS job_label,204 jobs.username AS job_username,205 jobs.queued_time AS job_queued_time,206 jobs.started_time AS job_started_time,207 jobs.finished_time AS job_finished_time,208 machines.hostname AS machine_hostname,209 machines.machine_group,210 machines.owner AS machine_owner,211 kernels.kernel_hash,212 kernels.base AS kernel_base,213 kernels.printable AS kernel_printable,214 status.word AS status_word,215 iteration_result.iteration,216 iteration_result.attribute AS iteration_key,217 iteration_result.value AS iteration_value218FROM tests219INNER JOIN jobs ON jobs.job_idx = tests.job_idx220INNER JOIN machines ON machines.machine_idx = jobs.machine_idx221INNER JOIN kernels ON kernels.kernel_idx = tests.kernel_idx222INNER JOIN status ON status.status_idx = tests.status223INNER JOIN iteration_result ON iteration_result.test_idx = tests.test_idx;224CREATE VIEW test_view_outer_joins AS225SELECT tests.test_idx,226 tests.job_idx,227 tests.test AS test_name,228 tests.subdir,229 tests.kernel_idx,230 tests.status AS status_idx,231 tests.reason,232 tests.machine_idx,233 tests.started_time AS test_started_time,234 tests.finished_time AS test_finished_time,235 jobs.tag AS job_tag,236 jobs.label AS job_name,237 jobs.username AS job_owner,238 jobs.queued_time AS job_queued_time,239 jobs.started_time AS job_started_time,240 jobs.finished_time AS job_finished_time,241 machines.hostname AS hostname,242 machines.machine_group AS platform,243 machines.owner AS machine_owner,244 kernels.kernel_hash,245 kernels.base AS kernel_base,246 kernels.printable AS kernel,247 status.word AS status248FROM tests249LEFT OUTER JOIN jobs ON jobs.job_idx = tests.job_idx250LEFT OUTER JOIN machines ON machines.machine_idx = jobs.machine_idx251LEFT OUTER JOIN kernels ON kernels.kernel_idx = tests.kernel_idx252LEFT OUTER JOIN status ON status.status_idx = tests.status;253CREATE VIEW test_view_2 AS254SELECT tests.test_idx,255 tests.job_idx,256 tests.test AS test_name,257 tests.subdir,258 tests.kernel_idx,259 tests.status AS status_idx,260 tests.reason,261 tests.machine_idx,262 tests.started_time AS test_started_time,263 tests.finished_time AS test_finished_time,264 jobs.tag AS job_tag,265 jobs.label AS job_name,266 jobs.username AS job_owner,267 jobs.queued_time AS job_queued_time,268 jobs.started_time AS job_started_time,269 jobs.finished_time AS job_finished_time,270 jobs.afe_job_id AS afe_job_id,271 machines.hostname AS hostname,272 machines.machine_group AS platform,273 machines.owner AS machine_owner,274 kernels.kernel_hash,275 kernels.base AS kernel_base,276 kernels.printable AS kernel,277 status.word AS status278FROM tests279INNER JOIN jobs ON jobs.job_idx = tests.job_idx280INNER JOIN machines ON machines.machine_idx = jobs.machine_idx281INNER JOIN kernels ON kernels.kernel_idx = tests.kernel_idx282INNER JOIN status ON status.status_idx = tests.status;283CREATE VIEW perf_view_2 AS284SELECT tests.test_idx,285 tests.job_idx,286 tests.test AS test_name,287 tests.subdir,288 tests.kernel_idx,289 tests.status AS status_idx,290 tests.reason,291 tests.machine_idx,292 tests.started_time AS test_started_time,293 tests.finished_time AS test_finished_time,294 jobs.tag AS job_tag,295 jobs.label AS job_name,296 jobs.username AS job_owner,297 jobs.queued_time AS job_queued_time,298 jobs.started_time AS job_started_time,299 jobs.finished_time AS job_finished_time,300 machines.hostname AS hostname,301 machines.machine_group AS platform,302 machines.owner AS machine_owner,303 kernels.kernel_hash,304 kernels.base AS kernel_base,305 kernels.printable AS kernel,306 status.word AS status,307 iteration_result.iteration,308 iteration_result.attribute AS iteration_key,309 iteration_result.value AS iteration_value310FROM tests311LEFT OUTER JOIN jobs ON jobs.job_idx = tests.job_idx312LEFT OUTER JOIN machines ON machines.machine_idx = jobs.machine_idx313LEFT OUTER JOIN kernels ON kernels.kernel_idx = tests.kernel_idx314LEFT OUTER JOIN status ON status.status_idx = tests.status315LEFT OUTER JOIN iteration_result ON iteration_result.test_idx = tests.test_idx;316"""317ORIG_NAMES = (318 'embedded_graphing_queries',319 'iteration_attributes',320 'iteration_result',321 'jobs',322 'kernels',323 'machines',324 'patches',325 'query_history',326 'saved_queries',327 'status',328 'test_attributes',329 'test_labels',330 'test_labels_tests',331 'tests',332 )333RENAMES_UP = dict((name, 'tko_' + name) for name in ORIG_NAMES)334VIEWS_TO_DROP_UP = (335 'test_view',336 'test_view_2',337 'test_view_outer_joins',338 'perf_view',339 'perf_view_2',340 )341RENAMES_DOWN = dict((value, key) for key, value in RENAMES_UP.iteritems())342VIEWS_TO_DROP_DOWN = ['tko_' + view for view in VIEWS_TO_DROP_UP]343def migrate_up(manager):344 db_utils.drop_views(manager, VIEWS_TO_DROP_UP)345 db_utils.rename(manager, RENAMES_UP)346 manager.execute_script(RECREATE_VIEWS_UP)347def migrate_down(manager):348 db_utils.drop_views(manager, VIEWS_TO_DROP_DOWN)349 db_utils.rename(manager, RENAMES_DOWN)...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

1from parse_task import *2from core import *3from test import *4from parse_type import *5import copy6CORE_NUM = 107TESTING = None #core instance under test8TEST_MODE_SCALAR = 1.291011def build_log():12 task_status_dic = {1:"running", 2:"stalled"}13 test_status_dic = {1:"PRE TEST", 2:"TESTING", 3:"AFTER TEST"}14 print '**********',"cycle:",CYCLE,'************'15 for i in xrange(len(CORES1)):16 if CORES1[i].status:17 if CORES1[i].test:18 print "core%d:"%(i+1), "(type%d)"%CORES1[i].type, CORES1[i].status.task_id, ' ',\19 task_status_dic[CORES1[i].status.status],\20 " Test is now in %s"%test_status_dic[CORES1[i].test.status]21 else:22 print "core%d:"%(i+1), "(type%d)"%CORES1[i].type, CORES1[i].status.task_id, ' ',\23 task_status_dic[CORES1[i].status.status],\24 " Not under test"25 else:26 if CORES1[i].test:27 print "core%d:"%(i+1), "(type%d)"%CORES1[i].type, "vacant.", " Test is now in %s"%test_status_dic[CORES1[i].test.status]28 else:29 print "core%d:"%(i+1), "(type%d)"%CORES1[i].type, "vacant.", " Not under test"303132def task_dispatch():33 for i in xrange(len(CORES1)):34 if not CORES1[i].status: #vacant core35 if len(CORES1[i].task_list):36 if CORES1[i].task_list[0].is_executable():37 if not CORES1[i].test: #not under test38 CORES1[i].status = CORES1[i].task_list[0]39 del CORES1[i].task_list[0]40 CORES1[i].status.status = 141 else: #under test42 if CORES1[i].test.status != 1 and CORES1[i].test.status != 3:43 CORES1[i].status = CORES1[i].task_list[0]44 del CORES1[i].task_list[0]45 CORES1[i].status.status = 146 47 else:#core running task48 if not CORES1[i].test:#not under test49 CORES1[i].status.runtime += 150 if CORES1[i].status.is_finished():51 CORES1[i].status = None52 else: #under test53 if CORES1[i].test.status == 1: #pre test54 if CORES1[i].type: #unbreakable55 CORES1[i].status.runtime += 156 if CORES1[i].status.is_finished():57 CORES1[i].status = None58 else: #breakable59 CORES1[i].status.status = 2 #task stalled60 elif CORES1[i].test.status == 2: #under test61 CORES1[i].status.status = 162 CORES1[i].status.runtime += 1/TEST_MODE_SCALAR63 if CORES1[i].status.is_finished():64 CORES1[i].status = None65 66 else: #after_test67 pass686970def is_test_finished():71 for i in xrange(len(CORES1)):72 if not CORES1[i].test_status:73 return 074 return 1757677def is_task_finished():78 for i in xrange(len(CORES1)):79 if CORES1[i].status:80 return 081 return 1828384def core_for_test():85 for i in xrange(len(CORES1)):86 if not CORES1[i].test_status:87 if not CORES1[i].type:88 CORES1[i].test = TEST_DIC[i]89 return CORES1[i]90 for i in xrange(len(CORES1)):91 if not CORES1[i].test_status:92 CORES1[i].test = TEST_DIC[i]93 return CORES1[i]94 return None959697def test_dispatch():98 global TESTING99 global TEST_TIME100 if TESTING.test.status == 1: #pre_test101 if TESTING.type: #unbreakable102 if not TESTING.status:103 TESTING.test.pre_test -= 1104 if TESTING.test.pre_test <= 0:105 TESTING.test.status = 2106 else: #breakable107 TESTING.test.pre_test -= 1108 if TESTING.test.pre_test <= 0:109 TESTING.test.status = 2110111 elif TESTING.test.status == 2: #under test112 TEST_TIME += 1113 if TESTING.type: #unbreakable114 TESTING.test.under_test -= 1115 if TESTING.test.under_test <= 0 and TESTING.status == None:116 TESTING.test.status = 3117 else: #breakable118 TESTING.test.under_test -= 1119 if TESTING.test.under_test <= 0:120 TESTING.test.status = 3121 if TESTING.status:122 TESTING.status.status = 2 #task stalled123124 else: #after test125 TESTING.test.after_test -= 1126 if TESTING.test.after_test <= 0:127 TESTING.test_status = 1128 if TESTING.status:129 TESTING.status.status = 1130 TESTING.test = None131 TESTING = None132133134def run_graph():135 global CYCLE136 global TEST_FINISHED137 global TASK_FINISHED138 global TESTING139 global TEST_TIME140 global TEST_FINISHED_TIME141 global TASK_FINISHED_TIME142 CYCLE = 0143 TEST_FINISHED = 0144 TASK_FINISHED = 0145 TEST_TIME = 0146 test_recording = 1147 task_recording = 1148 while not (TASK_FINISHED and TEST_FINISHED):149 CYCLE += 1150151 # build_log()152 if not TESTING and not TEST_FINISHED:153 TESTING = core_for_test()154 test_dispatch()155 task_dispatch()156 else:157 if not TEST_FINISHED:158 test_dispatch()159 task_dispatch()160161 TEST_FINISHED = is_test_finished()162 TASK_FINISHED = is_task_finished()163 if TEST_FINISHED and test_recording:164 TEST_FINISHED_TIME = CYCLE165 test_recording = 0166 if TASK_FINISHED and task_recording:167 TASK_FINISHED_TIME = CYCLE168 task_recording = 0169 # build_log()170 # print task_finished_time171 # print test_finished_time172173174def run_graph_2():175 global CYCLE176 CYCLE = 0177 finished = 0178 while not finished:179 finished = 1180 CYCLE += 1181 for i in xrange(len(CORES1)):182 if not CORES2[i].status:183 if len(CORES2[i].task_list):184 if CORES2[i].task_list[0].is_executable():185 CORES2[i].status = CORES2[i].task_list[0]186 del CORES2[i].task_list[0]187 finished = 0188 else:189 finished = 0190 CORES2[i].status.runtime += 1191 if CORES2[i].status.is_finished():192 CORES2[i].status = None193 # print "cycle%d*********\n"%CYCLE194 # for i in xrange(len(CORES1)):195 # if CORES2[i].status:196 # print "core" + str(i) + ":" + CORES2[i].status.task_id + "\n"197 # else:198 # print "core" + str(i) + ":"+ "vacant\n"199200def init():201 global CORES1202 CORES1 = []203 for i in range(CORE_NUM):204 if i == 4 or i == 5 or i == 9:205 CORES1.append(Core(i+1, 1))206 else:207 CORES1.append(Core(i+1, 0))208209210def write_log():211 res_seq = []212 res_seq.append("TEST MODE--------------------\n")213 res_seq.append("Task is finished at cycle:%d\n" % TASK_FINISHED_TIME)214 res_seq.append("Test is finished at cycle:%d\n" % TEST_FINISHED_TIME)215 res_seq.append("Total test time cycle is: %d\n" % TEST_TIME)216 res_seq.append("COMMON MODE--------------------\n")217 res_seq.append("Task is finished at cycle:%d\n" % CYCLE)218 return res_seq219220if __name__ == '__main__':221 global TEST_DIC222223 TEST_DIC = test_dic_init()224 filename = "config.tgff"225 # raw_input("ENTER YOUR TG FILENAME:\n")226 file_object = open(filename)227 try:228 tgff_file = file_object.read()229 finally:230 file_object.close()231 init()232 type_dic = parse_type(tgff_file)233 parse_task(tgff_file, CORES1, type_dic)234 CORES2 = copy.deepcopy(CORES1)235 run_graph()236 run_graph_2()237 file_write = open('result', 'a')238 file_write.writelines(write_log())239 file_write.close()240 ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful