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.
 
 
 

124 lines
4.9 KiB

from datetime import datetime
import traceback
import basic.program
import basic.constants as B
import utils.tdata_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 startPy(pjob):
myjob = pjob
myjob.m.setMsg("# # # # # start executer # # # # # ")
tdata = utils.tdata_tool.getTestdata()
job = basic.program.Job("unit")
if not hasattr(myjob.par, B.PAR_STEP):
raise Exception("Parameter " + B.PAR_STEP + " is missing")
testcases = getattr(myjob.par, B.PAR_TESTCASE)
for step in tdata[B.DATA_NODE_STEPS]:
if int(step.exexStep) != int(getattr(myjob.par, "step")):
continue
for arg in step["args"]:
if arg == "start":
if "testsuite" in step["args"][arg]:
jobargs = {B.PAR_APP: myjob.par.application, B.PAR_ENV: myjob.par.environment,
B.PAR_TESTSUITE: myjob.par.usecase, B.PAR_TSTIME: utils.date_tool.getActdate(utils.date_tool.F_DIR)}
job.popInstance()
job = basic.program.Job("unit")
job.par.setParameterArgs(jobargs)
job.setProgram(step["args"][arg])
print("Job initialisiert "+job.program+" in Verzeichnis "+getattr(job.par, B.PAR_TSDIR))
myjob.m.logInfo("Job initialisiert "+job.program+" in Verzeichnis "+getattr(job.par, B.PAR_TSDIR))
dirname = getattr(job.par, B.PAR_TSDIR)
job.stopJob(1)
job.popInstance()
basic.program.Job.pushInstance(myjob)
print("ende")
job = myjob
if B.PAR_TESTCASE in step["args"][arg]:
if step["comp"] in testcases:
jobargs = {B.PAR_APP: myjob.par.application, B.PAR_ENV: myjob.par.environment,
B.PAR_TCDIR: testcases[step["comp"]] }
else:
jobargs = {B.PAR_APP: myjob.par.application, B.PAR_ENV: myjob.par.environment,
B.PAR_TESTCASE: step["comp"], B.PAR_TCTIME: utils.date_tool.getActdate(utils.date_tool.F_DIR)}
job.popInstance()
job = basic.program.Job("unit")
job.par.setParameterArgs(jobargs)
job.setProgram(step["args"][arg])
print("Job initialisiert "+job.program+" in Verzeichnis "+getattr(job.par, B.PAR_TCDIR))
myjob.m.logInfo("Job initialisiert "+job.program+" in Verzeichnis "+getattr(job.par, B.PAR_TCDIR))
dirname = getattr(job.par, B.PAR_TCDIR)
testcases[step["comp"]] = dirname
job.stopJob(1)
job.popInstance()
basic.program.Job.pushInstance(myjob)
print("ende")
job = myjob
if arg == "report": # testsuite
basic.program.Job.pushInstance(myjob)
pass
basic.program.Job.pushInstance(myjob)
setattr(myjob.par, "testcases", testcases)
# myjob.stopJob(1)
def startStepProgram(step, job, jobargs):
myjob = basic.program.Job("unit") # meaning temp
myjob.par.setParameterArgs(jobargs)
myjob.setProgram(step.start)
myjob.pushInstance(myjob)
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)
if __name__ == '__main__':
print(PROGRAM_NAME)
x = basic.program.Job(PROGRAM_NAME)
x.startJob()
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()