Browse Source

dialog for job execution

refactor
Ulrich 2 years ago
parent
commit
09564f3143
  1. 4
      basic/constants.py
  2. 3
      basic/message.py
  3. 21
      basic/program.py
  4. 51
      tools/job_const.py
  5. 181
      tools/job_tool.py

4
basic/constants.py

@ -32,6 +32,7 @@ SVAL_NULL = "null"
# parameter with arguments
PAR_PROGRAM = 'program'
PAR_USER = 'user'
PAR_GRAN = "gran"
PAR_PROJ = 'project'
""" definition of the project which will be tested """
PAR_APP = 'application'
@ -69,6 +70,7 @@ PAR_TESTCASE = "testcase"
PAR_TESTCASES = "testcases"
PAR_TESTSUITE = "testsuite"
# todo Trennung testsuite - usecase denn n:1-Zuordnung
PAR_TPTIME = "tptime"
PAR_TCTIME = "tctime"
PAR_TSTIME = "tstime"
PAR_TESTINSTANCES = "testinstances"
@ -77,7 +79,7 @@ PAR_DB_WHERE = "dbwhere"
""" optional parameter with a where-clause """
PAR_DB_PARTITION = "dbparts"
""" optional parameter for partitions of a partitioned tables """
LIST_MAIN_PAR = [PAR_APP, PAR_ENV, PAR_VAR, PAR_REL, PAR_TSDIR, PAR_TSDIR]
LIST_MAIN_PAR = [PAR_APP, PAR_ENV, PAR_VAR, PAR_REL, PAR_TCDIR, PAR_TSDIR]
# -------------------------------------------------------------
# attributes

3
basic/message.py

@ -371,7 +371,8 @@ class Message:
def getLoggingArgs(self, mlevel, prio, text):
verify = self.getLogLevel("msg_tool")
self.logTrace(verify, "getLoggingArgs: " + str(mlevel)+ ", "+self.format2Str(prio)+", "+self.format2Str(text))
if verify:
self.debugfile.write(verify, "getLoggingArgs: " + str(mlevel)+ ", "+self.format2Str(prio)+", "+self.format2Str(text))
out = {}
prefix = ""
if isinstance(mlevel, int):

21
basic/program.py

@ -210,9 +210,9 @@ class Job:
tools.job_tool.startJobProcesses(self)
if self.programDef[CTLG_PARSOURCE] != "":
self.par.setParameterLoaded(self)
header1 = "# # # Start Job " + tools.date_tool.formatParsedDate(str(self.start), tools.date_tool.F_DE_TSTAMP) + " # # # "
header1 = "# # # Start " + self.program + " # "
header1 += tools.date_tool.formatParsedDate(str(self.start), tools.date_tool.F_DE_TSTAMP) + " # # # "
self.m.logInfo(header1)
self.m.debug(basic.message.LIMIT_INFO, header1)
print(header1)
self.par.checkParameter(self)
self.m.logInfo(self.par.parstring)
@ -224,15 +224,16 @@ class Job:
if self.programDef[CTLG_PARTARGET] != "":
self.dumpParameter()
footer1 = "# # " + self.m.topmessage + " # # # "
footer2 = "# # # Stop Job " + tools.date_tool.formatParsedDate(str(self.start), tools.date_tool.F_DE_TSTAMP)
footer2 = "# # # Stop " + self.program + " # "
footer2 += tools.date_tool.formatParsedDate(str(self.start), tools.date_tool.F_DE_TSTAMP)
footer2 += " # " + tools.date_tool.formatParsedDate(str(self.ende), tools.date_tool.F_DE_TSTAMP) + " # # # "
footer2 += " # # # RC: " + str(self.m.getFinalRc())
footer2 += " # # # RC: " + self.m.getFinalReturncode()
self.m.logDebug("Logpath: "+self.m.logpath)
self.m.logInfo(footer1)
self.m.logInfo(footer2)
self.m.debug(basic.message.LIMIT_INFO, footer1)
self.m.debug(basic.message.LIMIT_INFO, footer2)
self.m.closeMessage()
rc = self.m.getFinalRc()
print("Logpath: "+self.m.logpath)
print(footer1)
print(footer2)
if reboot == 0:
@ -333,13 +334,13 @@ class Job:
if (not hasattr(self, "m")) or (self.m is None):
return basic.message.LIMIT_DEBUG
elif elem.find("tool") > 1 and hasattr(self, "par"):
if not hasattr(self.par, "tool") or getattr(self.par, "tool").find(elem) <= 0:
return 4
if not hasattr(self.par, "tool") or elem not in getattr(self.par, "tool"):
return 0
else:
return 4
return 2
else:
# TODO quickfix
return 4
return 0
def getInfoLevel(self, elem):
return self.getMessageLevel("info", elem)
def getDebugLevel(self, elem):

