Browse Source

nameschema paths

master
Ulrich Carmesin 3 years ago
parent
commit
ae399fc300
  1. 117
      basic/componentHandling.py
  2. 43
      basic/constants.py
  3. 22
      basic/program.py
  4. 2
      components/component.py
  5. 12
      utils/configs/path.yml

117
basic/componentHandling.py

@ -26,7 +26,8 @@ import basic.constants as B
comps = {} comps = {}
PARAM_NOSUBNODE = ["artifact", "components", "instance"] PARAM_NOSUBNODE = ["artifact", "components", "instance"]
DEFAULT_INST_CNT = 1
DEFAULT_INST_SGL = "y"
def getComponents(mainfct): def getComponents(mainfct):
job = basic.program.Job.getInstance() job = basic.program.Job.getInstance()
@ -41,6 +42,22 @@ def getComponents(mainfct):
return out 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: class ComponentManager:
__instance = None __instance = None
""" """
@ -64,7 +81,7 @@ class ComponentManager:
return return
for k in job.conf.confs["applicationen"].get(anw): for k in job.conf.confs["applicationen"].get(anw):
job.m.logDebug("applicationscomponente -- " + k + ":") job.m.logDebug("applicationscomponente -- " + k + ":")
self.createComponents(k, 0, "") self.createComponent(k, 0, "")
def setComponents(self): def setComponents(self):
# set components from parameter-file # set components from parameter-file
@ -96,90 +113,85 @@ class ComponentManager:
else: else:
raise Exception("Klasse noch nicht initialisiert") 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 in order to create a component it must be loaded
* knogwedge of the application - which components should be created * knogwedge of the application - which components should be created
* technical-knowledge of the instanciated component, especially the connection, user, password * technical-knowledge of the instanciated component, especially the connection, user, password
* business-knowledge of the component, especially of their interfaces resp. artifacts * business-knowledge of the component, especially of their interfaces resp. artifacts
:param componentName: Name of the component :param componentName: Name of the component
:param nr: :param nr: for numbered instance if component is multiple
:param suffix: :param suffix: suffix for specific context of the component
:return: :return:
""" """
job = basic.program.Job.getInstance() job = basic.program.Job.getInstance()
verify = job.getDebugLevel("job_tool") verify = job.getDebugLevel("job_tool")
componentName = componentName.lower() componentName = componentName.lower()
print("createComponent " + componentName) job.debug(verify, "createComponent " + componentName)
confs = utils.config_tool.getConfig("comp", componentName) confs = utils.config_tool.getConfig("comp", componentName)
conns = utils.conn_tool.getConnections(componentName) conns = utils.conn_tool.getConnections(componentName)
print("createComponent -91- " + componentName + " : " + str(confs)) instAttr = getInstanceAttributes(confs)
if nr > 0 and int(confs["conf"]["instance"]["count"]) > 1: 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 ") job.m.setError("for multiple callers are multiple calls not implemented ")
if nr > 0 and len(conns) == 0: if nr > 0 and len(conns) == 0:
job.m.setError("for multiple calls has only one call configured") job.m.setError("for multiple calls has only one call configured")
print(confs) print(confs)
print("createComponent 1 " + componentName) parContent = job.loadParameter()
print(getComponentPath(componentName))
print("createComponent 2 " + componentName)
cmodul = importlib.import_module(getComponentPath(componentName))
class_ = getattr(cmodul, getComponentClass(componentName))
readedPar = job.loadParameter()
if len(conns) == 1: if len(conns) == 1:
c = self.createInstance(componentName, parContent, confs, conns, 0)
print("createComponent 3 a " + componentName) print("createComponent 3 a " + componentName)
if nr > 0 and confs["conf"]["instance"]["single"] == "n": self.createSubComponents(c, nr, suffix)
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)
else: else:
i = 1 i = 1
print("createComponent 3 b " + componentName) print("createComponent 3 b " + componentName)
for cn in conns: for cn in conns:
name = componentName + "_0" + str(i) c = self.createInstance(componentName, parContent, confs, conns, i)
self.createSubComponents(c, i, suffix)
i = i + 1
print("createComponent 9 " + componentName)
print(comps)
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_() c = class_()
if nr > 0:
name = compName + "_0" + str(nr)
i = nr - 1
else:
name = compName
i = 0
c.name = name c.name = name
c.conf = confs["conf"] c.conf = confs["conf"]
c.conf[B.SUBJECT_CONN] = conns[0] c.conf[B.SUBJECT_CONN] = conns[i]
c.m = basic.message.Message(basic.message.LIMIT_DEBUG, "logTime", name) c.m = basic.message.Message(basic.message.LIMIT_DEBUG, "logTime", name)
c.init() c.init()
print("createComponent 4 b " + componentName) if parContent is not None:
print(vars(c)) print("createComponent 5 a " + name + " : " + str(parContent))
if readedPar is not None: if name in parContent["comps"]:
if name in readedPar["comps"]: for k in parContent["comps"][name].keys():
for k in readedPar["comps"][name].keys(): c.conf[k] = parContent["comps"][name][k]
c.conf[k] = readedPar["comps"][name][k]
else:
print("comp fehlt "+name)
comps[name] = c comps[name] = c
self.createComponent(c, i, suffix) return c
i = i + 1
print("createComponent 9 " + componentName)
print(comps)
def createComponent(self, comp, nr, suffix): def createSubComponents(self, comp, nr, suffix):
job = basic.program.Job.getInstance() job = basic.program.Job.getInstance()
verify = -2 + job.getDebugLevel("job_tool") verify = -2 + job.getDebugLevel("job_tool")
job.debug(verify, "getComponents " + str(comp.conf["components"])) job.debug(verify, "getComponents " + str(comp.conf[B.ATTR_INST_SUBCOMP]))
for c in comp.conf["components"].keys(): for c in comp.conf[B.ATTR_INST_SUBCOMP].keys():
if c == "none": if c == "none":
continue continue
self.createComponents(c, nr, suffix) self.createComponent(c, nr, suffix)
def getComponentFolder(comp): def getComponentFolder(comp):
@ -220,6 +232,7 @@ def isParameterSubnode(key):
return False return False
return True return True
def getPlainCompname(name): def getPlainCompname(name):
if "_0" in name: if "_0" in name:
return name[0:-3] return name[0:-3]

