|
@ -11,14 +11,45 @@ |
|
|
""" |
|
|
""" |
|
|
import os.path |
|
|
import os.path |
|
|
import json |
|
|
import json |
|
|
|
|
|
import re |
|
|
|
|
|
|
|
|
import basic.program |
|
|
import basic.program |
|
|
import basic.constants as B |
|
|
import basic.constants as B |
|
|
|
|
|
import collect_testcase |
|
|
|
|
|
import compare_testcase |
|
|
|
|
|
import copy_appdummy |
|
|
|
|
|
import execute_testcase |
|
|
|
|
|
import finish_testsuite |
|
|
|
|
|
import init_testcase |
|
|
|
|
|
import init_testsuite |
|
|
|
|
|
import test_executer |
|
|
import utils.file_tool |
|
|
import utils.file_tool |
|
|
|
|
|
import utils.data_const as D |
|
|
|
|
|
import utils.date_tool |
|
|
|
|
|
import utils.path_tool |
|
|
|
|
|
import utils.path_const as P |
|
|
|
|
|
|
|
|
tempJob = {} |
|
|
tempJob = {} |
|
|
|
|
|
|
|
|
PROGRAM_NAME = "unit" |
|
|
PROGRAM_NAME = "service" |
|
|
|
|
|
|
|
|
|
|
|
DLG_TESTCASE = "Testfall" |
|
|
|
|
|
DLG_TESTSUITE = "Testsuite" |
|
|
|
|
|
DLG_COMPLETE = "Komplettausfuehrung" |
|
|
|
|
|
LIST_DLG_GRAN = [DLG_TESTCASE, DLG_TESTSUITE] |
|
|
|
|
|
DLG_START_QUESTION = "was soll getestet werden" |
|
|
|
|
|
# DLG_TESTPLAN = "Testplan" |
|
|
|
|
|
DLG_ENVIRONMENT = "Umgebung" |
|
|
|
|
|
DLG_APPLICATION = "Anwendung" |
|
|
|
|
|
DLG_REDO = "wiederholen" |
|
|
|
|
|
DLG_CONTINUE = "fortsetzen" |
|
|
|
|
|
DLG_DUMMY_STEP = "Dummy-Schritt" |
|
|
|
|
|
DLG_NEWJOB = "neuer Job" |
|
|
|
|
|
|
|
|
JSON_FILE = "actualJob.json" |
|
|
JSON_FILE = "actualJob.json" |
|
|
JOB_NR = { |
|
|
JOB_NR = { |
|
|
|
|
|
DLG_TESTSUITE : { |
|
|
|
|
|
"start": "init_testsuite", |
|
|
"init_testsuite": { |
|
|
"init_testsuite": { |
|
|
"jobnr": "0" }, |
|
|
"jobnr": "0" }, |
|
|
"execute_testsuite": { |
|
|
"execute_testsuite": { |
|
@ -28,43 +59,102 @@ JOB_NR = { |
|
|
"compare_testsuite": { |
|
|
"compare_testsuite": { |
|
|
"jobnr": "3"}, |
|
|
"jobnr": "3"}, |
|
|
"finish_testsuite": { |
|
|
"finish_testsuite": { |
|
|
"jobnr": "4"}, |
|
|
"jobnr": "4"} |
|
|
|
|
|
}, |
|
|
|
|
|
DLG_TESTCASE: { |
|
|
|
|
|
"start": "init_testcase", |
|
|
"init_testcase": { |
|
|
"init_testcase": { |
|
|
"jobnr": "5" }, |
|
|
"jobnr": "5" }, |
|
|
"execute_testcase": { |
|
|
"execute_testcase": { |
|
|
"jobnr": "6" }, |
|
|
"jobnr": "6" }, |
|
|
"collect_testcase": { |
|
|
"collect_testcase": { |
|
|
"jobnr": "7" }, |
|
|
"jobnr": "7" }, |
|
|
"compare_testcase": { |
|
|
"copy_appdummy": { |
|
|
"jobnr": "8" }, |
|
|
"jobnr": "8" }, |
|
|
"check_environment": { |
|
|
"compare_testcase": { |
|
|
"jobnr": "9" }, |
|
|
"jobnr": "9" }, |
|
|
"test_executer": { |
|
|
}, |
|
|
|
|
|
"check_environment": { |
|
|
"jobnr": "10" }, |
|
|
"jobnr": "10" }, |
|
|
|
|
|
"test_executer": { |
|
|
|
|
|
"jobnr": "11"}, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
JOB_LIST = [ |
|
|
JOB_LIST = [ |
|
|
"init_testsuite", |
|
|
"init_testsuite", # 0 |
|
|
"execute_testsuite", |
|
|
"execute_testsuite", # 1 |
|
|
"collect_testsuite", |
|
|
"collect_testsuite", # 2 |
|
|
"compare_testsuite", |
|
|
"compare_testsuite", # 3 |
|
|
"finish_testsuite", |
|
|
"finish_testsuite", # 4 |
|
|
"init_testcase", |
|
|
"init_testcase", # 5 |
|
|
"execute_testcase", |
|
|
"execute_testcase", # 6 |
|
|
"collect_testcase", |
|
|
"collect_testcase", # 7 |
|
|
"compare_testcase", |
|
|
"copy_appdummy", # 8 |
|
|
"check_environment", |
|
|
"compare_testcase", # 9 |
|
|
"test_executer" |
|
|
"check_environment", # 10 |
|
|
|
|
|
"test_executer" # 11 |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
appList = [] |
|
|
appList = [] |
|
|
envList = ["ENV01"] |
|
|
envList = [] |
|
|
testList = {"TEST": [ |
|
|
entities = {} |
|
|
"TC0001", "TST001" |
|
|
entities[DLG_TESTCASE] = {} |
|
|
]} |
|
|
entities[DLG_TESTSUITE] = {} |
|
|
|
|
|
|
|
|
def readContext(job): |
|
|
def readContext(job): |
|
|
for k in job.conf.confs["applications"]: |
|
|
for k in job.conf.confs[B.SUBJECT_APPS]: |
|
|
appList.append(k) |
|
|
appList.append(k) |
|
|
|
|
|
path = job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_ENV] |
|
|
|
|
|
if os.path.exists(path): |
|
|
|
|
|
for d in os.listdir(path): |
|
|
|
|
|
print ("-- "+d) |
|
|
|
|
|
if not os.path.isdir(os.path.join(path, d)): |
|
|
|
|
|
continue |
|
|
|
|
|
if d[0:1] == "_": |
|
|
|
|
|
continue |
|
|
|
|
|
envList.append(d) |
|
|
|
|
|
path = job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_TDATA] |
|
|
|
|
|
if os.path.exists(path): |
|
|
|
|
|
for d in os.listdir(path): |
|
|
|
|
|
print("tdata path "+d) |
|
|
|
|
|
if not os.path.isdir(os.path.join(path, d)): |
|
|
|
|
|
print("continue a") |
|
|
|
|
|
continue |
|
|
|
|
|
if d[0:1] == "_": |
|
|
|
|
|
print("continue b") |
|
|
|
|
|
continue |
|
|
|
|
|
specpath = os.path.join(path, d, D.DFILE_TESTCASE_NAME + ".csv") |
|
|
|
|
|
readSpec(job, d, DLG_TESTCASE, specpath) |
|
|
|
|
|
specpath = os.path.join(path, d, D.DFILE_TESTSUITE_NAME + ".csv") |
|
|
|
|
|
readSpec(job, d, DLG_TESTSUITE, specpath) |
|
|
|
|
|
|
|
|
|
|
|
def readSpec(job, testentity, testgran, specpath): |
|
|
|
|
|
print("spec "+specpath) |
|
|
|
|
|
if not os.path.isfile(specpath): |
|
|
|
|
|
print("continue c") |
|
|
|
|
|
return |
|
|
|
|
|
text = utils.file_tool.readFileText(job, specpath, job.m) |
|
|
|
|
|
print("-----------\n"+text+"\n------------------") |
|
|
|
|
|
if re.match(r".*?depricated;[jJyY]", text): |
|
|
|
|
|
return |
|
|
|
|
|
if re.match(r".*\nhead:application;", text): |
|
|
|
|
|
print("## app gematcht") |
|
|
|
|
|
res = re.search(r".*head:application;(.+)\n", text) |
|
|
|
|
|
apps = res.group(1).replace(";", ",").split(",") |
|
|
|
|
|
print("# "+str(apps)) |
|
|
|
|
|
for a in apps: |
|
|
|
|
|
if len(a) < 1: |
|
|
|
|
|
break |
|
|
|
|
|
if a not in entities[testgran]: |
|
|
|
|
|
entities[testgran][a] = [] |
|
|
|
|
|
print(a+" in "+testentity+" "+testgran+" -- "+str(entities)) |
|
|
|
|
|
entities[testgran][a].append(testentity) |
|
|
|
|
|
|
|
|
|
|
|
def printProc(job, process): |
|
|
|
|
|
print("--------------------------------------------------") |
|
|
|
|
|
for k in process: |
|
|
|
|
|
print("| {0:15s} : {1}".format(k, process[k])) |
|
|
|
|
|
print("--------------------------------------------------") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def restartActualProcess(job): |
|
|
def restartActualProcess(job): |
|
@ -74,61 +164,105 @@ def restartActualProcess(job): |
|
|
""" |
|
|
""" |
|
|
path = os.path.join(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_DEBUG], JSON_FILE) |
|
|
path = os.path.join(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_DEBUG], JSON_FILE) |
|
|
if os.path.exists(path): |
|
|
if os.path.exists(path): |
|
|
actProc = utils.file_tool.readFileDict(job, path) |
|
|
actProc = utils.file_tool.readFileDict(job, path, job.m) |
|
|
jobNr = int(JOB_NR[actProc["job"]]["jobnr"]) |
|
|
print("restartActJob "+str(actProc)) |
|
|
question = "Prozess " |
|
|
printProc(job, actProc) |
|
|
choiceList = "" |
|
|
step = int(actProc["step"]) |
|
|
if jobNr < 8 and jobNr != 4: |
|
|
if actProc["program"] == "test_executer": |
|
|
question += "F_ortsetzen | " |
|
|
if step > 5: |
|
|
choiceList += "f | " |
|
|
dialogProcess(job) |
|
|
question += "W_iederholen | N_euen Prozess | X_exit" |
|
|
else: |
|
|
choiceList = "w | n | x ?" |
|
|
actProc["step"] = str(step+1) |
|
|
print("+-----------------------------------------------") |
|
|
startProcess(job, actProc) |
|
|
for k in actProc: |
|
|
selection = [DLG_NEWJOB, DLG_REDO] |
|
|
print('| {:6s} : {:60s}'.format(k, actProc[k])) |
|
|
|
|
|
print("+-----------------------------------------------") |
|
|
nr = int(JOB_NR[actProc["gran"]][actProc["program"]]["jobnr"]) |
|
|
print(question) |
|
|
if (actProc["gran"] == DLG_TESTSUITE and nr < 4) or (actProc["gran"] == DLG_TESTCASE and nr < 9): |
|
|
choice = input("Auswahl "+choiceList) |
|
|
selection.append(DLG_CONTINUE) |
|
|
choiceList.replace(" | ","") |
|
|
if nr == 7: |
|
|
if choice.lower() not in choiceList[:-1]: |
|
|
selection.append(DLG_DUMMY_STEP) |
|
|
print("FEHLER : falsche Auswahl") |
|
|
choice = getChoice(job, selection, DLG_ENVIRONMENT) |
|
|
elif choice.lower() == "x": |
|
|
print(choice) |
|
|
job.stopJob(0) |
|
|
if choice == DLG_REDO: |
|
|
elif choice.lower() == "w": |
|
|
|
|
|
startProcess(job, actProc) |
|
|
startProcess(job, actProc) |
|
|
elif choice.lower() == "f": |
|
|
elif choice == DLG_DUMMY_STEP: |
|
|
actProc["job"] = JOB_NR[int(jobNr)+1] |
|
|
actProc["program"] = JOB_LIST[nr+1] |
|
|
startProcess(job, actProc) |
|
|
startProcess(job, actProc) |
|
|
elif choice.lower() == "n": |
|
|
elif choice == DLG_CONTINUE: |
|
|
createProcess(job) |
|
|
if nr == 7: |
|
|
|
|
|
nr = 9 |
|
|
else: |
|
|
else: |
|
|
print("unbekannte Situation") |
|
|
nr += 1 |
|
|
|
|
|
print (" act nr "+str(nr)) |
|
|
|
|
|
actProc["step"] = str(step + 1) |
|
|
|
|
|
actProc["program"] = JOB_LIST[nr] |
|
|
|
|
|
startProcess(job, actProc) |
|
|
|
|
|
elif choice == DLG_NEWJOB: |
|
|
|
|
|
dialogProcess(job) |
|
|
else: |
|
|
else: |
|
|
createProcess(job) |
|
|
dialogProcess(job) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def createProcess(job): |
|
|
def dialogProcess(job): |
|
|
|
|
|
""" |
|
|
|
|
|
dialog for selection and starting a process |
|
|
|
|
|
:param job: |
|
|
|
|
|
:return: |
|
|
|
|
|
""" |
|
|
process = {} |
|
|
process = {} |
|
|
index = 0 |
|
|
index = 0 |
|
|
print("create new process") |
|
|
print("create new process") |
|
|
process["app"] = getChoice(job, appList, "Anwendung") |
|
|
selection = [] |
|
|
|
|
|
selection = LIST_DLG_GRAN |
|
|
|
|
|
if DLG_TESTCASE + " - " + DLG_COMPLETE not in selection: |
|
|
|
|
|
selection.append(DLG_TESTCASE + " - " + DLG_COMPLETE) |
|
|
|
|
|
if DLG_TESTSUITE + " - " + DLG_COMPLETE not in selection: |
|
|
|
|
|
selection.append(DLG_TESTSUITE + " - " + DLG_COMPLETE) |
|
|
|
|
|
choice = getChoice(job, LIST_DLG_GRAN, DLG_START_QUESTION) |
|
|
|
|
|
if DLG_COMPLETE in choice: |
|
|
|
|
|
process["gran"] = choice[0:-3-len(DLG_COMPLETE)] |
|
|
|
|
|
process["program"] = "test_executer" |
|
|
|
|
|
process["step"] = 1 |
|
|
|
|
|
else: |
|
|
|
|
|
process["gran"] = choice |
|
|
|
|
|
process["program"] = JOB_NR[process["gran"]]["start"] |
|
|
|
|
|
process["step"] = 1 |
|
|
|
|
|
if len(appList) == 1: |
|
|
|
|
|
process["app"] = appList[0] |
|
|
|
|
|
else: |
|
|
|
|
|
process["app"] = getChoice(job, appList, DLG_ENVIRONMENT) |
|
|
# |
|
|
# |
|
|
if len(envList) == 1: |
|
|
if len(envList) == 1: |
|
|
process["env"] = envList[0] |
|
|
process["env"] = envList[0] |
|
|
else: |
|
|
else: |
|
|
process["env"] = getChoice(job, envList, "Umgebung") |
|
|
process["env"] = getChoice(job, envList, DLG_ENVIRONMENT) |
|
|
# |
|
|
# |
|
|
process["tc"] = getChoice(job, testList[process["app"]], "Testfall") |
|
|
if len(entities[process["gran"]][process["app"]]) == 1: |
|
|
|
|
|
process["entity"] = entities[process["gran"]][process["app"]][0] |
|
|
|
|
|
else: |
|
|
|
|
|
process["entity"] = getChoice(job, entities[process["gran"]][process["app"]], process["gran"]) |
|
|
print(str(process)) |
|
|
print(str(process)) |
|
|
|
|
|
setattr(job.par, B.PAR_ENV, process["env"]) |
|
|
|
|
|
setattr(job.par, B.PAR_APP, process["app"]) |
|
|
|
|
|
if process["gran"] == DLG_TESTCASE: |
|
|
|
|
|
setattr(job.par, B.PAR_TESTCASE, process["entity"]) |
|
|
|
|
|
setattr(job.par, B.PAR_TCTIME, utils.date_tool.getActdate(utils.date_tool.F_DIR)) |
|
|
|
|
|
path = utils.path_tool.composePattern(job, "{"+P.P_TCBASE+"}", None) |
|
|
|
|
|
process[B.PAR_TCDIR] = path |
|
|
|
|
|
elif process["gran"] == DLG_TESTSUITE: |
|
|
|
|
|
setattr(job.par, B.PAR_TESTSUITE, process["entity"]) |
|
|
|
|
|
setattr(job.par, B.PAR_TSTIME, utils.date_tool.getActdate(utils.date_tool.F_DIR)) |
|
|
|
|
|
path = utils.path_tool.composePattern(job, "{"+P.P_TSBASE+"}", None) |
|
|
|
|
|
process[B.PAR_TSDIR] = path |
|
|
|
|
|
startProcess(job, process) |
|
|
|
|
|
|
|
|
def getChoice(job, choiselist, description): |
|
|
def getChoice(job, choiselist, description): |
|
|
index = 0 |
|
|
index = 0 |
|
|
print("+------------- "+description+" ----------") |
|
|
print("+------------- "+description+" ----------") |
|
|
print('| {:2d} : {:60s}'.format(0, "exit")) |
|
|
print('| | {:2d} : {:60s}'.format(0, "exit")) |
|
|
for k in choiselist: |
|
|
for k in choiselist: |
|
|
index += 1 |
|
|
index += 1 |
|
|
print('| {:2d} : {:60s}'.format(index, k)) |
|
|
print('| | {:2d} : {:60s}'.format(index, k)) |
|
|
print("+-----------------------------------------------") |
|
|
print("+-----------------------------------------------") |
|
|
choice = input("Auswahl 1-" + str(index) + ": ") |
|
|
choice = input("Auswahl 1-" + str(index) + ": ") |
|
|
if not choice.isnumeric(): |
|
|
if not choice.isnumeric(): |
|
@ -145,9 +279,45 @@ def getChoice(job, choiselist, description): |
|
|
|
|
|
|
|
|
def startProcess(job, process): |
|
|
def startProcess(job, process): |
|
|
print(str(process)) |
|
|
print(str(process)) |
|
|
|
|
|
path = os.path.join(job.conf.confs[B.SUBJECT_PATH][B.ATTR_PATH_DEBUG], JSON_FILE) |
|
|
|
|
|
utils.file_tool.writeFileDict(job.m, job, path, process) |
|
|
|
|
|
jobargs = {} |
|
|
|
|
|
jobargs[B.PAR_APP] = process["app"] |
|
|
|
|
|
jobargs[B.PAR_ENV] = process["env"] |
|
|
|
|
|
if B.PAR_STEP in process: |
|
|
|
|
|
jobargs[B.PAR_STEP] = process[B.PAR_STEP] |
|
|
|
|
|
if B.PAR_TCDIR in process: |
|
|
|
|
|
jobargs[B.PAR_TCDIR] = process[B.PAR_TCDIR] |
|
|
|
|
|
jobargs[B.PAR_TESTCASE] = process["entity"] |
|
|
|
|
|
elif B.PAR_TSDIR in process: |
|
|
|
|
|
jobargs[B.PAR_TSDIR] = process[B.PAR_TSDIR] |
|
|
|
|
|
jobargs[B.PAR_TESTSUITE] = process["entity"] |
|
|
|
|
|
print("process-programm "+process["program"]) |
|
|
|
|
|
myjob = basic.program.Job(process["program"], jobargs) |
|
|
|
|
|
myjob.startJob() |
|
|
|
|
|
if process["program"] == "init_testcase": |
|
|
|
|
|
init_testcase.startPyJob(myjob) |
|
|
|
|
|
elif process["program"] == "execute_testcase": |
|
|
|
|
|
execute_testcase.startPyJob(myjob) |
|
|
|
|
|
elif process["program"] == "collect_testcase": |
|
|
|
|
|
collect_testcase.startPyJob(myjob) |
|
|
|
|
|
elif process["program"] == "compare_testcase": |
|
|
|
|
|
compare_testcase.startPyJob(myjob) |
|
|
|
|
|
elif process["program"] == "copy_appdummy": |
|
|
|
|
|
copy_appdummy.startPyJob(myjob) |
|
|
|
|
|
elif process["program"] == "init_testsuite": |
|
|
|
|
|
init_testsuite.startPyJob(myjob) |
|
|
|
|
|
elif process["program"] == "execute_testsuite": |
|
|
|
|
|
print("execute_testsuite.startPyJob(myjob) not implemented") |
|
|
|
|
|
elif process["program"] == "collect_testsuite": |
|
|
|
|
|
print("collect_testsuite.startPyJob(myjob) not implemented") |
|
|
|
|
|
elif process["program"] == "finish_testsuite": |
|
|
|
|
|
finish_testsuite.startPyJob(myjob) |
|
|
|
|
|
elif process["program"] == "test_executer": |
|
|
|
|
|
test_executer.startPyJob(myjob) |
|
|
|
|
|
restartActualProcess(job) |
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
if __name__ == '__main__': |
|
|
job = basic.program.Job(PROGRAM_NAME) |
|
|
job = basic.program.Job(PROGRAM_NAME, {}) |
|
|
readContext(job) |
|
|
readContext(job) |
|
|
restartActualProcess(job) |
|
|
restartActualProcess(job) |
|
|