Browse Source

test-executer part-1

master
Ulrich Carmesin 3 years ago
parent
commit
43b17a6dc5
  1. 6
      basic/componentHandling.py
  2. 1
      basic/constants.py
  3. 24
      basic/program.py
  4. 0
      bereinige.py
  5. 61
      test_executer.py
  6. 4
      utils/configs/path.yml

6
basic/componentHandling.py

@ -183,6 +183,12 @@ class ComponentManager:
if name in parContent["comps"]: if name in parContent["comps"]:
for k in parContent["comps"][name].keys(): for k in parContent["comps"][name].keys():
c.conf[k] = parContent["comps"][name][k] c.conf[k] = parContent["comps"][name][k]
if B.SUBJECT_ARTS in c.conf and B.TOPIC_NODE_DB in c.conf[B.SUBJECT_ARTS]:
if not B.DATA_NODE_DDL in c.conf:
c.conf[B.DATA_NODE_DDL] = {}
for table in c.conf[B.SUBJECT_ARTS][B.SUBJECT_ARTS]:
conf = utils.config_tool.getConfig("DATASTRUCTURE", c.name, table)
c.conf[B.DATA_NODE_DDL][table] = conf
comps[name] = c comps[name] = c
return c return c

1
basic/constants.py

@ -40,6 +40,7 @@ PAR_COMP = 'component'
PAR_FCT = 'function' PAR_FCT = 'function'
PAR_TOOL = 'tool' PAR_TOOL = 'tool'
PAR_TESTCASE = "testcase" PAR_TESTCASE = "testcase"
PAR_TESTSUITE = "usecase"
""" name of testcase extracted from PAR_TCDIR """ """ name of testcase extracted from PAR_TCDIR """

24
basic/program.py

@ -34,7 +34,14 @@ jobdef = {
"basedir": "envbase", "basedir": "envbase",
"dirname": "envdir", "dirname": "envdir",
"logdir": "{job.par.envdir}/{log}/log_{time}.txt" }, "logdir": "{job.par.envdir}/{log}/log_{time}.txt" },
"init_testset": { "test_executer": {
"pardef": "",
"pfilesource" : "",
"pfiletarget" : "tsparfile",
"basedir": "tsbase",
"dirname": "tsdir",
"logdir": "{job.par.tsdir}/{log}/log_{time}.txt" },
"init_testsuite": {
"pardef": "tsdir", # ,tdtyp,tdsrc,tdname", "pardef": "tsdir", # ,tdtyp,tdsrc,tdname",
"pfilesource" : "envparfile", "pfilesource" : "envparfile",
"pfiletarget" : "tsparfile", "pfiletarget" : "tsparfile",
@ -62,7 +69,7 @@ jobdef = {
"basedir": "tcbase", "basedir": "tcbase",
"dirname": "tcdir", "dirname": "tcdir",
"logdir": "{job.par.tcdir}/{log}/log_{tctime}.txt"}, "logdir": "{job.par.tcdir}/{log}/log_{tctime}.txt"},
"finish_testset": { "finish_testsuite": {
"pardef": "tcdir,tdtyp,tdsrc,tdname", "pardef": "tcdir,tdtyp,tdsrc,tdname",
"pfilesource": "tsparfile", "pfilesource": "tsparfile",
"pfiletarget": "tcparfile", "pfiletarget": "tcparfile",
@ -99,6 +106,16 @@ class Job:
self.m = basic.message.Message(basic.message.LIMIT_DEBUG, logTime, None) self.m = basic.message.Message(basic.message.LIMIT_DEBUG, logTime, None)
print("prog-50 " + str(self.par.basedir)) print("prog-50 " + str(self.par.basedir))
@staticmethod
def popInstance():
job = Job.getInstance()
Job.__instance = None
return job
@staticmethod
def pushInstance(job):
Job.__instance = job
return job
def resetInstance(program): def resetInstance(program):
job = Job.getInstance() job = Job.getInstance()
@ -224,6 +241,9 @@ class Parameter:
self.basedir = jobdef[program]["basedir"] self.basedir = jobdef[program]["basedir"]
if hasattr(self, jobdef[program]["dirname"]): if hasattr(self, jobdef[program]["dirname"]):
utils.path_tool.extractPath(self.basedir, getattr(self, jobdef[program]["dirname"])) utils.path_tool.extractPath(self.basedir, getattr(self, jobdef[program]["dirname"]))
elif program != "unit":
dirpath = utils.path_tool.composePatttern("{"+jobdef[program]["basedir"]+"}", None)
setattr(self, jobdef[program]["dirname"], dirpath)
else: else:
self.basedir = "debugs" self.basedir = "debugs"

0
bereinige.py

61
test_executer.py

@ -0,0 +1,61 @@
from datetime import datetime
import basic.program
import basic.program as program
import utils.tdata_tool
PROGRAM_NAME = "test_executer"
def getTime():
time = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
return time
def start(job):
job.m.setMsg("# # # # # start executer # # # # # ")
tdata = utils.tdata_tool.getTestdata()
myjob = job
for step in tdata["_steps"]:
for arg in step["args"]:
if arg == "start":
if "testsuite" in step["args"][arg]:
jobargs = {"application": job.par.application, "environment": job.par.environment,
"usecase": job.par.usecase, "tstime": getTime()}
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, "tsdir"))
job.stopJob(1)
job.popInstance()
basic.program.Job.pushInstance(myjob)
print("ende")
job = myjob
if "testcase" in step["args"][arg]:
jobargs = {"application": job.par.application, "environment": job.par.environment,
"testcase": step["comp"], "tctime": getTime()}
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, "tcdir"))
job.stopJob(1)
job.popInstance()
basic.program.Job.pushInstance(myjob)
print("ende")
job = myjob
if __name__ == '__main__':
print(PROGRAM_NAME)
x = program.Job(PROGRAM_NAME)
#m = message.Message(3)
#m.closeMessage()
x.startJob()
x.m.logInfo("hier eine LogInfo")
x.m.logDebug("hier eine DbugMeldung")
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)
start(x)
x.stopJob()

4
utils/configs/path.yml

@ -24,7 +24,7 @@ pattern:
envlog: "{envbase}/{log}" envlog: "{envbase}/{log}"
envparfile: "{envbase}/{parfile}" envparfile: "{envbase}/{parfile}"
# testcase # testcase
tcbase: "{job.conf.archiv}/{job.par.release}/{job.par.testcase}/{job.par.tctime}" tcbase: "{job.conf.archiv}/{job.par.testcase}/{job.par.tctime}"
tclog: "{tcbase}/{log}" tclog: "{tcbase}/{log}"
tcresult: "{tcbase}/{result}" tcresult: "{tcbase}/{result}"
tcparfile: "{tcbase}/{parfile}" tcparfile: "{tcbase}/{parfile}"
@ -34,7 +34,7 @@ pattern:
tcprecond: "{tcresult}/{precond}" tcprecond: "{tcresult}/{precond}"
tcpostcond: "{tcresult}/{postcond}" tcpostcond: "{tcresult}/{postcond}"
# testset # testset
tsbase: "{job.conf.archiv}/{job.par.release}/{job.par.usecase}_{job.par.tltime}" tsbase: "{job.conf.archiv}/{ts}/{job.par.usecase}_{job.par.tstime}"
tslog: "{tsbase}/{log}" tslog: "{tsbase}/{log}"
tsparfile: "{tsbase}/{parfile}" tsparfile: "{tsbase}/{parfile}"
tssum: "{tsbase}/Ergebnis" tssum: "{tsbase}/Ergebnis"

Loading…
Cancel
Save