43
basic/constants.py

@ -19,6 +19,30 @@ The constants desribes the keywords of the main datastructures, these are
* the internal datastructure * 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: # the internal datastructure is a tree with this design:
# root { : constant # root { : constant
# + option { : constant # + option { : constant
@ -61,24 +85,25 @@ ATTR_PATH_HOME = "home"
ATTR_PATH_DEBUG = "debugs" ATTR_PATH_DEBUG = "debugs"
""" This constant defines the debug-folder in testing-filesystem """ """ This constant defines the debug-folder in testing-filesystem """
ATTR_PATH_ARCHIV = "archiv" ATTR_PATH_ARCHIV = "archiv"
""" This constant defines the archiv-folder in testing-filesystem """ """ This constant defines the folder in testing-filesystem for results and log of execution """
ATTR_PATH_SPECIAL = "results" ATTR_PATH_EXPECT = "expect"
""" This constant defines the debug-folder in testing-filesystem """ """ This constant defines the folder in testing-filesystem for test-expectation values """
ATTR_PATH_PROGRAM = "program" 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" 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" 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" 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" ATTR_PATH_PATTN = "pattern"
""" This constant defines the debug-folder in testing-filesystem """ """ This constant defines the debug-folder in testing-filesystem """
SUBJECT_APPS = "applications" # | x | | | | CompHandling SUBJECT_APPS = "applications" # | x | | | | CompHandling
SUBJECT_INST = "instance" # | | | | x | CompHanlding 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_FCT = "function" # | | | | x | main-programs
SUBJECT_ARTS = "artifact" # | | | | x | Component SUBJECT_ARTS = "artifact" # | | | | x | Component

22
basic/program.py