51
tools/job_const.py

@ -0,0 +1,51 @@
import basic.constants as B
from basic import constants as B
PROG_TC_INIT = "init_testcase"
PROG_TC_EXECUTE = "execute_testcase"
PROG_TC_COLLECT = "collect_testcase"
PROG_TC_COMPARE = "compare_testcase"
PROG_TS_INIT = "init_testsuite"
PROG_TS_EXECUTE = "execute_testsuite"
PROG_TS_COLLECT = "collect_testsuite"
PROG_TS_FINISH = "finish_testsuite"
PROG_TEST_EXECUTER = "test_executer"
LIST_TC_PROGS = [PROG_TC_INIT, PROG_TC_EXECUTE, PROG_TC_COLLECT, PROG_TC_COMPARE]
LIST_TS_PROGS = [PROG_TS_INIT, PROG_TS_EXECUTE, PROG_TS_COLLECT, PROG_TS_FINISH]
PROG_CHECK_ENV = "check_environment"
PROG_CHECK_CONF = "check_configuration"
PROG_CHECK_SPEC = "check_specification"
PROG_UNZIP_RESULT = "unzip_result"
PROG_DECLARE_RESULT = "declare_result"
PROG_CLEAN_WORKSPACE = "clean_workspace"
PROG_MAKE_WORKSPACE = "make_workspace"
PROG_UNIT_TESTER = "unit_tester"
LIST_SERVICE_PROG = [PROG_CHECK_ENV, PROG_CHECK_CONF, PROG_CHECK_SPEC, PROG_UNZIP_RESULT, PROG_DECLARE_RESULT,
PROG_CLEAN_WORKSPACE, PROG_MAKE_WORKSPACE, PROG_UNIT_TESTER]
PROC_TP_EXECUTION = "Testplan ausfuehren"
PROC_TS_EXECUTION = "Testsuite ausfuehren"
PROC_TS_STEPWISE = "Testsuite Job fuer Job ausfuehren"
PROC_TC_EXECUTION = "Testfall ausfuehren"
PROC_TC_STEPWISE = "Testfall Job fuer Job ausfuehren"
PROC_REDO_EXECUTION = "Job der Testausfuehrung wiederholen"
PROC_SINGLE_JOB = "Einzelnes Programm ausfuehren"
LIST_PROC = [PROC_TP_EXECUTION, PROC_TS_EXECUTION, PROC_TS_STEPWISE, PROC_TC_EXECUTION, PROC_TC_STEPWISE,
PROC_REDO_EXECUTION, PROC_SINGLE_JOB]
GRAN_TP = "Testplan"
GRAN_TS = "Testsuite"
GRAN_TC = "Testfall"
LIST_GRAN = [GRAN_TP, GRAN_TS, GRAN_TC]
MODEL_PROC = "proc"
MODEL_GRAN = "gran"
MODEL_APP = B.PAR_APP
MODEL_ENV = B.PAR_ENV
MODEL_COMP = B.PAR_COMP
MODEL_RELEASE = B.PAR_REL
LIST_MODEL = [MODEL_APP, MODEL_ENV, MODEL_COMP, MODEL_RELEASE]
CHOICE_GRAN = "Testgranularitaet auswaehlen"
CHOICE_APP = "Anwendung auswaehlen"
CHOICE_ENV = "Umgebung auswaehlen"
CHOICE_SPEC = "Testspezifikation auswaehlen"
CHOICE_ARCHIV = "Testausfuehrung auswaehlen"
CHOICE_TIME = "Testzeit auswaehlen"
CHOICE_VARIANT = "Testvariante auswaehlen"

181
tools/job_tool.py

