|
|
@ -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) |
|
|
|
|
|
|
|