From a079a47875b5a505941af2f56c120e9fd4696ca4 Mon Sep 17 00:00:00 2001 From: Ulrich Date: Wed, 17 May 2023 09:34:08 +0200 Subject: [PATCH] model designed for install_workspace --- basic/Testserver.py | 25 ++++-- basic/constants.py | 9 +- basic/program.py | 6 +- ...DATASTRUCTURE.yml => xxDATASTRUCTURE.yxml} | 0 catalog/programs.csv | 1 + install_workspace.py | 88 +++++++++++++++---- model/ap_application.csv | 4 + model/ap_component.csv | 5 ++ model/ap_project.csv | 6 ++ model/application.csv | 13 +++ model/artifact.csv | 14 +++ model/co_artifact.csv | 7 ++ model/co_step.csv | 7 ++ model/co_table.csv | 7 ++ model/component.csv | 15 ++++ model/en_component.csv | 13 +++ model/en_project.csv | 4 + model/environment.csv | 13 +++ model/job.csv | 12 +++ model/release.csv | 15 ++++ model/step.csv | 13 +++ model/story.csv | 15 ++++ model/table.csv | 13 +++ model/tc_step.csv | 5 ++ model/tc_story.csv | 7 ++ model/tc_table.csv | 5 ++ model/testcase.csv | 15 ++++ model/testplan.csv | 16 ++++ model/testreport.csv | 22 +++++ model/testsuite.csv | 15 ++++ model/tp_testsuite.csv | 5 ++ model/tr_artifact.csv | 6 ++ model/ts_testcase.csv | 5 ++ model/ts_usecase.csv | 5 ++ model/usecase.csv | 15 ++++ tools/config_tool.py | 16 +++- tools/conn_tool.py | 2 +- tools/data_const.py | 13 ++- tools/dbmysql_tool.py | 8 +- tools/dbrel_tool.py | 2 +- tools/file_tool.py | 2 +- tools/git_tool.py | 54 +++++++++--- 42 files changed, 469 insertions(+), 54 deletions(-) rename basic/{DATASTRUCTURE.yml => xxDATASTRUCTURE.yxml} (100%) create mode 100644 model/ap_application.csv create mode 100644 model/ap_component.csv create mode 100644 model/ap_project.csv create mode 100644 model/application.csv create mode 100644 model/artifact.csv create mode 100644 model/co_artifact.csv create mode 100644 model/co_step.csv create mode 100644 model/co_table.csv create mode 100644 model/component.csv create mode 100644 model/en_component.csv create mode 100644 model/en_project.csv create mode 100644 model/environment.csv create mode 100644 model/job.csv create mode 100644 model/release.csv create mode 100644 model/step.csv create mode 100644 model/story.csv create mode 100644 model/table.csv create mode 100644 model/tc_step.csv create mode 100644 model/tc_story.csv create mode 100644 model/tc_table.csv create mode 100644 model/testcase.csv create mode 100644 model/testplan.csv create mode 100644 model/testreport.csv create mode 100644 model/testsuite.csv create mode 100644 model/tp_testsuite.csv create mode 100644 model/tr_artifact.csv create mode 100644 model/ts_testcase.csv create mode 100644 model/ts_usecase.csv create mode 100644 model/usecase.csv diff --git a/basic/Testserver.py b/basic/Testserver.py index 1966bbf..9d1c552 100644 --- a/basic/Testserver.py +++ b/basic/Testserver.py @@ -1,9 +1,13 @@ +import os.path +import re + import basic.component import basic.constants as B import basic.toolHandling import tools.config_tool import tools.data_const as D import tools.file_tool +import tools.filecsv_fcts import model.table COMP_NAME = "testserver" @@ -27,6 +31,8 @@ class Testserver(basic.component.Component): for table in COMP_TABLES: if table in B.LIST_DB_ATTR: continue + else: + continue ddl = tools.config_tool.getConfig(job, D.DDL_FILENAME, COMP_NAME, table) tableDdl = model.table.Table(job, component=COMP_NAME, name=table) self.tables[table] = tableDdl @@ -50,14 +56,24 @@ class Testserver(basic.component.Component): self.conf[B.DATA_NODE_DDL][table] = ddl def createDBTables(self, job): + tables = {} if B.TOPIC_NODE_DB in job.conf: dbi = basic.toolHandling.getDbTool(job, self, job.conf[B.TOPIC_NODE_DB][B.ATTR_TYPE]) else: return "No DB in job-config" - for t in self.tables: - sql = self.tables[t].get_schema(tableName=t, tableObject=self.tables[t]) - #for t in COMP_TABLES: - #sql = self.getDBSchema(job, dbi, t) + path = os.path.join(job.conf[B.SUBJECT_PATH][B.ATTR_PATH_PROGRAM], "model") + fct = basic.toolHandling.getFileTool(job, None, "csv") + for m in sorted(os.listdir(path)): + if not re.match(r".*?\.csv", m): + print("sonstig "+m) + continue + print("model "+m) + modelPath = os.path.join(path, m) + modelDoc = fct.load_file(modelPath, D.CSV_SPECTYPE_DATA) + table = model.table.Table(job, project="", application="", component="Testserver", name=m[:-4]) + sql = table.get_schema(tableName=m[:-4], tableObject=table) # [B.DATA_NODE_TABLES][m[:-4]] + job.m.logInfo(sql) + tables[m[:-4]] = modelDoc for s in sql.split(";\n"): if len(s) < 3: continue @@ -66,4 +82,3 @@ class Testserver(basic.component.Component): print("SQL executed: "+s) except Exception as e: raise Exception("Fehler bei createSchema "+s) - pass diff --git a/basic/constants.py b/basic/constants.py index c4a3a27..850de85 100644 --- a/basic/constants.py +++ b/basic/constants.py @@ -119,7 +119,8 @@ DATA_NODE_COMP = "comp" DATA_NODE_PAR = "par" DATA_NODE_CATALOG = "_catalog" DATA_NODE_ROW = "_row" - +LIST_DATA_NODE = [DATA_NODE_HEADER, DATA_NODE_DATA, DATA_NODE_DDL, + DATA_NODE_TABLES, DATA_NODE_STEPS, DATA_NODE_OPTION, DATA_NODE_ROW] ATTR_ARTS_TYPE = "type" """ must attribute for the type of the technique """ @@ -227,9 +228,6 @@ SUBJECT_COMPS = "components" ATTR_INST_SUBCOMP = SUBJECT_COMPS #SUBJECT_FCT = "function" # | | | | x | main-programs -SUBJECT_ARTS = "artifact" # | | | | x | Component - - """ in this subject-node are each kind of result of any component with the structure: * topic (db, cli, api, ...) @@ -237,6 +235,9 @@ in this subject-node are each kind of result of any component with the structure * * partial-component - to-know: the existence of db-tables can be defined in the ddl-tree * * * specific attributes - it overrides the general attributes """ +SUBJECT_ARTS = "artifact" # | | | | x | Component + +SUBJECT_VARIANTS = "variants" #ATTR_ARTS_DB = "db" ATTR_ARTS_LOG = "log" ATTR_ARTS_LOB = "lob" diff --git a/basic/program.py b/basic/program.py index 7ebd3d8..3438d2a 100644 --- a/basic/program.py +++ b/basic/program.py @@ -154,8 +154,10 @@ class Job: exit(3) if args is not None: self.setParameter(args) - self.m = basic.message.Message(self, self.programDef[CTLG_LOGLEVEL], logTime, None) - + if isinstance(self.programDef, dict): + self.m = basic.message.Message(self, self.programDef[CTLG_LOGLEVEL], logTime, None) + else: + self.m = basic.message.Message(self, basic.message.LIMIT_DEBUG, logTime, None) def getLogpath(self): path = tools.path_tool.compose_path(self, self.programDef[CTLG_LOGPATH], None) return path diff --git a/basic/DATASTRUCTURE.yml b/basic/xxDATASTRUCTURE.yxml similarity index 100% rename from basic/DATASTRUCTURE.yml rename to basic/xxDATASTRUCTURE.yxml diff --git a/catalog/programs.csv b/catalog/programs.csv index 0650fa2..56fbdce 100644 --- a/catalog/programs.csv +++ b/catalog/programs.csv @@ -1,3 +1,4 @@ +_type;ctlg;;;;;;;;;;;;; _key;name;;;;;;;;;;;;; table:programs;name;objtype;objname;time;env;app;variant;pardef;pfilesource;pfiletarget;dirname;basedir;loglevel;logpath ;test_executer;tp,ts,tc;m;m;m;m;o;"{""gran"":""args"",""application"":""args"",""environment"":""args"",""testelem"":""args"",""variant"":""args""}";;;{objtype}dir;{objtype}base;info;{job.par.wsdir}/{log}/log_{job.start}.txt diff --git a/install_workspace.py b/install_workspace.py index d4df462..4752662 100644 --- a/install_workspace.py +++ b/install_workspace.py @@ -7,7 +7,9 @@ import json import os import datetime +import re import subprocess +import traceback import yaml @@ -22,6 +24,11 @@ PROGRAM_NAME = "install_workspace" CONFIG_FORMAT = "yml" BASIS_FORMAT = "json" +REPO_NAME = "_name" +REPO_URL = "url" +REPO_BRANCH = "_branch" + + job = None # ----------------------------------------------------------------------------------------- # Miniimplementierung des Programmeahmens @@ -48,6 +55,8 @@ class Logger: def logInfo(self, text): self.logfile.write(text + "\n") + def setMsg(self, text): + self.logfile.write(text + "\n") def logError(self, text): self.logfile.write("ERROR:" + text + "\n") print("ERROR:" + text) @@ -66,6 +75,8 @@ class ActJob: self.program = program self.start = datetime.datetime.now().strftime("%Y%m%d_%H%M%S") self.jobid = 100000 + self.conf = {} + self.par = {} def startJob(self): self.m = Logger(self, "info", self.start, None) # job, level, logTime, componente @@ -80,10 +91,17 @@ class ActJob: self.m.closeLog() print(text) + def getDebugLevel(self, tool): + return 0 + + def debug(self, verify, text): + self.m.logInfo(text) + def setParameter(self, args): for k in args: setattr(self, k, args[k]) + # ----------------------------------------------------------------------------------------- # Standardsteuerung Hauptverarbeitung def startPyJob(job): @@ -99,8 +117,13 @@ def startPyJob(job): createFolders(job) createGit(job) createBasisConfig(job) + createDb(job) except Exception as e: + job.m.logError("+++++++++++++++++++++++++++++++++++++++++++++") job.m.logError(str(e)) + job.m.logError("+++++++++++++++++++++++++++++++++++++++++++++") + job.m.logError("execpt "+traceback.format_exc()) + job.m.logError("+++++++++++++++++++++++++++++++++++++++++++++") # ----------------------------------------------------------------------------------------- # konkrete Verarbeitungsroutinen @@ -125,6 +148,10 @@ def readConfig(job): file.close() for k in doc: args[k] = doc[k] + job.conf[k] = doc[k] + home = getHome() + for k in job.conf["paths"]: + job.conf["paths"][k] = os.path.join(home, job.conf["paths"][k]) job.setParameter(args) def createFolders(job): @@ -142,13 +169,17 @@ def createFolder(job, path): else: job.m.logInfo("Verzeichnis existiert: " + path) +# -------------------------------------------------------------------------------------- +# git_tool +# -------------------------------------------------------------------------------------- + def createGit(job): job.m.logInfo("--- erstelle und aktualisiere git-Repos ") repos = {} local = {} attr = { - "_name": "", - "_branch": "" + REPO_NAME: "", + REPO_BRANCH: "" } # erstelle Repoliste mit den Attributen: name, branch, url for r in job.repos: @@ -160,7 +191,7 @@ def createGit(job): repo[a] = job.repos[r][a] repos[r] = repo for k in attr: - a = k[1:] + a = k for r in repos: if a not in repos[r]: repos[r][a] = attr[k] @@ -168,9 +199,10 @@ def createGit(job): repo = repos[r] path = os.path.join(job.home, job.paths[r]) if os.path.exists(path): - local["url"] = os.path.join(job.home, job.paths[r]) - local["branch"] = repo["branch"] - rpath = os.path.join(local["url"], ".git") + local[REPO_URL] = os.path.join(job.home, job.paths[r]) + local[REPO_BRANCH] = repo[REPO_BRANCH] + local[REPO_NAME] = repo[REPO_NAME] + rpath = os.path.join(local[REPO_URL], ".git") if os.path.exists(rpath): job.m.logInfo("Repo existiert bereits "+r) else: @@ -182,42 +214,52 @@ def createGit(job): def initGit(job, local, repo, bare=False): job.m.logInfo("--- initialisiere git-Repo "+str(repo)+","+str(local)) - os.chdir(local["url"]) + os.chdir(local[REPO_URL]) cmd = "git init " if bare: cmd += " --bare" execCmd(job, cmd) - cmd = "git checkout " + local["branch"] + cmd = "git checkout " + local[REPO_BRANCH] execCmd(job, cmd) - cmd = "git remote add " + repo["name"] + " " + repo["url"] + cmd = "git remote add " + repo[REPO_NAME] + " " + repo[REPO_URL] execCmd(job, cmd) os.chdir(job.home) def execCmd(job, cmd): job.m.logInfo(cmd) + text = "" process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) btext = process.communicate()[0] text = btext.decode('utf-8') job.m.logInfo(text) return text -def switchLocal(job, local): - os.chdir(local["url"]) - cmd = "git checkout " + local["branch"] - execCmd(job, cmd) +def checkoutLocal(job, local): + os.chdir(local[REPO_URL]) + cmd = "git checkout " + local[REPO_BRANCH] + text = execCmd(job, cmd) + return text def updateLocal(job, local, repo): job.m.logInfo("--- aktualisiere git-Repo "+str(repo)+","+str(local)) - switchLocal(job, local) - cmd = "git pull " + repo["name"] + " " + repo["branch"] - execCmd(job, cmd) + text = checkoutLocal(job, local) +# if len(text) > 0 and re.match(r"[MA]\s\w+", text): + match = re.search(r"([DMA])\s(\S+)", text) + if match is not None: + os.chdir(job.home) + job.m.logError("ERROR: lokales Repo " + local[REPO_URL] + ", " + local[REPO_BRANCH] + " hat uncommited Aenderungen") + print("regex gefunden") + return + cmd = "git pull " + repo[REPO_NAME] + " " + repo[REPO_BRANCH] + text = execCmd(job, cmd) + job.m.logInfo(text) os.chdir(job.home) def updateRemote(job, local, repo): job.m.logInfo("--- aktualisiere git-Repo "+str(repo)+","+str(local)) - switchLocal(job, local) - cmd = "git push " + repo["name"] + " " + repo["branch"] - execCmd(job, cmd) + text = checkoutLocal(job, local) + cmd = "git push " + repo[REPO_NAME] + " " + repo[REPO_BRANCH] + text = execCmd(job, cmd) os.chdir(job.home) def createBasisConfig(job): @@ -246,6 +288,13 @@ def createBasisConfig(job): file.write(doc) file.close() +def createDb(job): + if "db" in job.conf: + import basic.connection + import basic.Testserver + + testserver = basic.Testserver.Testserver(job) + testserver.createDBTables(job) def getHome(): home = os.getcwd() @@ -253,6 +302,7 @@ def getHome(): home = home[0:-8] return home + # ----------------------------------------------------------------------------------------- # Pythonstandard Programmaufruf # Job-Objekt erzeugen und beenden diff --git a/model/ap_application.csv b/model/ap_application.csv new file mode 100644 index 0000000..393b2b1 --- /dev/null +++ b/model/ap_application.csv @@ -0,0 +1,4 @@ +table:ap_application;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;apappid;pk;vchar(256);N;;;;;; +;apid;int;vchar(256);I;;;;;; +;component;str;vchar(256);I;;;;;; diff --git a/model/ap_component.csv b/model/ap_component.csv new file mode 100644 index 0000000..eb79c33 --- /dev/null +++ b/model/ap_component.csv @@ -0,0 +1,5 @@ +table:ap_component;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;apcomid;pk;int;N;;;;;; +;apid;int;int;I;;;;;; +;coid;int;int;I;;;;;; +;component;str;vchar(256);N;;;;;; diff --git a/model/ap_project.csv b/model/ap_project.csv new file mode 100644 index 0000000..68bb588 --- /dev/null +++ b/model/ap_project.csv @@ -0,0 +1,6 @@ +table:ap_project;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;pjid;pk;int;N;;;;;; +;apid;int;int;I;;;;;; +;project;str;vchar(256);I;;;;;; +;description;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; diff --git a/model/application.csv b/model/application.csv new file mode 100644 index 0000000..1c4002e --- /dev/null +++ b/model/application.csv @@ -0,0 +1,13 @@ +table:application;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;apid;pk;int;N;;;;;; +;name;str;vchar(256);I;;;;;; +;description;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; +;attributes;string;jlob;N;;;;;; +;insauthor;str;vchar(256);N;;;;;; +;inscommit;str;vchar(256);N;;;;;; +;instime;time;vchar(256);N;;;;;; +;updauthor;str;vchar(256);N;;;;;; +;updcommit;str;vchar(256);N;;;;;; +;updtime;time;vchar(256);N;;;;;; +;actual;int;vchar(256);I;;;;;; diff --git a/model/artifact.csv b/model/artifact.csv new file mode 100644 index 0000000..56263fe --- /dev/null +++ b/model/artifact.csv @@ -0,0 +1,14 @@ +table:artifact;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;afid;pk;int;N;;;;;; +;name;str;vchar(256);I;;;;;; +;aftype;str;vchar(256);I;;;;;; +;description;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; +;attributes;string;jlob;N;;;;;; +;insauthor;str;vchar(256);N;;;;;; +;inscommit;str;vchar(256);N;;;;;; +;instime;time;vchar(256);N;;;;;; +;updauthor;str;vchar(256);N;;;;;; +;updcommit;str;vchar(256);N;;;;;; +;updtime;time;vchar(256);N;;;;;; +;actual;int;vchar(256);I;;;;;; diff --git a/model/co_artifact.csv b/model/co_artifact.csv new file mode 100644 index 0000000..ffde721 --- /dev/null +++ b/model/co_artifact.csv @@ -0,0 +1,7 @@ +table:tc_story;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;tcid;int;integer;I;;;T:1;;; +;stid;int;integer;I;;;T:2;;; +;story;str;vchar(256);I;;;;;; +;description;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; +;acceptcriteria;str;clob;N;;;;;; diff --git a/model/co_step.csv b/model/co_step.csv new file mode 100644 index 0000000..ffde721 --- /dev/null +++ b/model/co_step.csv @@ -0,0 +1,7 @@ +table:tc_story;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;tcid;int;integer;I;;;T:1;;; +;stid;int;integer;I;;;T:2;;; +;story;str;vchar(256);I;;;;;; +;description;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; +;acceptcriteria;str;clob;N;;;;;; diff --git a/model/co_table.csv b/model/co_table.csv new file mode 100644 index 0000000..ffde721 --- /dev/null +++ b/model/co_table.csv @@ -0,0 +1,7 @@ +table:tc_story;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;tcid;int;integer;I;;;T:1;;; +;stid;int;integer;I;;;T:2;;; +;story;str;vchar(256);I;;;;;; +;description;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; +;acceptcriteria;str;clob;N;;;;;; diff --git a/model/component.csv b/model/component.csv new file mode 100644 index 0000000..cb28dfe --- /dev/null +++ b/model/component.csv @@ -0,0 +1,15 @@ +table:component;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;coid;pk;int;N;;;;;; +;name;str;vchar(256);I;;;;;; +;description;string;vchar(256);N;;;;;; +;project;string;vchar(256);I;;;;;; +;application;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; +;attributes;string;jlob;N;;;;;; +;insauthor;str;vchar(256);N;;;;;; +;inscommit;str;vchar(256);N;;;;;; +;instime;time;vchar(256);N;;;;;; +;updauthor;str;vchar(256);N;;;;;; +;updcommit;str;vchar(256);N;;;;;; +;updtime;time;vchar(256);N;;;;;; +;actual;int;vchar(256);I;;;;;; diff --git a/model/en_component.csv b/model/en_component.csv new file mode 100644 index 0000000..7b9e52d --- /dev/null +++ b/model/en_component.csv @@ -0,0 +1,13 @@ +table:en_component;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;encomid;pk;vchar(256);N;;;;;; +;enid;int;vchar(256);I;;;;;; +;component;str;vchar(256);I;;;;;; +;instance;int;vchar(256);N;;;;;; +;type;str;vchar(256);N;;;;;; +;ip;str;vchar(256);N;;;;;; +;port;str;vchar(256);N;;;;;; +;hostname;str;vchar(256);N;;;;;; +;dompath;str;vchar(256);N;;;;;; +;user;str;vchar(256);N;;;;;; +;password;str;vchar(256);N;;;;;; +;attributes;string;vchar(256);N;;;;;; diff --git a/model/en_project.csv b/model/en_project.csv new file mode 100644 index 0000000..12a60d3 --- /dev/null +++ b/model/en_project.csv @@ -0,0 +1,4 @@ +table:en_project;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;enproid;pk;vchar(256);N;;;;;; +;enid;int;vchar(256);I;;;;;; +;project;str;vchar(256);I;;;;;; diff --git a/model/environment.csv b/model/environment.csv new file mode 100644 index 0000000..a149a90 --- /dev/null +++ b/model/environment.csv @@ -0,0 +1,13 @@ +table:environment;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;enid;pk;int;N;;;;;; +;name;str;vchar(256);I;;;;;; +;description;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; +;attributes;string;jlob;N;;;;;; +;insauthor;str;vchar(256);N;;;;;; +;inscommit;str;vchar(256);N;;;;;; +;instime;time;vchar(256);N;;;;;; +;updauthor;str;vchar(256);N;;;;;; +;updcommit;str;vchar(256);N;;;;;; +;updtime;time;vchar(256);N;;;;;; +;actual;int;vchar(256);I;;;;;; diff --git a/model/job.csv b/model/job.csv new file mode 100644 index 0000000..877b165 --- /dev/null +++ b/model/job.csv @@ -0,0 +1,12 @@ +table:job;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;jbid;pk;integer;N;;;T:1;;; +;name;str;vchar(256);I;;;F:1;;; +;description;string;vchar(256);N;;;;;; +;project;string;vchar(256);I;;;;;; +;application;string;vchar(256);N;;;;;; +;release;str;vchar(256);I;;;;;; +;environment;str;vchar(256);N;;;;;; +;status;str;vchar(256);I;;;;;; +;attributes;jlob;clob;N;;;;;; +;starttime;time;datetime;N;;;;;; +;endtime;time;datetime;N;;;;;; diff --git a/model/release.csv b/model/release.csv new file mode 100644 index 0000000..afb34f9 --- /dev/null +++ b/model/release.csv @@ -0,0 +1,15 @@ +table:release;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;rlid;pk;int;N;;;;;; +;name;str;vchar(256);I;;;;;; +;description;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; +;project;string;vchar(256);I;;;;;; +;application;string;vchar(256);N;;;;;; +;attributes;string;jlob;N;;;;;; +;insauthor;str;vchar(256);N;;;;;; +;inscommit;str;vchar(256);N;;;;;; +;instime;time;vchar(256);N;;;;;; +;updauthor;str;vchar(256);N;;;;;; +;updcommit;str;vchar(256);N;;;;;; +;updtime;time;vchar(256);N;;;;;; +;actual;int;vchar(256);I;;;;;; diff --git a/model/step.csv b/model/step.csv new file mode 100644 index 0000000..a64aac3 --- /dev/null +++ b/model/step.csv @@ -0,0 +1,13 @@ +table:step;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;spid;pk;int;N;;;;;; +;name;str;vchar(256);I;;;;;; +;description;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; +;attributes;string;jlob;N;;;;;; +;insauthor;str;vchar(256);N;;;;;; +;inscommit;str;vchar(256);N;;;;;; +;instime;time;vchar(256);N;;;;;; +;updauthor;str;vchar(256);N;;;;;; +;updcommit;str;vchar(256);N;;;;;; +;updtime;time;vchar(256);N;;;;;; +;actual;int;vchar(256);I;;;;;; diff --git a/model/story.csv b/model/story.csv new file mode 100644 index 0000000..cecc0e0 --- /dev/null +++ b/model/story.csv @@ -0,0 +1,15 @@ +table:story;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;stid;pk;int;N;;;;;; +;name;str;vchar(256);I;;;;;; +;description;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; +;project;string;vchar(256);I;;;;;; +;application;string;vchar(256);N;;;;;; +;attributes;string;jlob;N;;;;;; +;insauthor;str;vchar(256);N;;;;;; +;inscommit;str;vchar(256);N;;;;;; +;instime;time;vchar(256);N;;;;;; +;updauthor;str;vchar(256);N;;;;;; +;updcommit;str;vchar(256);N;;;;;; +;updtime;time;vchar(256);N;;;;;; +;actual;int;vchar(256);I;;;;;; diff --git a/model/table.csv b/model/table.csv new file mode 100644 index 0000000..f15672b --- /dev/null +++ b/model/table.csv @@ -0,0 +1,13 @@ +table:table;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;tbid;pk;integer;N;;;T:1;;; +;name;str;vchar(256);I;;;F:1;;; +;description;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;;story +;attributes;jlob;clob;N;;;;;; +;insauthor;str;vchar(256);N;;;;;; +;inscommit;str;vchar(256);N;;;;;; +;instime;time;datetime;N;;;;;; +;updauthor;str;vchar(256);N;;;;;; +;updcommit;str;vchar(256);N;;;;;; +;updtime;time;datetime;N;;;;;; +;actual;int;integer;I;;;;;; diff --git a/model/tc_step.csv b/model/tc_step.csv new file mode 100644 index 0000000..62aa270 --- /dev/null +++ b/model/tc_step.csv @@ -0,0 +1,5 @@ +table:tc_step;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;tcid;int;integer;I;;;T:1;;; +;spid;int;integer;I;;;T:2;;; +;description;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; diff --git a/model/tc_story.csv b/model/tc_story.csv new file mode 100644 index 0000000..ffde721 --- /dev/null +++ b/model/tc_story.csv @@ -0,0 +1,7 @@ +table:tc_story;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;tcid;int;integer;I;;;T:1;;; +;stid;int;integer;I;;;T:2;;; +;story;str;vchar(256);I;;;;;; +;description;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; +;acceptcriteria;str;clob;N;;;;;; diff --git a/model/tc_table.csv b/model/tc_table.csv new file mode 100644 index 0000000..6d332f2 --- /dev/null +++ b/model/tc_table.csv @@ -0,0 +1,5 @@ +table:tc_table;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;tcid;int;integer;I;;;T:1;;; +;tbid;int;integer;I;;;T:2;;; +;count;int;int;N;;;;;; +;refdate;date;date;N;;;;;; diff --git a/model/testcase.csv b/model/testcase.csv new file mode 100644 index 0000000..604c383 --- /dev/null +++ b/model/testcase.csv @@ -0,0 +1,15 @@ +table:testcase;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;tcid;pk;integer;N;;;T:1;;; +;name;str;vchar(256);I;;;F:1;;; +;description;string;vchar(256);N;;;;;; +;project;string;vchar(256);I;;;;;; +;application;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;;story +;attributes;jlob;clob;N;;;;;; +;insauthor;str;vchar(256);N;;;;;; +;inscommit;str;vchar(256);N;;;;;; +;instime;time;datetime;N;;;;;; +;updauthor;str;vchar(256);N;;;;;; +;updcommit;str;vchar(256);N;;;;;; +;updtime;time;datetime;N;;;;;; +;actual;int;integer;I;;;;;; diff --git a/model/testplan.csv b/model/testplan.csv new file mode 100644 index 0000000..3ef9315 --- /dev/null +++ b/model/testplan.csv @@ -0,0 +1,16 @@ +table:testplan;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;tpid;pk;integer;N;;;T:1;;; +;name;str;vchar(256);I;;;F:1;;; +;description;string;vchar(256);N;;;;;; +;project;string;vchar(256);I;;;;;; +;application;string;vchar(256);N;;;;;; +;release;string;vchar(256);I;;;;;; +;reference;str;vchar(256);N;;;;;;story +;attributes;jlob;clob;N;;;;;; +;insauthor;str;vchar(256);N;;;;;; +;inscommit;str;vchar(256);N;;;;;; +;instime;time;datetime;N;;;;;; +;updauthor;str;vchar(256);N;;;;;; +;updcommit;str;vchar(256);N;;;;;; +;updtime;time;datetime;N;;;;;; +;actual;int;integer;I;;;;;; diff --git a/model/testreport.csv b/model/testreport.csv new file mode 100644 index 0000000..c633b7a --- /dev/null +++ b/model/testreport.csv @@ -0,0 +1,22 @@ +table:testreport;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;tcid;pk;integer;N;;;T:1;;; +;name;str;vchar(256);I;;;F:1;;; +;description;string;vchar(256);N;;;;;; +;project;string;vchar(256);I;;;;;; +;application;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; +;release;str;vchar(256);I;;;;;; +;environment;str;vchar(256);N;;;;;; +;testplan;str;vchar(256);N;;;;;; +;testsuite;str;vchar(256);N;;;;;; +;testcase;str;vchar(256);N;;;;;; +;artifact;str;vchar(256);N;;;;;; +;result;str;vchar(256);I;;;;;; +;attributes;jlob;clob;N;;;;;; +;insauthor;str;vchar(256);N;;;;;; +;inscommit;str;vchar(256);N;;;;;; +;instime;time;datetime;N;;;;;; +;updauthor;str;vchar(256);N;;;;;; +;updcommit;str;vchar(256);N;;;;;; +;updtime;time;datetime;N;;;;;; +;actual;int;integer;I;;;;;; diff --git a/model/testsuite.csv b/model/testsuite.csv new file mode 100644 index 0000000..037cfff --- /dev/null +++ b/model/testsuite.csv @@ -0,0 +1,15 @@ +table:testsuite;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;tsid;pk;integer;N;;;T:1;;; +;name;str;vchar(256);I;;;F:1;;; +;description;string;vchar(256);N;;;;;; +;project;string;vchar(256);I;;;;;; +;application;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;;story +;attributes;jlob;clob;N;;;;;; +;insauthor;str;vchar(256);N;;;;;; +;inscommit;str;vchar(256);N;;;;;; +;instime;time;datetime;N;;;;;; +;updauthor;str;vchar(256);N;;;;;; +;updcommit;str;vchar(256);N;;;;;; +;updtime;time;datetime;N;;;;;; +;actual;int;integer;I;;;;;; diff --git a/model/tp_testsuite.csv b/model/tp_testsuite.csv new file mode 100644 index 0000000..17409bb --- /dev/null +++ b/model/tp_testsuite.csv @@ -0,0 +1,5 @@ +table:tp_testsuite;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;tpid;int;integer;I;;;T:1;;; +;tsid;int;integer;I;;;T:2;;; +;description;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; diff --git a/model/tr_artifact.csv b/model/tr_artifact.csv new file mode 100644 index 0000000..beb65a1 --- /dev/null +++ b/model/tr_artifact.csv @@ -0,0 +1,6 @@ +table:tr_artifact;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;trid;int;integer;I;;;T:1;;; +;afid;int;integer;I;;;T:2;;; +;result;str;vchar(256);I;;;;;; +;description;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; diff --git a/model/ts_testcase.csv b/model/ts_testcase.csv new file mode 100644 index 0000000..0a4ad96 --- /dev/null +++ b/model/ts_testcase.csv @@ -0,0 +1,5 @@ +table:ts_testcase;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;tsid;int;integer;I;;;T:1;;; +;tcid;int;integer;I;;;T:2;;; +;description;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; diff --git a/model/ts_usecase.csv b/model/ts_usecase.csv new file mode 100644 index 0000000..0353b12 --- /dev/null +++ b/model/ts_usecase.csv @@ -0,0 +1,5 @@ +table:ts_usecase;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;tsid;int;integer;I;;;T:1;;; +;ucid;int;integer;I;;;T:2;;; +;description;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; diff --git a/model/usecase.csv b/model/usecase.csv new file mode 100644 index 0000000..856ac89 --- /dev/null +++ b/model/usecase.csv @@ -0,0 +1,15 @@ +table:usecase;_field;type;format;index;generic;aggregat;key;acceptance;alias;description +;ucid;pk;int;N;;;;;; +;name;str;vchar(256);I;;;;;; +;description;string;vchar(256);N;;;;;; +;project;string;vchar(256);I;;;;;; +;application;string;vchar(256);N;;;;;; +;reference;str;vchar(256);N;;;;;; +;attributes;string;jlob;N;;;;;; +;insauthor;str;vchar(256);N;;;;;; +;inscommit;str;vchar(256);N;;;;;; +;instime;time;vchar(256);N;;;;;; +;updauthor;str;vchar(256);N;;;;;; +;updcommit;str;vchar(256);N;;;;;; +;updtime;time;vchar(256);N;;;;;; +;actual;int;vchar(256);I;;;;;; diff --git a/tools/config_tool.py b/tools/config_tool.py index 7163f8c..aa11059 100644 --- a/tools/config_tool.py +++ b/tools/config_tool.py @@ -153,9 +153,19 @@ def getCompPath(job, name, subname, filename): configpath = getExistingPath(job, pathnames) if configpath is not None: return configpath + if name == "Testserver": + print(name) + for format in CONFIG_FORMAT: + pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_PROGRAM], + "model", subname + "." + format) + print(pathname) + if os.path.exists(pathname): + return pathname + for format in CONFIG_FORMAT: pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_COMPONENTS], basic.componentHandling.getComponentFolder(name), filename + "." + format) + print(pathname) if os.path.exists(pathname): return pathname for format in CONFIG_FORMAT: @@ -179,7 +189,7 @@ def getBasicPath(job, name): def getTestPath(job, name, filename): for format in CONFIG_FORMAT: - pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_TDATA], + pathname = os.path.join(job.conf[B.SUBJECT_PATH][P.ATTR_PATH_TDATA], job.par.project, name, filename + "." + format) if os.path.exists(pathname): return pathname @@ -255,8 +265,8 @@ def getConfig(job, modul, name, subname=""): job.debug(verify, "getConfig " + pathname) if len(pathname) < 1: return confs - doc = tools.file_tool.read_file_dict(job, pathname, msg) if modul == D.DDL_FILENAME: + doc = tools.file_tool.read_file_dict(job, pathname, msg, D.CSV_SPECTYPE_DATA) # in csv the root is the subname # from the Dict-structure of DDL_FILENAME pick the substructure of the subname keys = list(doc.keys()) @@ -267,6 +277,8 @@ def getConfig(job, modul, name, subname=""): if subname in keys: doc0 = doc[subname] doc = doc0 + else: + doc = tools.file_tool.read_file_dict(job, pathname, msg) for i, v in doc.items(): confs[i] = v return confs diff --git a/tools/conn_tool.py b/tools/conn_tool.py index 4ea571d..acd4c2f 100644 --- a/tools/conn_tool.py +++ b/tools/conn_tool.py @@ -13,7 +13,7 @@ def getConnection(job, comp, nr): #job = basic.program.Job.getInstance() verify = job.getDebugLevel("conn_tool") conn = {} - if job.conf.confs.get(B.SUBJECT_TOOL).get("connsrc") == D.DFILE_TYPE_YML: + if job.conf.get(B.SUBJECT_TOOL).get("connsrc") == D.DFILE_TYPE_YML: conn = tools.config_tool.getConfig(job, "tool", B.SUBJECT_CONN) xtypes = None if ("types" in conn["env"][comp]): diff --git a/tools/data_const.py b/tools/data_const.py index 8da81cf..7e64bc1 100644 --- a/tools/data_const.py +++ b/tools/data_const.py @@ -81,14 +81,23 @@ HEAD_ATTR_TARGET = "target" HEAD_ATTR_USECASE = "usecase" HEAD_ATTR_UCID = "usecase-id" HEAD_ATTR_STORY = "story" -HEAD_ATTR_STORYID = "storyid-id" +HEAD_ATTR_STORYID = "story-id" +HEAD_ATTR_APP = B.SUBJECT_APP HEAD_ATTR_APPS = B.SUBJECT_APPS HEAD_ATTR_DEPR = "deprecated" LIST_HEAD_ATTR = [HEAD_ATTR_DESCR, HEAD_ATTR_TARGET, HEAD_ATTR_USECASE, HEAD_ATTR_UCID, - HEAD_ATTR_STORY, HEAD_ATTR_STORYID, HEAD_ATTR_APPS, HEAD_ATTR_DEPR] + HEAD_ATTR_STORY, HEAD_ATTR_STORYID, HEAD_ATTR_APP, HEAD_ATTR_APPS, HEAD_ATTR_DEPR] LIST_HEAD_CONST = ["HEAD_ATTR_DESCR", "HEAD_ATTR_TARGET", "HEAD_ATTR_USECASE", "HEAD_ATTR_UCID", "HEAD_ATTR_STORY", "HEAD_ATTR_STORYID", "HEAD_ATTR_APPS", "HEAD_ATTR_DEPR"] +OPT_ATTR_DESCR = "decription" +OPT_ATTR_TARGET = "target" +OPT_ATTR_USECASE = "usecase" +OPT_ATTR_UCID = "usecase-id" +OPT_ATTR_STORY = "story" +OPT_ATTR_STORYID = "story-id" +LIST_OPT_ATTR = [OPT_ATTR_DESCR, OPT_ATTR_TARGET, OPT_ATTR_USECASE, OPT_ATTR_UCID, + OPT_ATTR_STORY, OPT_ATTR_STORYID] CSV_HEADER_START = ["node", "table", "tabelle"] CSV_DELIMITER = ";" diff --git a/tools/dbmysql_tool.py b/tools/dbmysql_tool.py index b1783d4..54789e2 100644 --- a/tools/dbmysql_tool.py +++ b/tools/dbmysql_tool.py @@ -4,12 +4,12 @@ # Author : Ulrich Carmesin # Source : gitea.ucarmesin.de # --------------------------------------------------------------------------------------------------------- -import utils.config_tool +import tools.config_tool import tools.dbrel_tool import mysql.connector import basic.constants as B -import utils.data_const as D -import utils.date_tool +import tools.data_const as D +import tools.date_tool class DbFcts(tools.dbrel_tool.DbFcts): """ @@ -44,7 +44,7 @@ class DbFcts(tools.dbrel_tool.DbFcts): i = 0 for f in self.comp.conf[B.DATA_NODE_DDL][table][B.DATA_NODE_HEADER]: if self.comp.conf[B.DATA_NODE_DDL][table][f][D.DDL_TYPE] in [D.TYPE_TIME, D.TYPE_DATE]: - r[f] = utils.date_tool.getFormatdate(x[i], utils.date_tool.F_DIR) + r[f] = tools.date_tool.getFormatdate(x[i], tools.date_tool.F_DIR) else: r[f] = str(x[i]) i += 1 diff --git a/tools/dbrel_tool.py b/tools/dbrel_tool.py index 557c5b3..ecdb176 100644 --- a/tools/dbrel_tool.py +++ b/tools/dbrel_tool.py @@ -99,7 +99,7 @@ class DbFcts(tools.db_abstract.DbFcts): return attr + " varchar(50)" elif atype == D.TYPE_STRING: return attr + " varchar(500)" - elif atype == D.TYPE_TEXT: + elif atype in [D.TYPE_TEXT, D.TYPE_CLOB, D.TYPE_JLOB, D.TYPE_XLOB]: return attr + " text" elif atype == D.TYPE_INT: return attr + " integer" diff --git a/tools/file_tool.py b/tools/file_tool.py index cfa3614..d684fb2 100644 --- a/tools/file_tool.py +++ b/tools/file_tool.py @@ -207,7 +207,7 @@ def getModTime(job, filepath): return out -def read_file_dict(job, path, msg, ttype=""): +def read_file_dict(job, path, msg, ttype=D.DFILE_TYPE_CSV): """ reads and gets general a dict from any kind of filetyp :param path: with extension of filetype diff --git a/tools/git_tool.py b/tools/git_tool.py index 28543cd..d52afcb 100644 --- a/tools/git_tool.py +++ b/tools/git_tool.py @@ -20,7 +20,11 @@ COMMIT_AUTHOR = "author" COMMIT_DATE = "date" COMMIT_COMMENT = "comment" -def runGit(job, repo, cmd): +REPO_NAME = "name" +REPO_URL = "url" +REPO_BRANCH = "branch" + +def execCmd(job, repo, cmd): """ executes the command on the repository :param job: @@ -31,10 +35,11 @@ def runGit(job, repo, cmd): cdpath = "" if os.path.isdir(repo): cdpath = repo - elif repo in job.conf.confs[B.SUBJECT_PATH]: - cdpath = job.conf.confs[B.SUBJECT_PATH][repo] + elif repo in job.conf[B.SUBJECT_PATH]: + cdpath = job.conf[B.SUBJECT_PATH][repo] else: raise Exception(T.EXP_PATH_MISSING, repo) + print("execCmd on " + cdpath + ": " + cmd) os.chdir(cdpath) text = "" process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) @@ -43,7 +48,7 @@ def runGit(job, repo, cmd): return text def gitStatus(job, repo): - text = runGit(job, repo, "git status") + text = execCmd(job, repo, "git status") return text def gitLog(job, repo, arg="", cnt=DEFAULT_CNT_COMMITS): @@ -58,8 +63,8 @@ def gitLog(job, repo, arg="", cnt=DEFAULT_CNT_COMMITS): arg = " -- "+arg else: arg = "" - text = runGit(job, repo, "git log -n "+str(cnt)+" --pretty=format:\"%H | %cn | %cd | %s\""+arg) - #print(text) + text = execCmd(job, repo, "git log -n "+str(cnt)+" --pretty=format:\"%H | %cn | %cd | %s\""+arg) + print(text+"\n\n") logs = [] i = 0 for l in text.split("\n"): @@ -67,6 +72,9 @@ def gitLog(job, repo, arg="", cnt=DEFAULT_CNT_COMMITS): break res = {} a = l.split("|") + print(str(a)) + if len(a) < 2: + continue res[COMMIT_ID] = a[0].strip() res[COMMIT_AUTHOR] = a[1].strip() cdate = utils.date_tool.parseDate(a[2].strip()) @@ -82,19 +90,39 @@ def gitCommits(job, repo, arg=""): arg = " -- "+arg else: arg = "" - text = runGit(job, repo, "git log --pretty=format:\"%H | %cn | %cd | %s\""+arg) + text = execCmd(job, repo, "git log --pretty=format:\"%H | %cn | %cd | %s\""+arg) print(text) +def checkoutLocal(job, local): + os.chdir(local["url"]) + cmd = "git checkout " + local["branch"] + execCmd(job, cmd) + +def updateLocal(job, local, repo): + job.m.logInfo("--- aktualisiere git-Repo "+str(repo)+","+str(local)) + checkoutLocal(job, local) + cmd = "git pull " + repo["name"] + " " + repo["branch"] + execCmd(job, cmd) + os.chdir(job.home) + +def updateRemote(job, local, repo): + job.m.logInfo("--- aktualisiere git-Repo "+str(repo)+","+str(local)) + checkoutLocal(job, local) + cmd = "git push " + repo["name"] + " " + repo["branch"] + execCmd(job, cmd) + os.chdir(job.home) + def gitPull(job, repo): - if "git" not in job.conf.confs[B.SUBJECT_TOOL] or repo not in job.conf.confs[B.SUBJECT_TOOL]["git"]: + if "git" not in job.conf[B.SUBJECT_TOOL] or repo not in job.conf[B.SUBJECT_TOOL]["git"]: raise Exception(T.EXP_CONFIG_MISSING, "tool.git."+repo) - #print(str(job.conf.confs[B.SUBJECT_TOOL]["git"][repo])) - master = job.conf.confs[B.SUBJECT_TOOL]["git"][repo]["master"] - remote = job.conf.confs[B.SUBJECT_TOOL]["git"][repo]["remote"] - text = runGit(job, repo, "git status") + #print(str(job.conf[B.SUBJECT_TOOL]["git"][repo])) + master = job.conf[B.SUBJECT_TOOL]["git"][repo]["master"] + remote = job.conf[B.SUBJECT_TOOL]["git"][repo]["remote"] + text = execCmd(job, repo, "git status") if "Commit vor" in text: print("Das Repository "+repo+" bitte zuerst pushen \n") #print(text+"\"-------------------------------------\n") else: + print("Repository "+repo+" kann gepullt werden.") - #runGit(job, repo, "git pull "+remote+" "+master) \ No newline at end of file + #execCmd(job, repo, "git pull "+remote+" "+master)