@ -21,10 +21,16 @@
"""
import getpass
import os.path
import pprint
import sys
import json
import basic.program
import basic.constants as B
import check_environment
import check_specification
import check_configuration
import tools.job_const as J
try:
import collect_testcase
import compare_testcase
@ -37,45 +43,13 @@ except Exception as e:
pass
import tools.path_tool
import tools.file_tool
import tools.date_tool as date_tool
import components.tools.job_tool
PROG_TC_INIT = "init_testcase"
PROG_TC_EXECUTE = "execute_testcase"
PROG_TC_COLLECT = "collect_testcase"
PROG_TC_COMPARE = "compare_testcase"
PROG_TS_INIT = "init_testsuite"
PROG_TS_EXECUTE = "execute_testsuite"
PROG_TS_COLLECT = "collect_testsuite"
PROG_TS_FINISH = "finish_testsuite"
PROG_TEST_EXECUTER = "test_executer"
LIST_TC_PROGS = [PROG_TC_INIT, PROG_TC_EXECUTE, PROG_TC_COLLECT, PROG_TC_COMPARE]
LIST_TS_PROGS = [PROG_TS_INIT, PROG_TS_EXECUTE, PROG_TS_COLLECT, PROG_TS_FINISH]
PROG_CHECK_ENV = "check_environment"
PROG_CHECK_CONF = "check_configuration"
PROG_CHECK_SPEC = "check_specification"
PROG_UNZIP_RESULT = "unzip_result"
PROG_DECLARE_RESULT = "declare_result"
PROG_CLEAN_WORKSPACE = "clean_workspace"
PROG_MAKE_WORKSPACE = "make_workspace"
PROG_UNIT_TESTER = "unit_tester"
LIST_SERVICE_PROG = [PROG_CHECK_ENV, PROG_CHECK_CONF, PROG_CHECK_SPEC, PROG_UNZIP_RESULT, PROG_DECLARE_RESULT,
PROG_CLEAN_WORKSPACE, PROG_MAKE_WORKSPACE, PROG_UNIT_TESTER]
PROC_TP_EXECUTION = "Testplan ausfuehren"
PROC_TS_EXECUTION = "Testsuite ausfuehren"
PROC_TS_STEPWISE = "Testsuite Job fuer Job ausfuehren"
PROC_TC_EXECUTION = "Testfall ausfuehren"
PROC_TC_STEPWISE = "Testfall Job fuer Job ausfuehren"
PROC_REDO_EXECUTION = "Job der Testausfuehrung wiederholen"
PROC_SINGLE_JOB = "Einzelnes Programm ausfuehren"
LIST_PROC = [PROC_TP_EXECUTION, PROC_TS_EXECUTION, PROC_TS_STEPWISE, PROC_TC_EXECUTION, PROC_TC_STEPWISE,
PROC_REDO_EXECUTION, PROC_SINGLE_JOB]
GRAN_TP = "Testplan"
GRAN_TS = "Testsuite"
GRAN_TC = "Testfall"
LIST_GRAN = [GRAN_TP, GRAN_TS, GRAN_TC]
import model.application
import model.environment
import model.testplan
import model.testsuite
import model.testcase
def hasModul(komp):
@ -109,7 +83,7 @@ def getUser(job=None):
def getUserProject(job=None):
# TODO move to objects.user
return "xxx"
return "TESTPROJ"
def getActChildPath(job):
return os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_DEBUG], job.username+".json")
@ -134,23 +108,39 @@ def start_child_process(job, args):
:param args: job-args
:return:
"""
verifiy = job.getDebugLevel("job_tool")
job.m.logDebug(verifiy, "start_child_process")
job.m.logTrace(verifiy, args)
print(str(args))
path = tools.path_tool.getActualJsonPath(job)
print("------- "+path)
tools.file_tool.writeFileDict(job.m, job, path, args)
childArgs = {}
childArgs[B.PAR_APP] = args[B.PAR_APP]
childArgs[B.PAR_ENV] = args[B.PAR_ENV]
if B.PAR_STEP in args:
childArgs[B.PAR_STEP] = args[B.PAR_STEP]
if B.PAR_TCDIR in args:
childArgs[B.PAR_TCDIR] = args[B.PAR_TCDIR]
childArgs[B.PAR_TESTCASE] = args["entity"]
elif B.PAR_TSDIR in args:
childArgs[B.PAR_TSDIR] = args[B.PAR_TSDIR]
childArgs[B.PAR_TESTSUITE] = args["entity"]
print("process-programm " + args[B.PAR_PROGRAM])
childJob = basic.program.Job(args[B.PAR_PROGRAM], childArgs)
for p in args:
if p in B.LIST_MAIN_PAR:
childArgs[p] = args[p]
if p in [B.PAR_USER]:
childArgs[p] = args[p]
if p in [B.PAR_TESTCASE, B.PAR_TCTIME]:
childArgs[B.PAR_TCTIME] = date_tool.getActdate(date_tool.F_LOG)
childArgs[B.PAR_TESTCASE] = args[B.PAR_TESTCASE]
childArgs[B.PAR_GRAN] = B.PAR_TESTCASE
elif p in [B.PAR_TESTSUITE, B.PAR_TSTIME]:
childArgs[B.PAR_TSTIME] = date_tool.getActdate(date_tool.F_LOG)
childArgs[B.PAR_TESTSUITE] = args[B.PAR_TESTSUITE]
childArgs[B.PAR_GRAN] = B.PAR_TESTSUITE
elif p in [B.PAR_TESTPLAN]:
childArgs[B.PAR_TPTIME] = date_tool.getActdate(date_tool.F_LOG)
childArgs[B.PAR_TESTPLAN] = args[B.PAR_TESTPLAN]
childArgs[B.PAR_GRAN] = B.PAR_TESTPLAN
job.m.logInfo("process-programm " + args[B.PAR_PROGRAM] + " :: " + str(childArgs))
childJob = basic.program.Job(args[B.PAR_PROGRAM], "ulrichX", childArgs)
if hasattr(job.par, "tool"):
setattr(childJob.par, "tool", getattr(job.par, "tool"))
childJob.m.logDebug(verifiy, "start_child_process "+childJob.program)
childJob.m.logDebug(verifiy, args)
childJob.m.logDebug(verifiy, B.LIST_MAIN_PAR)
childJob.m.logDebug(verifiy, childArgs)
childJob.startJob()
if args[B.PAR_PROGRAM] == "init_testcase":
init_testcase.startPyJob(childJob)
@ -170,6 +160,13 @@ def start_child_process(job, args):
finish_testsuite.startPyJob(childJob)
elif args[B.PAR_PROGRAM] == "test_executer":
test_executer.startPyJob(childJob)
elif args[B.PAR_PROGRAM] == "check_environment":
check_environment.startPyJob(childJob)
elif args[B.PAR_PROGRAM] == "check_configuration":
check_configuration.startPyJob(childJob)
elif args[B.PAR_PROGRAM] == "check_specification":
check_specification.startPyJob(childJob)
childJob.stopJob(1)
return childJob
def select_gran(job, programDef):
@ -177,14 +174,7 @@ def select_gran(job, programDef):
select one of testcase, testsuite or testplan
:return:
"""
return LIST_GRAN
def select_environment(job, programDef):
"""
read environments and select one of them
:return:
"""
return ""
return J.LIST_GRAN
def select_project(job, programDef):
"""
@ -192,27 +182,86 @@ def select_project(job, programDef):
:return:
"""
# the implemented projects which are configured in conf/basic.yml
return [""]
return ["a", "b", "c"]
def select_application(job, programDef, project):
"""
read the application of the project and select one of them
:return:
"""
verify = job.m.getLogLevel("job_tool")
job.m.logDebug(verify, "select_application "+project)
# the application are configured in comp/applications.yml which are optionally stored in the database
return ""
projList = [project]
apps = model.application.select_applications(job, projList)
return list(apps.keys())
def select_environment(job, programDef, project):
"""
read environments and select one of them
:return:
"""
print("selectr env "+project)
projList = [project]
envs = model.environment.select_environments(job, projList)
return list(envs.keys())
def select_spec(job, programDef, gran, application):
def select_spec(job, programDef, gran, args):
"""
read the testspec of the granularity,application and select one of them with the variant
:return:
"""
return ""
print("select spec "+gran+" "+str(args))
if gran in [J.GRAN_TP.lower(), J.GRAN_TP]:
print("select tp spec " + gran)
return []
elif gran in [B.PAR_TESTSUITE, J.GRAN_TS]:
print("select ts spec " + gran)
out = model.testsuite.select_testsuites(job, [args[B.PAR_PROJ]], [args[B.PAR_APP]])
return list(out.keys())
elif gran in [B.PAR_TESTCASE, J.GRAN_TC]:
print("select tc spec " + gran)
out = model.testcase.select_testcases(job, [args[B.PAR_PROJ]], [args[B.PAR_APP]])
return list(out.keys())
print("select no spec "+gran)
def select_archiv(job, programDef, gran, project):
"""
read the testobjects of the granularity,project and select one of them with the time
:return:
"""
return ""
print("select archiv")
return ["a", "b", "c"]
def select_testtime(job, programDef, gran, args):
"""
read the testobjects of the granularity,project and select one of them with the time
:return:
"""
return ["a", "b", "c"]
def select_variant(job, programDef, gran, args):
"""
read the testobjects of the granularity,project and select one of them with the time
:return:
"""
print("select spec "+gran)
if gran == J.GRAN_TP.lower():
print("select tp spec " + gran)
return [""]
elif gran in [B.PAR_TESTSUITE, J.GRAN_TS]:
print("select ts spec " + gran)
out = model.testsuite.select_testsuite(job, args[B.PAR_PROJ], args[B.PAR_TESTSUITE])
if "variant" not in out:
return [""]
return list(out["variant"].keys())
elif gran in [B.PAR_TESTCASE, J.GRAN_TC]:
print("select tc spec " + gran + " " + str(args))
out = model.testcase.select_testcase(job, args[B.PAR_PROJ], args[B.PAR_TESTCASE])
if "variant" not in out:
return [""]
return list(out["variant"].keys())
else:
raise Exception("for gran "+gran+" variant can not be selected")
print("select no spec "+gran)

Loading…
Cancel
Save