From ae399fc30030b18c60dde40e6910eae60c1484d4 Mon Sep 17 00:00:00 2001 From: Ulrich Carmesin Date: Tue, 22 Feb 2022 22:17:59 +0100 Subject: [PATCH] nameschema paths --- basic/componentHandling.py | 123 ++++++++++++++++++++----------------- basic/constants.py | 43 ++++++++++--- basic/program.py | 22 +++---- components/component.py | 2 +- utils/configs/path.yml | 12 ++-- 5 files changed, 120 insertions(+), 82 deletions(-) diff --git a/basic/componentHandling.py b/basic/componentHandling.py index cb08cc1..7884ec2 100644 --- a/basic/componentHandling.py +++ b/basic/componentHandling.py @@ -26,7 +26,8 @@ import basic.constants as B comps = {} PARAM_NOSUBNODE = ["artifact", "components", "instance"] - +DEFAULT_INST_CNT = 1 +DEFAULT_INST_SGL = "y" def getComponents(mainfct): job = basic.program.Job.getInstance() @@ -41,6 +42,22 @@ def getComponents(mainfct): return out +def getInstanceAttributes(conf): + """ + the attributes for instancing the component are set from configuration or from default + :param conf: + :return: a complete set of these attributes + """ + out = {} + out[B.ATTR_INST_CNT] = DEFAULT_INST_CNT + out[B.ATTR_INST_SGL] = DEFAULT_INST_SGL + if B.SUBJECT_INST in conf: + for attr in [B.ATTR_INST_CNT, B.ATTR_INST_SGL]: + if attr in conf[B.SUBJECT_INST]: + out[attr] = conf[B.SUBJECT_INST][attr] + return out + + class ComponentManager: __instance = None """ @@ -64,7 +81,7 @@ class ComponentManager: return for k in job.conf.confs["applicationen"].get(anw): job.m.logDebug("applicationscomponente -- " + k + ":") - self.createComponents(k, 0, "") + self.createComponent(k, 0, "") def setComponents(self): # set components from parameter-file @@ -96,90 +113,85 @@ class ComponentManager: else: raise Exception("Klasse noch nicht initialisiert") - def createComponents(self, componentName, nr, suffix): + def createComponent(self, componentName, nr, suffix): """ in order to create a component it must be loaded * knogwedge of the application - which components should be created * technical-knowledge of the instanciated component, especially the connection, user, password * business-knowledge of the component, especially of their interfaces resp. artifacts :param componentName: Name of the component - :param nr: - :param suffix: + :param nr: for numbered instance if component is multiple + :param suffix: suffix for specific context of the component :return: """ job = basic.program.Job.getInstance() verify = job.getDebugLevel("job_tool") componentName = componentName.lower() - print("createComponent " + componentName) + job.debug(verify, "createComponent " + componentName) confs = utils.config_tool.getConfig("comp", componentName) conns = utils.conn_tool.getConnections(componentName) - print("createComponent -91- " + componentName + " : " + str(confs)) - if nr > 0 and int(confs["conf"]["instance"]["count"]) > 1: + instAttr = getInstanceAttributes(confs) + job.debug(verify, "createComponent -91- " + componentName + " : " + str(confs)) + if nr > 0 and int(instAttr[B.ATTR_INST_CNT]) > 1: job.m.setError("for multiple callers are multiple calls not implemented ") if nr > 0 and len(conns) == 0: job.m.setError("for multiple calls has only one call configured") print(confs) - print("createComponent 1 " + componentName) - print(getComponentPath(componentName)) - print("createComponent 2 " + componentName) - cmodul = importlib.import_module(getComponentPath(componentName)) - class_ = getattr(cmodul, getComponentClass(componentName)) - readedPar = job.loadParameter() + parContent = job.loadParameter() if len(conns) == 1: + c = self.createInstance(componentName, parContent, confs, conns, 0) print("createComponent 3 a " + componentName) - if nr > 0 and confs["conf"]["instance"]["single"] == "n": - name = componentName + "_0" + str(nr) - else: - name = componentName - c = class_() - c.name = name - c.conf = confs["conf"] - c.conf[B.SUBJECT_CONN] = conns[0] - c.m = basic.message.Message(basic.message.LIMIT_DEBUG, "logTime", name) - c.init() - print("createComponent 4 a " + componentName) - print(vars(c)) - print(vars(c.m)) - if readedPar is not None: - print("createComponent 5 a " + name + " : " + str(readedPar)) - if name in readedPar["comps"]: - for k in readedPar["comps"][name].keys(): - c.conf[k] = readedPar["comps"][name][k] - comps[name] = c - self.createComponent(c, nr, suffix) + self.createSubComponents(c, nr, suffix) else: i = 1 print("createComponent 3 b " + componentName) for cn in conns: - name = componentName + "_0" + str(i) - c = class_() - c.name = name - c.conf = confs["conf"] - c.conf[B.SUBJECT_CONN] = conns[0] - c.m = basic.message.Message(basic.message.LIMIT_DEBUG, "logTime", name) - c.init() - print("createComponent 4 b " + componentName) - print(vars(c)) - if readedPar is not None: - if name in readedPar["comps"]: - for k in readedPar["comps"][name].keys(): - c.conf[k] = readedPar["comps"][name][k] - else: - print("comp fehlt "+name) - comps[name] = c - self.createComponent(c, i, suffix) + c = self.createInstance(componentName, parContent, confs, conns, i) + self.createSubComponents(c, i, suffix) i = i + 1 print("createComponent 9 " + componentName) print(comps) - def createComponent(self, comp, nr, suffix): + def createInstance(self, compName, parContent, confs, conns, nr): + """ + instance a component + :param compName: name without suffix or number + :param parContent: content of the parameter-file which is dumped from a pre-step + :param confs: configuration of the component + :param conns: connection-attributes for the specific environment + :param nr: number if component is multiple + :return: instance of the component with all necessary attributes + """ + cmodul = importlib.import_module(getComponentPath(compName)) + class_ = getattr(cmodul, getComponentClass(compName)) + c = class_() + if nr > 0: + name = compName + "_0" + str(nr) + i = nr - 1 + else: + name = compName + i = 0 + c.name = name + c.conf = confs["conf"] + c.conf[B.SUBJECT_CONN] = conns[i] + c.m = basic.message.Message(basic.message.LIMIT_DEBUG, "logTime", name) + c.init() + if parContent is not None: + print("createComponent 5 a " + name + " : " + str(parContent)) + if name in parContent["comps"]: + for k in parContent["comps"][name].keys(): + c.conf[k] = parContent["comps"][name][k] + comps[name] = c + return c + + def createSubComponents(self, comp, nr, suffix): job = basic.program.Job.getInstance() verify = -2 + job.getDebugLevel("job_tool") - job.debug(verify, "getComponents " + str(comp.conf["components"])) - for c in comp.conf["components"].keys(): + job.debug(verify, "getComponents " + str(comp.conf[B.ATTR_INST_SUBCOMP])) + for c in comp.conf[B.ATTR_INST_SUBCOMP].keys(): if c == "none": continue - self.createComponents(c, nr, suffix) + self.createComponent(c, nr, suffix) def getComponentFolder(comp): @@ -220,6 +232,7 @@ def isParameterSubnode(key): return False return True + def getPlainCompname(name): if "_0" in name: return name[0:-3] diff --git a/basic/constants.py b/basic/constants.py index a9ebc5e..4266928 100644 --- a/basic/constants.py +++ b/basic/constants.py @@ -19,6 +19,30 @@ The constants desribes the keywords of the main datastructures, these are * the internal datastructure """ +PAR_APP = 'application' +""" definition of the application which will be tested """ +PAR_ENV = 'environment' +""" definition of the environment where the application runs which will be tested """ +PAR_REL = 'release' +""" definition of the release of the application which will be tested """ +PAR_TSDIR = 'tsdir' +""" definition of the directory of the testsuite for summaries of the testcases """ +PAR_TCDIR = 'tcdir' +""" definition of the directory of the testcase for logs and results """ +PAR_XPDIR = 'xpdir' +""" definition of the directory of expectation for comparing the testcase """ +PAR_TDTYP = 'tdtyp' +PAR_TDSRC = 'tdsrc' +PAR_TDNAME = 'tdname' +PAR_LOG = 'loglevel' +PAR_MODUS = 'modus' +PAR_COMP = 'component' +PAR_FCT = 'function' +PAR_TOOL = 'tool' +PAR_TESTCASE = "testcase" +""" name of testcase extracted from PAR_TCDIR """ + + # the internal datastructure is a tree with this design: # root { : constant # + option { : constant @@ -61,24 +85,25 @@ ATTR_PATH_HOME = "home" ATTR_PATH_DEBUG = "debugs" """ This constant defines the debug-folder in testing-filesystem """ ATTR_PATH_ARCHIV = "archiv" -""" This constant defines the archiv-folder in testing-filesystem """ -ATTR_PATH_SPECIAL = "results" -""" This constant defines the debug-folder in testing-filesystem """ +""" This constant defines the folder in testing-filesystem for results and log of execution """ +ATTR_PATH_EXPECT = "expect" +""" This constant defines the folder in testing-filesystem for test-expectation values """ ATTR_PATH_PROGRAM = "program" -""" This constant defines the program-folder in testing-filesystem """ +""" This constant defines the program-folder in the workspace """ ATTR_PATH_ENV = "environment" -""" This constant defines the environment-folder in testing-filesystem, used for configs related to environments """ +""" This constant defines the folder in testing-filesystem, used for configs related to environments """ ATTR_PATH_RELEASE = "release" -""" This constant defines the release-folder in testing-filesystem, used for configs related to release """ +""" This constant defines the folder in testing-filesystem, used for configs related to release """ ATTR_PATH_TDATA = "testdata" -""" This constant defines the testdata-folder in testing-filesystem with the testcase-specifications """ +""" This constant defines the folder in testing-filesystem with the testcase-specifications """ ATTR_PATH_PATTN = "pattern" """ This constant defines the debug-folder in testing-filesystem """ SUBJECT_APPS = "applications" # | x | | | | CompHandling SUBJECT_INST = "instance" # | | | | x | CompHanlding -ATTR_COUNT = "count" # | | | | x | CompHanlding - +ATTR_INST_CNT = "count" # | | | | x | CompHanlding +ATTR_INST_SGL = "single" +ATTR_INST_SUBCOMP = "components" SUBJECT_FCT = "function" # | | | | x | main-programs SUBJECT_ARTS = "artifact" # | | | | x | Component diff --git a/basic/program.py b/basic/program.py index f5740bf..05ed4d9 100644 --- a/basic/program.py +++ b/basic/program.py @@ -35,14 +35,14 @@ jobdef = { "dirname": "envdir", "logdir": "{job.par.envdir}/{log}/log_{time}.txt" }, "init_testset": { - "pardef": "tsdir,tdtyp,tdsrc,tdname", + "pardef": "tsdir", # ,tdtyp,tdsrc,tdname", "pfilesource" : "envparfile", "pfiletarget" : "tsparfile", "basedir": "tsbase", "dirname": "tsdir", "logdir": "{job.par.tsdir}/{log}/log_{tstime}.txt" }, "init_testcase": { - "pardef": "tcdir,tdtyp,tdsrc,tdname", + "pardef": "tcdir", # ",tdtyp,tdsrc,tdname", "pfilesource" : "envparfile", "pfiletarget" : "tcparfile", "basedir": "tcbase", @@ -264,19 +264,20 @@ class Parameter: parser.add_argument('-ts', '--tsdir', action='store') parser.add_argument('-tc', '--tcdir', action='store') parser.add_argument('-rs', '--rsdir', action='store') - parser.add_argument('-dt', '--tdtyp', action='store') - parser.add_argument('-ds', '--tdsrc', action='store') - parser.add_argument('-dn', '--tdname', action='store') - parser.add_argument('-l', '--loglevel', action='store') - parser.add_argument('-m', '--modus', action='store') - parser.add_argument('-c', '--componente', action='store') - parser.add_argument('-f', '--funktion', action='store') - parser.add_argument('-t', '--tool', action='store') + parser.add_argument('-dt', '--tdtyp', action='store') # PAR_TDTYP + parser.add_argument('-ds', '--tdsrc', action='store') # PAR_TDSRC + parser.add_argument('-dn', '--tdname', action='store') # PAR_TDNAME + parser.add_argument('-l', '--loglevel', action='store') # PAR_LOG + parser.add_argument('-m', '--modus', action='store') # PAR_MODUS + parser.add_argument('-c', '--component', action='store') # PAR_COMP + parser.add_argument('-f', '--function', action='store') # PAR_FCT + parser.add_argument('-t', '--tool', action='store') # PAR_TOOL # parser.add_argument('-t', '--typ', default='einzel', action='store') # parser.add_argument('-d', '--dir', action='store') args = parser.parse_args() self.setParameterArgs(args) + def getDirParameter(self): if hasattr(self, "tcdir"): return ("tcbase", str(self.tcdir)) @@ -315,7 +316,6 @@ class Parameter: return self[a[0]] if len(a) == 2: return self[a[0]][a[1]] - return class Configuration: diff --git a/components/component.py b/components/component.py index f0c3c18..03b1449 100644 --- a/components/component.py +++ b/components/component.py @@ -80,7 +80,7 @@ class Component(components.testexec.Testexecuter): self.m.logInfo("get files in for " + self.name + " in tcresult ") self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() " + str(self.name)) - def collect_Target(self): + def collect_Expect(self): """ pre: only for components which be collected at the end of the test-set collects the result from the folder {rsresult}. diff --git a/utils/configs/path.yml b/utils/configs/path.yml index 4faac60..44d9df5 100644 --- a/utils/configs/path.yml +++ b/utils/configs/path.yml @@ -31,14 +31,14 @@ pattern: tcdiff: "{tcresult}/{diff}" tcprediff: "{tcresult}/{prediff}" tcrundiff: "{tcresult}/{rundiff}" - tcprecond: "{tcresult}/vorher" - tcpostcond: "{tcresult}/nachher" + tcprecond: "{tcresult}/{precond}" + tcpostcond: "{tcresult}/{postcond}" # testset tsbase: "{job.conf.archiv}/{job.par.release}/{job.par.usecase}_{job.par.tltime}" tslog: "{tsbase}/{log}" tsparfile: "{tsbase}/{parfile}" tssum: "{tsbase}/Ergebnis" - # target-result rs - rsbase: "{job.conf.results}/{job.par.branch}" - rsresult: "{rsbase}/{result}" - rsbackup: "{rsbase}/{result}" + # expectation-result rs + xpbase: "{job.conf.expect}/{job.par.branch}" + xpresult: "{xpbase}/{result}" + xpbackup: "{xpbase}/{result}"