Data-Test-Executer Framework speziell zum Test von Datenverarbeitungen mit Datengenerierung, Systemvorbereitungen, Einspielungen, ganzheitlicher diversifizierender Vergleich
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
4.1 KiB

#!/usr/bin/python
# program to execute automatically programs for a testsuite
# PARAM: --environment --application --tsdir [ testsuite, tstime ] --step
# main functions
# + execute_step() : testspec --> tdata.steps --> call( init_testsuite/testcase(),
# execute_testcase/testsuite(), collect_testcase/testsuite(), compare_testcase(), finish_testsuite() )
# ---------------------------------------------------
from datetime import datetime
2 years ago
import traceback
import basic.program
import basic.constants as B
# import tools.tdata_tool as tdata_tool
import tools.date_tool as date_tool
import tools.job_tool as job_tool
# import init_testcase
# import init_testsuite
# import execute_testcase
# import collect_testcase
# import compare_testcase
# import finish_testsuite
PROGRAM_NAME = "test_executer"
myjob = None
testcases = []
testinstances = {}
def getTime():
time = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
return time
def startPyJob(job):
job.m.setMsg("# # # # # start executer # # # # # ")
tdata = {} #tdata_tool.getTestdata(job)
if not hasattr(job.par, B.PAR_STEP):
2 years ago
raise Exception("Parameter " + B.PAR_STEP + " is missing")
testcases = getattr(job.par, B.PAR_TESTCASE)
for step in tdata[B.DATA_NODE_STEPS]:
if int(step.exexStep) != int(getattr(job.par, "step")):
continue
for arg in step["args"]:
if arg == "start":
print("start "+str(step["args"][arg]))
if "testsuite" in step["args"][arg]:
jobargs = {B.PAR_APP: job.par.application, B.PAR_ENV: job.par.environment,
B.PAR_TESTSUITE: job.par.usecase, B.PAR_TSTIME: date_tool.getActdate(date_tool.F_DIR)}
job_tool.start_child_process(job, jobargs)
elif B.PAR_TESTCASE in step["args"][arg]:
if step["comp"] in testcases:
jobargs = {B.PAR_APP: job.par.application, B.PAR_ENV: job.par.environment,
B.PAR_TCDIR: testcases[step["comp"]] }
else:
jobargs = {B.PAR_APP: job.par.application, B.PAR_ENV: job.par.environment,
B.PAR_TESTCASE: step["comp"], B.PAR_TCTIME: date_tool.getActdate(date_tool.F_DIR)}
job_tool.start_child_process(job, jobargs)
if arg == "report": # testsuite
#basic.program.Job.pushInstance(myjob)
pass
#basic.program.Job.pushInstance(myjob)
setattr(job.par, "testcases", testcases)
# myjob.stopJob(1)
"""def startStepProgram(step, job, jobargs):
2 years ago
myjob = basic.program.Job("unit") # meaning temp
myjob.par.setParameterArgs(job, jobargs)
2 years ago
myjob.setProgram(step.start)
#myjob.pushInstance(myjob)
2 years ago
myjob.startJob()
try:
job.m.logInfo(step.start + " starting")
if step.start == "init_testcase":
init_testcase.startPyJob(myjob)
elif step.start == "execute_testcase":
execute_testcase.startPyJob(myjob)
elif step.start == "collect_testcase":
collect_testcase.startPyJob(myjob)
elif step.start == "compare_testcase":
compare_testcase.startPyJob(myjob)
job.m.logInfo(step.start + " finished")
except Exception as e:
txt1 = traceback.format_stack()
print("==================================================================0")
print(txt1)
print("==================================================================0")
txt2 = traceback.format_exc()
print(txt2)
print("==================================================================0")
job.m.setError(step.start + " aborted")
finally:
myjob.stopJob(1)
#myjob.popInstance(myjob)
"""
2 years ago
if __name__ == '__main__':
print(PROGRAM_NAME)
x = basic.program.Job(PROGRAM_NAME)
x.startJob()
2 years ago
try:
x.m.logDebug(str(vars(x.par)) + "\n" + str(vars(x.conf)))
if x.m.isRc("fatal"):
x.stopJob()
exit(x.m.rc * (-1) + 3)
startPy(x)
except:
x.m.setError(PROGRAM_NAME + " aborted")
finally:
x.stopJob()