@ -35,14 +35,14 @@ jobdef = {
"dirname": "envdir", "dirname": "envdir",
"logdir": "{job.par.envdir}/{log}/log_{time}.txt" }, "logdir": "{job.par.envdir}/{log}/log_{time}.txt" },
"init_testset": { "init_testset": {
"pardef": "tsdir,tdtyp,tdsrc,tdname", "pardef": "tsdir", # ,tdtyp,tdsrc,tdname",
"pfilesource" : "envparfile", "pfilesource" : "envparfile",
"pfiletarget" : "tsparfile", "pfiletarget" : "tsparfile",
"basedir": "tsbase", "basedir": "tsbase",
"dirname": "tsdir", "dirname": "tsdir",
"logdir": "{job.par.tsdir}/{log}/log_{tstime}.txt" }, "logdir": "{job.par.tsdir}/{log}/log_{tstime}.txt" },
"init_testcase": { "init_testcase": {
"pardef": "tcdir,tdtyp,tdsrc,tdname", "pardef": "tcdir", # ",tdtyp,tdsrc,tdname",
"pfilesource" : "envparfile", "pfilesource" : "envparfile",
"pfiletarget" : "tcparfile", "pfiletarget" : "tcparfile",
"basedir": "tcbase", "basedir": "tcbase",
@ -264,19 +264,20 @@ class Parameter:
parser.add_argument('-ts', '--tsdir', action='store') parser.add_argument('-ts', '--tsdir', action='store')
parser.add_argument('-tc', '--tcdir', action='store') parser.add_argument('-tc', '--tcdir', action='store')
parser.add_argument('-rs', '--rsdir', action='store') parser.add_argument('-rs', '--rsdir', action='store')
parser.add_argument('-dt', '--tdtyp', action='store') parser.add_argument('-dt', '--tdtyp', action='store') # PAR_TDTYP
parser.add_argument('-ds', '--tdsrc', action='store') parser.add_argument('-ds', '--tdsrc', action='store') # PAR_TDSRC
parser.add_argument('-dn', '--tdname', action='store') parser.add_argument('-dn', '--tdname', action='store') # PAR_TDNAME
parser.add_argument('-l', '--loglevel', action='store') parser.add_argument('-l', '--loglevel', action='store') # PAR_LOG
parser.add_argument('-m', '--modus', action='store') parser.add_argument('-m', '--modus', action='store') # PAR_MODUS
parser.add_argument('-c', '--componente', action='store') parser.add_argument('-c', '--component', action='store') # PAR_COMP
parser.add_argument('-f', '--funktion', action='store') parser.add_argument('-f', '--function', action='store') # PAR_FCT
parser.add_argument('-t', '--tool', action='store') parser.add_argument('-t', '--tool', action='store') # PAR_TOOL
# parser.add_argument('-t', '--typ', default='einzel', action='store') # parser.add_argument('-t', '--typ', default='einzel', action='store')
# parser.add_argument('-d', '--dir', action='store') # parser.add_argument('-d', '--dir', action='store')
args = parser.parse_args() args = parser.parse_args()
self.setParameterArgs(args) self.setParameterArgs(args)
def getDirParameter(self): def getDirParameter(self):
if hasattr(self, "tcdir"): if hasattr(self, "tcdir"):
return ("tcbase", str(self.tcdir)) return ("tcbase", str(self.tcdir))
@ -315,7 +316,6 @@ class Parameter:
return self[a[0]] return self[a[0]]
if len(a) == 2: if len(a) == 2:
return self[a[0]][a[1]] return self[a[0]][a[1]]
return return
class Configuration: class Configuration:

2
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.logInfo("get files in for " + self.name + " in tcresult ")
self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() " + str(self.name)) 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 pre: only for components which be collected at the end of the test-set
collects the result from the folder {rsresult}. collects the result from the folder {rsresult}.

12
utils/configs/path.yml

@ -31,14 +31,14 @@ pattern:
tcdiff: "{tcresult}/{diff}" tcdiff: "{tcresult}/{diff}"
tcprediff: "{tcresult}/{prediff}" tcprediff: "{tcresult}/{prediff}"
tcrundiff: "{tcresult}/{rundiff}" tcrundiff: "{tcresult}/{rundiff}"
tcprecond: "{tcresult}/vorher" tcprecond: "{tcresult}/{precond}"
tcpostcond: "{tcresult}/nachher" tcpostcond: "{tcresult}/{postcond}"
# testset # testset
tsbase: "{job.conf.archiv}/{job.par.release}/{job.par.usecase}_{job.par.tltime}" tsbase: "{job.conf.archiv}/{job.par.release}/{job.par.usecase}_{job.par.tltime}"
tslog: "{tsbase}/{log}" tslog: "{tsbase}/{log}"
tsparfile: "{tsbase}/{parfile}" tsparfile: "{tsbase}/{parfile}"
tssum: "{tsbase}/Ergebnis" tssum: "{tsbase}/Ergebnis"
# target-result rs # expectation-result rs
rsbase: "{job.conf.results}/{job.par.branch}" xpbase: "{job.conf.expect}/{job.par.branch}"
rsresult: "{rsbase}/{result}" xpresult: "{xpbase}/{result}"
rsbackup: "{rsbase}/{result}" xpbackup: "{xpbase}/{result}"

Loading…
Cancel
Save