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

3
basic/message.py

@ -371,7 +371,8 @@ class Message:
def getLoggingArgs(self, mlevel, prio, text): def getLoggingArgs(self, mlevel, prio, text):
verify = self.getLogLevel("msg_tool") 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 = {} out = {}
prefix = "" prefix = ""
if isinstance(mlevel, int): if isinstance(mlevel, int):

21
basic/program.py

@ -210,9 +210,9 @@ class Job:
tools.job_tool.startJobProcesses(self) tools.job_tool.startJobProcesses(self)
if self.programDef[CTLG_PARSOURCE] != "": if self.programDef[CTLG_PARSOURCE] != "":
self.par.setParameterLoaded(self) 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.logInfo(header1)
self.m.debug(basic.message.LIMIT_INFO, header1)
print(header1) print(header1)
self.par.checkParameter(self) self.par.checkParameter(self)
self.m.logInfo(self.par.parstring) self.m.logInfo(self.par.parstring)
@ -224,15 +224,16 @@ class Job:
if self.programDef[CTLG_PARTARGET] != "": if self.programDef[CTLG_PARTARGET] != "":
self.dumpParameter() self.dumpParameter()
footer1 = "# # " + self.m.topmessage + " # # # " 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 += " # " + 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(footer1)
self.m.logInfo(footer2) self.m.logInfo(footer2)
self.m.debug(basic.message.LIMIT_INFO, footer1)
self.m.debug(basic.message.LIMIT_INFO, footer2)
self.m.closeMessage() self.m.closeMessage()
rc = self.m.getFinalRc() rc = self.m.getFinalRc()
print("Logpath: "+self.m.logpath)
print(footer1) print(footer1)
print(footer2) print(footer2)
if reboot == 0: if reboot == 0:
@ -333,13 +334,13 @@ class Job:
if (not hasattr(self, "m")) or (self.m is None): if (not hasattr(self, "m")) or (self.m is None):
return basic.message.LIMIT_DEBUG return basic.message.LIMIT_DEBUG
elif elem.find("tool") > 1 and hasattr(self, "par"): elif elem.find("tool") > 1 and hasattr(self, "par"):
if not hasattr(self.par, "tool") or getattr(self.par, "tool").find(elem) <= 0: if not hasattr(self.par, "tool") or elem not in getattr(self.par, "tool"):
return 4 return 0
else: else:
return 4 return 2
else: else:
# TODO quickfix # TODO quickfix
return 4 return 0
def getInfoLevel(self, elem): def getInfoLevel(self, elem):
return self.getMessageLevel("info", elem) return self.getMessageLevel("info", elem)
def getDebugLevel(self, 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 getpass
import os.path import os.path
import pprint
import sys import sys
import json
import basic.program import basic.program
import basic.constants as B import basic.constants as B
import check_environment
import check_specification
import check_configuration
import tools.job_const as J
try: try:
import collect_testcase import collect_testcase
import compare_testcase import compare_testcase
@ -37,45 +43,13 @@ except Exception as e:
pass pass
import tools.path_tool import tools.path_tool
import tools.file_tool import tools.file_tool
import tools.date_tool as date_tool
import components.tools.job_tool import components.tools.job_tool
import model.application
PROG_TC_INIT = "init_testcase" import model.environment
PROG_TC_EXECUTE = "execute_testcase" import model.testplan
PROG_TC_COLLECT = "collect_testcase" import model.testsuite
PROG_TC_COMPARE = "compare_testcase" import model.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]
def hasModul(komp): def hasModul(komp):
@ -109,7 +83,7 @@ def getUser(job=None):
def getUserProject(job=None): def getUserProject(job=None):
# TODO move to objects.user # TODO move to objects.user
return "xxx" return "TESTPROJ"
def getActChildPath(job): def getActChildPath(job):
return os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_DEBUG], job.username+".json") 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 :param args: job-args
:return: :return:
""" """
verifiy = job.getDebugLevel("job_tool")
job.m.logDebug(verifiy, "start_child_process")
job.m.logTrace(verifiy, args)
print(str(args)) print(str(args))
path = tools.path_tool.getActualJsonPath(job) path = tools.path_tool.getActualJsonPath(job)
print("------- "+path)
tools.file_tool.writeFileDict(job.m, job, path, args) tools.file_tool.writeFileDict(job.m, job, path, args)
childArgs = {} childArgs = {}
childArgs[B.PAR_APP] = args[B.PAR_APP] for p in args:
childArgs[B.PAR_ENV] = args[B.PAR_ENV] if p in B.LIST_MAIN_PAR:
if B.PAR_STEP in args: childArgs[p] = args[p]
childArgs[B.PAR_STEP] = args[B.PAR_STEP] if p in [B.PAR_USER]:
if B.PAR_TCDIR in args: childArgs[p] = args[p]
childArgs[B.PAR_TCDIR] = args[B.PAR_TCDIR] if p in [B.PAR_TESTCASE, B.PAR_TCTIME]:
childArgs[B.PAR_TESTCASE] = args["entity"] childArgs[B.PAR_TCTIME] = date_tool.getActdate(date_tool.F_LOG)
elif B.PAR_TSDIR in args: childArgs[B.PAR_TESTCASE] = args[B.PAR_TESTCASE]
childArgs[B.PAR_TSDIR] = args[B.PAR_TSDIR] childArgs[B.PAR_GRAN] = B.PAR_TESTCASE
childArgs[B.PAR_TESTSUITE] = args["entity"] elif p in [B.PAR_TESTSUITE, B.PAR_TSTIME]:
print("process-programm " + args[B.PAR_PROGRAM]) childArgs[B.PAR_TSTIME] = date_tool.getActdate(date_tool.F_LOG)
childJob = basic.program.Job(args[B.PAR_PROGRAM], childArgs) 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() childJob.startJob()
if args[B.PAR_PROGRAM] == "init_testcase": if args[B.PAR_PROGRAM] == "init_testcase":
init_testcase.startPyJob(childJob) init_testcase.startPyJob(childJob)
@ -170,6 +160,13 @@ def start_child_process(job, args):
finish_testsuite.startPyJob(childJob) finish_testsuite.startPyJob(childJob)
elif args[B.PAR_PROGRAM] == "test_executer": elif args[B.PAR_PROGRAM] == "test_executer":
test_executer.startPyJob(childJob) 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 return childJob
def select_gran(job, programDef): def select_gran(job, programDef):
@ -177,14 +174,7 @@ def select_gran(job, programDef):
select one of testcase, testsuite or testplan select one of testcase, testsuite or testplan
:return: :return:
""" """
return LIST_GRAN return J.LIST_GRAN
def select_environment(job, programDef):
"""
read environments and select one of them
:return:
"""
return ""
def select_project(job, programDef): def select_project(job, programDef):
""" """
@ -192,27 +182,86 @@ def select_project(job, programDef):
:return: :return:
""" """
# the implemented projects which are configured in conf/basic.yml # the implemented projects which are configured in conf/basic.yml
return [""] return ["a", "b", "c"]
def select_application(job, programDef, project): def select_application(job, programDef, project):
""" """
read the application of the project and select one of them read the application of the project and select one of them
:return: :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 # 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 read the testspec of the granularity,application and select one of them with the variant
:return: :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): def select_archiv(job, programDef, gran, project):
""" """
read the testobjects of the granularity,project and select one of them with the time read the testobjects of the granularity,project and select one of them with the time
:return: :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