Browse Source

renames

master
Ulrich Carmesin 3 years ago
parent
commit
50ad303cdd
  1. 37
      basic/componentHandling.py
  2. 7
      basic/message.py
  3. 20
      basic/program.py
  4. 11
      check_environment.py
  5. 8
      components/catalog.py
  6. 27
      components/component.py
  7. 6
      components/maintain.py
  8. 2
      components/mariadb/CONFIG.yml
  9. 6
      components/report.py
  10. 10
      components/sysmonitor.py
  11. 2
      components/testa/CONFIG.yml
  12. 5
      components/testa1/CONFIG.yml
  13. 2
      components/testa11/CONFIG.yml
  14. 2
      components/testb/CONFIG.yml
  15. 2
      components/testb1/CONFIG.yml
  16. 48
      components/testexec.py
  17. 6
      declare_result.py
  18. 8
      finish_testcase.py
  19. 6
      finish_testset.py
  20. 6
      init_testcase.py
  21. 8
      init_testset.py
  22. 4
      test/test_config.py
  23. 4
      test/test_conn.py
  24. 19
      test/test_db.py
  25. 8
      test/test_file.py
  26. 14
      test/test_job.py
  27. 4
      test/test_main.py
  28. 12
      test/test_path.py
  29. 4
      test/test_tdata.py
  30. 10
      utils/config_tool.py
  31. 10
      utils/conn_tool.py
  32. 4
      utils/file_tool.py
  33. 2
      utils/job_tool.py
  34. 12
      utils/path_tool.py
  35. 8
      utils/report_tool.py
  36. 4
      utils/ssh_tool.py
  37. 16
      utils/tdata_tool.py

37
basic/componentHandling.py

@ -11,8 +11,8 @@ Each crated component-onject are documented in the parameter-file.
"""
import utils.config_tool
import utils.conn_tool
import ulrich.program
import ulrich.message
import basic.program
import basic.message
import components.component
import importlib
import copy
@ -22,7 +22,7 @@ PARAM_NOSUBNODE = ["artifact", "components", "instance"]
def getComponents(mainfct):
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -2 + job.getDebugLevel("job_tool")
job.debug(verify, "getComponents " + mainfct)
out = []
@ -41,14 +41,15 @@ class ComponentManager:
"""
def __init__(self):
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
job.m.logDebug("applicationscomponente -- " + str(type(job.par)))
self.components = {}
print ("init ComponentHandling "+str(self))
def initComponents(self):
# sets components the first time
# afterwards set components from parameter-file
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
anw = job.par.application
job.m.logDebug("applicationscomponente -- " + str(type(job.par)))
if not job.conf.confs["applicationen"].get(anw):
@ -60,15 +61,27 @@ class ComponentManager:
def setComponents(self):
# set components from parameter-file
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
job.m.logDebug("applicationscomponente -- " + str(type(job.par)))
def getComponent(self, compobjname):
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -2 + job.getDebugLevel("job_tool")
job.debug(verify, "getComponents " + compobjname)
return comps[compobjname]
def getComponents(mainfct):
job = basic.program.Job.getInstance()
verify = -2 + job.getDebugLevel("job_tool")
job.debug(verify, "getComponents " + mainfct)
out = []
for c in comps:
job.debug(verify, "getComponents " + c + ": " + str(comps[c].conf))
print("getComponents " + c + ": " + str(comps[c].conf))
if mainfct in comps[c].conf["function"]:
out.append(c)
return out
@staticmethod
def getInstance():
if (ComponentManager.__instance is not None):
@ -87,7 +100,7 @@ class ComponentManager:
:param suffix:
:return:
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = job.getDebugLevel("job_tool")
componentName = componentName.lower()
print("createComponent " + componentName)
@ -115,7 +128,7 @@ class ComponentManager:
c.name = name
c.conf = confs["conf"]
c.conf["conn"] = conns[0]
c.m = ulrich.message.Message(ulrich.message.LIMIT_DEBUG, "logTime", name)
c.m = basic.message.Message(basic.message.LIMIT_DEBUG, "logTime", name)
c.init()
print("createComponent 4 a " + componentName)
print(vars(c))
@ -135,7 +148,7 @@ class ComponentManager:
c.name = name
c.conf = confs["conf"]
c.conf["conn"] = conns[0]
c.m = ulrich.message.Message(ulrich.message.LIMIT_DEBUG, "logTime", name)
c.m = basic.message.Message(basic.message.LIMIT_DEBUG, "logTime", name)
c.init()
print("createComponent 4 b " + componentName)
print(vars(c))
@ -149,7 +162,7 @@ class ComponentManager:
print(comps)
def createComponent(self, comp, nr, suffix):
job = ulrich.program.Job.getInstance()
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():
@ -175,7 +188,7 @@ def getComponentPath(comp):
def getComponentDict():
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -2 + job.getDebugLevel("job_tool")
job.debug(verify, "getComponents ")
out = {}

7
basic/message.py

@ -16,7 +16,7 @@ at the end of a program there are some results:
* for each component there is a return-code, a top-message for documentation in the parameter-file, and a list of collected messages
+ for the main-program the result (return-code, top-message) will be summarized (the most relevant message will used)
"""
import ulrich.program
import basic.program
import os
import math
from datetime import datetime
@ -57,7 +57,7 @@ class Message:
# (self, componente, out, level):
self.componente = componente # dezantrales Logsystem
#self.level = level # Vorgabe zu level zum Filtern, ob auszugebe
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
print(vars(job))
print(globals())
# exit(5)
@ -74,6 +74,7 @@ class Message:
self.debug(verify, "> > > debugfile uebernommen zu " + str(componente))
else:
debugpath = job.conf.confs["paths"]["debugs"] + "/debug_" + logTime[0:-4] + "00.txt"
print ("debugpathx "+debugpath)
self.debugfile = open(debugpath, "a")
self.debug(verify, "> > > debugfile geoeffnet zu " + job.program + " mit " + debugpath)
# init logfile - except for components or unittest
@ -143,7 +144,7 @@ class Message:
self.debugfile.close()
def setRc(self, rc, text):
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -0+LIMIT_DEBUG
self.debug(verify, "setRc " + str(rc) + " " + str(self.rc)+ "\n")
if (int(rc) > self.rc):

20
basic/program.py

@ -8,9 +8,9 @@ import copy
import yaml
from datetime import datetime
import ulrich.message
import ulrich.message
import ulrich.componentHandling
import basic.message
import basic.message
import basic.componentHandling
import utils.date_tool
import utils.path_tool
@ -84,7 +84,7 @@ class Job:
if program == "unit": # no job will be started
self.start = datetime.now()
logTime = self.start.strftime("%Y%m%d_%H%M%S")
self.m = ulrich.message.Message(ulrich.message.LIMIT_DEBUG, logTime, None)
self.m = basic.message.Message(basic.message.LIMIT_DEBUG, logTime, None)
print("prog-50 " + str(self.par.basedir))
@ -106,11 +106,11 @@ class Job:
self.start = datetime.now()
print("prog-68 " + str(self.par.basedir))
logTime = self.start.strftime("%Y%m%d_%H%M%S")
self.m = ulrich.message.Message(ulrich.message.LIMIT_DEBUG, logTime, None)
self.m = basic.message.Message(basic.message.LIMIT_DEBUG, logTime, None)
print("prog-68 " + str(self.m.rc))
self.par.setParameterLoaded()
self.m.logInfo("# # # Start Job " + self.start.strftime("%d.%m.%Y %H:%M:%S") + " # # # ")
self.m.debug(ulrich.message.LIMIT_INFO, "# # # Start Job " + self.start.strftime("%d.%m.%Y %H:%M:%S") + " # # # ")
self.m.debug(basic.message.LIMIT_INFO, "# # # Start Job " + self.start.strftime("%d.%m.%Y %H:%M:%S") + " # # # ")
self.par.checkParameter()
def stopJob(self, reboot=0):
@ -119,8 +119,8 @@ class Job:
print("stopJob " + str(self.m.messages) + ", " + str(self.m.debugfile))
self.m.logInfo("# # " + self.m.topmessage + " # # # ")
self.m.logInfo("# # # Stop Job " + self.start.strftime("%d.%m.%Y %H:%M:%S") + " # " + self.ende.strftime("%d.%m.%Y %H:%M:%S") + " # # # ")
self.m.debug(ulrich.message.LIMIT_INFO, "# # " + self.m.topmessage + " # # # ")
self.m.debug(ulrich.message.LIMIT_INFO, "# # # Stop Job " + self.start.strftime("%d.%m.%Y %H:%M:%S") + " # " + self.ende.strftime("%d.%m.%Y %H:%M:%S") + " # # # RC: " + str(self.m.getFinalRc()))
self.m.debug(basic.message.LIMIT_INFO, "# # " + self.m.topmessage + " # # # ")
self.m.debug(basic.message.LIMIT_INFO, "# # # Stop Job " + self.start.strftime("%d.%m.%Y %H:%M:%S") + " # " + self.ende.strftime("%d.%m.%Y %H:%M:%S") + " # # # RC: " + str(self.m.getFinalRc()))
self.m.closeMessage()
rc = self.m.getFinalRc()
print ("rc " + str(rc))
@ -130,7 +130,7 @@ class Job:
def dumpParameter(self):
parpath = utils.path_tool.composePath(jobdef[self.program]["pfiletarget"], None)
output = {}
output["comps"] = ulrich.componentHandling.getComponentDict()
output["comps"] = basic.componentHandling.getComponentDict()
output["par"] = self.par.__dict__
print(str(output))
with open(parpath, "w") as file:
@ -170,7 +170,7 @@ class Job:
return self.hasElement("tool", tool)
def getMessageLevel(self, errtyp, elem):
if (not hasattr(self, "m")) or (self.m is None):
return ulrich.message.LIMIT_DEBUG
return basic.message.LIMIT_DEBUG
elif elem.find("tool") > 1:
if not hasattr(self.par, "tool") or getattr(self.par, "tool").find(elem) <= 0:
return int(self.m.CONST_ERRTYP[errtyp]) -1

11
check_environment.py

@ -2,15 +2,15 @@
import sys#
# import jsonpickle # pip install jsonpickle
import yaml # pip install pyyaml
import ulrich.program
import ulrich.componentHandling
import ulrich.message
import basic.program
import basic.componentHandling
import basic.message
import utils.tdata_tool
PROGRAM_NAME = "check_environment"
if __name__ == '__main__':
x = ulrich.program.Job(PROGRAM_NAME)
x = basic.program.Job(PROGRAM_NAME)
print ("x "+str(x))
x.startJob()
x.m.logDebug(str(vars(x.par)) + "\n" + str(vars(x.conf)))
@ -19,7 +19,8 @@ if __name__ == '__main__':
exit(x.m.rc * (-1) + 3)
# now in theory the program is runnable
x.m.setMsg("# job initialized")
cm = ulrich.componentHandling
cm = basic.componentHandling.ComponentManager()
print("cm "+str(cm))
cm.initComponents()
comps = cm.getComponents(PROGRAM_NAME)
x.m.setMsg("# Components initialized with these relevant components " + str(comps))

8
components/catalog.py

@ -5,13 +5,13 @@ a lot of test-results are created dynamically - so these dont belog to the testd
In order to get an overview over the testcases these results should be imported into a database.
"""
from datetime import datetime
import ulrich.message
import ulrich.program
import basic.message
import basic.program
import inspect
import components.component
class Catalog(components.component.CompData):
class Catalog():
def init_Catalog(self):
"""
@ -24,7 +24,7 @@ class Catalog(components.component.CompData):
"""
checks system-instances and writes it into the parameter-file
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -1 + job.getDebugLevel(self.name)
self.m.logInfo("--- " + str(inspect.currentframe().f_code.co_name) + "() started at " + datetime.now().strftime(
"%Y%m%d_%H%M%S") + " for " + str(self.name).upper())

27
components/component.py

@ -3,12 +3,12 @@
from datetime import datetime
import components.sysmonitor
import components.testrun
import components.testexec
import components.report
import components.maintain
import components.catalog
import ulrich.message
import ulrich.program
import basic.message
import basic.program
import inspect
import threading
@ -21,8 +21,9 @@ class CompData:
class Component(components.sysmonitor.SystemMonitor, components.testrun.Testrun, components.report.Report,
components.maintain.Maintainer, components.catalog, threading.Thread):
#class Component(components.sysmonitor.SystemMonitor, components.testexec.Testexecuter, components.report.Report,
# components.maintain.Maintainer, components.catalog, threading.Thread):
class Component():
"""
A component represents an application of the system-under-test or a data-artifact which is created from the system-under-test.
As the representation it has to knowlegde of the url, which other components depends on this component.
@ -39,12 +40,12 @@ class Component(components.sysmonitor.SystemMonitor, components.testrun.Testrun,
it is controlled by their configuration
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = job.getDebugLevel(self.name)
self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() " + str(self.name))
def run(self):
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
if job.program == "check_environment":
self.check_Instance()
elif job.program == "init_testset":
@ -68,7 +69,7 @@ class Component(components.sysmonitor.SystemMonitor, components.testrun.Testrun,
the content is stored intern for comparison
:return:
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = job.getDebugLevel(self.name)
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))
@ -80,7 +81,7 @@ class Component(components.sysmonitor.SystemMonitor, components.testrun.Testrun,
post: a further contact zo the test-system is not necessary
:return:
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = job.getDebugLevel(self.name)
self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() " + str(self.name))
@ -129,7 +130,7 @@ class Component(components.sysmonitor.SystemMonitor, components.testrun.Testrun,
the relevant testcases will be called
:return:
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = job.getDebugLevel(self.name)
self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() " + str(self.name))
# for tc in testcases:
@ -140,7 +141,7 @@ class Component(components.sysmonitor.SystemMonitor, components.testrun.Testrun,
controles the comparison the result with the target
:return:
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = job.getDebugLevel(self.name)
self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() " + str(self.name))
# for tc in testcases:
@ -155,7 +156,7 @@ class Component(components.sysmonitor.SystemMonitor, components.testrun.Testrun,
(2.4) visualization of statistical result-codes of each component and each test-set in test-context - result-report -
:return:
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = job.getDebugLevel(self.name)
self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() " + str(self.name))
reportheader = '<head>'
@ -194,7 +195,7 @@ class Component(components.sysmonitor.SystemMonitor, components.testrun.Testrun,
pass
def declare_Target(self):
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -1+job.getDebugLevel(self.name)
self.m.logInfo("--- " + str(inspect.currentframe().f_code.co_name) + "() started at " + datetime.now().strftime("%Y%m%d_%H%M%S") + " for " + str(self.name).upper())
self.m.logInfo("something in "+ self.name)

6
components/maintain.py

@ -8,11 +8,11 @@ outside the testrun there are some tasks in order maintain the tests, for exampl
# partial cleaning of the storage
"""
from datetime import datetime
import ulrich.message
import ulrich.program
import basic.message
import basic.program
import inspect
import components.component
class Maintainer(components.component.CompData):
class Maintainer():
pass

2
components/mariadb/CONFIG.yml

@ -1,7 +1,7 @@
# Example af a component with
# # one instance -> connection
# # mo subcomponents
# # artifact-tyoe db -> precondition, load testdata, postcondition
# # artifact-tyoe flaskdb -> precondition, load testdata, postcondition
conf:
instance:
count: 1

6
components/report.py

@ -4,12 +4,12 @@
reporting-applications
"""
from datetime import datetime
import ulrich.message
import ulrich.program
import basic.message
import basic.program
import inspect
import components.component
class Report(components.component.CompData):
class Report():
pass

10
components/sysmonitor.py

@ -6,19 +6,19 @@ installed and if each instance is running. In order to know these fundamental po
The result could be inserted into a database so you can get an overview over all test environments.
"""
from datetime import datetime
import ulrich.message
import ulrich.program
import basic.message
import basic.program
import inspect
import components.component
#from components.component import CompData
class SystemMonitor(components.component.CompData):
class SystemMonitor():
def check_Instance(self):
"""
checks system-instances and writes it into the parameter-file
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -1 + job.getDebugLevel(self.name)
self.m.logInfo("--- " + str(inspect.currentframe().f_code.co_name) + "() started at " + datetime.now().strftime(
"%Y%m%d_%H%M%S") + " for " + str(self.name).upper())

2
components/testa/CONFIG.yml

@ -26,7 +26,7 @@ conf:
script: "{dompath}/bin/sysctl.sh" # for checking
checks: "status,version,start,stop,restart,available"
artifact: # look at testrun
log: # log|db|file|lob
log: # log|flaskdb|file|lob
path: "{dompath}/log/debug.log"
rotate: jmx
reset: testcase

5
components/testa1/CONFIG.yml

@ -1,7 +1,7 @@
# Example af a component with
# # one instance -> connection
# # mo subcomponents
# # artifact-tyoe db -> precondition, load testdata, postcondition
# # artifact-tyoe flaskdb -> precondition, load testdata, postcondition
conf:
instance:
count: 1
@ -20,5 +20,4 @@ conf:
artifact:
db:
reset: testset
testdata: db #
testdata: flaskdb #

2
components/testa11/CONFIG.yml

@ -1,7 +1,7 @@
# Example af a component with
# # one instance -> connection
# # mo subcomponents
# # artifact-tyoe db -> precondition, load testdata, postcondition
# # artifact-tyoe flaskdb -> precondition, load testdata, postcondition
conf:
instance:
count: 1

2
components/testb/CONFIG.yml

@ -8,7 +8,7 @@ conf:
single: y
components:
testB1:
relationtyp: db
relationtyp: flaskdb
conffile: "{dompath}/config/dbconn.xml"
filetyp: xml
ippattern: "<second>.*?<ip>(.*?)</ip>"

2
components/testb1/CONFIG.yml

@ -1,7 +1,7 @@
# Example af a component with
# # one instance -> connection
# # mo subcomponents
# # artifact-tyoe db -> precondition, load testdata, postcondition
# # artifact-tyoe flaskdb -> precondition, load testdata, postcondition
conf:
instance:
count: 1

48
components/testexec.py

@ -28,13 +28,13 @@ the test can check different quality-measures like
4.b
"""
from datetime import datetime
import ulrich.message
import ulrich.program
import basic.message
import basic.program
import inspect
import components.component
class Testrun(components.component.CompData):
class Testexecuter():
def prepare_system(self, granularity):
"""
In order to preparate the test system test data should be cleaned and loaded with actual data.
@ -43,7 +43,7 @@ class Testrun(components.component.CompData):
The loaded test data should be selected for a later comparison.
:return:
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -1+job.getDebugLevel(self.name)
self.m.logInfo("--- " + str(inspect.currentframe().f_code.co_name) + "() started at " + datetime.now().strftime("%Y%m%d_%H%M%S") + " for " + str(self.name).upper())
@ -58,15 +58,15 @@ class Testrun(components.component.CompData):
:param granularity:
:return:
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -1+job.getDebugLevel(self.name)
self.m.logDebug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() started at " + datetime.now().strftime("%Y%m%d_%H%M%S") + " for " + str(self.name).upper())
if "log" in self.conf["artifact"]:
self.m.logInfo("log rotate in "+ self.name)
if "db" in self.conf["artifact"]:
self.m.logInfo("delete db-content "+ self.name)
if "flaskdb" in self.conf["artifact"]:
self.m.logInfo("delete flaskdb-content "+ self.name)
if "lob" in self.conf["artifact"]:
self.m.logInfo("lob is deleted with db "+ self.name)
self.m.logInfo("lob is deleted with flaskdb "+ self.name)
if "file" in self.conf["artifact"]:
self.m.logInfo("rm files in "+ self.name)
self.m.setMsg("checkInstance for " + self.name + " is OK")
@ -80,12 +80,12 @@ class Testrun(components.component.CompData):
:param testdata:
:return:
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -1+job.getDebugLevel(self.name)
self.m.logDebug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() started at " + datetime.now().strftime("%Y%m%d_%H%M%S") + " for " + str(self.name).upper())
if "testdata" in self.conf:
if self.conf["testdata"] == "db":
self.m.logInfo("insert db-content " + self.name)
if self.conf["testdata"] == "flaskdb":
self.m.logInfo("insert flaskdb-content " + self.name)
self.m.setMsg("data loaded for " + self.name + " is OK")
self.m.logDebug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() finished at " + datetime.now().strftime("%Y%m%d_%H%M%S") + " for " + str(self.name).upper())
@ -95,13 +95,13 @@ class Testrun(components.component.CompData):
:param granularity:
:return:
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -1+job.getDebugLevel(self.name)
self.m.logDebug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() started at " + datetime.now().strftime("%Y%m%d_%H%M%S") + " for " + str(self.name).upper())
if "db" in self.conf["artifact"]:
self.m.logInfo("select db-content "+ self.name)
if "flaskdb" in self.conf["artifact"]:
self.m.logInfo("select flaskdb-content "+ self.name)
if "lob" in self.conf["artifact"]:
self.m.logInfo("check lob if is deleted with db "+ self.name)
self.m.logInfo("check lob if is deleted with flaskdb "+ self.name)
self.m.setMsg("checkInstance for " + self.name + " is OK")
self.m.logDebug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() finished at " + datetime.now().strftime("%Y%m%d_%H%M%S") + " for " + str(self.name).upper())
@ -123,7 +123,7 @@ class Testrun(components.component.CompData):
initialization-routine for finish-step
:return:
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -1+job.getDebugLevel(self.name)
self.m.logInfo("--- " + str(inspect.currentframe().f_code.co_name) + "() started at " + datetime.now().strftime("%Y%m%d_%H%M%S") + " for " + str(self.name).upper())
self.m.logInfo("something in "+ self.name)
@ -146,14 +146,14 @@ class Testrun(components.component.CompData):
post: a further contact zo the test-system is not necessary
:return:
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = job.getDebugLevel(self.name)
if "log" in self.conf["artifact"]:
self.m.logInfo("get files in for "+ self.name + " in " + self.conf["artifact"]["log"]["path"])
if "db" in self.conf["artifact"]:
self.m.logInfo("select db-content "+ self.name)
if "flaskdb" in self.conf["artifact"]:
self.m.logInfo("select flaskdb-content "+ self.name)
if "lob" in self.conf["artifact"]:
pass # after selection get file from db
pass # after selection get file from flaskdb
if "file" in self.conf["artifact"]:
self.m.logInfo("get files in for "+ self.name + " in " + self.conf["artifact"]["file"]["path"])
@ -165,15 +165,15 @@ class Testrun(components.component.CompData):
the result is written as utf-8-readable parts in subfolder {tcparts}
:return:
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = job.getDebugLevel(self.name)
self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() " + str(self.name))
if "log" in self.conf["artifact"]:
pass #
if "db" in self.conf["artifact"]:
if "flaskdb" in self.conf["artifact"]:
pass # stored in table
if "lob" in self.conf["artifact"]:
self.m.logInfo("move file from db "+ self.name)
self.m.logInfo("move file from flaskdb "+ self.name)
self.m.logInfo("tidy files in for " + self.name + " in " + self.conf["artifact"]["lob"]["format"])
if "file" in self.conf["artifact"]:
self.m.logInfo("tidy files in for "+ self.name + " in " + self.conf["artifact"]["file"]["format"])
@ -185,7 +185,7 @@ class Testrun(components.component.CompData):
with the identifiable name - like in target
:return:
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = job.getDebugLevel(self.name)
self.m.debug(verify, "--- " + str(inspect.currentframe().f_code.co_name) + "() " + str(self.name))

6
declare_result.py

@ -2,9 +2,9 @@
import sys#
# import jsonpickle # pip install jsonpickle
import yaml # pip install pyyaml
import ulrich.program as program
from ulrich.componentHandling import ComponentManager
import ulrich.message as message
import basic.program as program
from basic.componentHandling import ComponentManager
import basic.message as message
# Press Umschalt+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.

8
finish_testcase.py

@ -2,15 +2,15 @@
import sys#
# import jsonpickle # pip install jsonpickle
import yaml # pip install pyyaml
import ulrich.program
from ulrich.componentHandling import ComponentManager
import ulrich.message
import basic.program
from basic.componentHandling import ComponentManager
import basic.message
import utils.tdata_tool
PROGRAM_NAME = "finish_testcase"
if __name__ == '__main__':
x = ulrich.program.Job(PROGRAM_NAME)
x = basic.program.Job(PROGRAM_NAME)
x.startJob()
x.m.logInfo("hier eine LogInfo")
x.m.logDebug("hier eine DbugMeldung")

6
finish_testset.py

@ -2,9 +2,9 @@
import sys#
# import jsonpickle # pip install jsonpickle
import yaml # pip install pyyaml
import ulrich.program as program
from ulrich.componentHandling import ComponentManager
import ulrich.message as message
import basic.program as program
from basic.componentHandling import ComponentManager
import basic.message as message
# Press Umschalt+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.

6
init_testcase.py

@ -2,9 +2,9 @@
import sys#
# import jsonpickle # pip install jsonpickle
import yaml # pip install pyyaml
import ulrich.program as program
from ulrich.componentHandling import ComponentManager
import ulrich.message as message
import basic.program as program
from basic.componentHandling import ComponentManager
import basic.message as message
# Press Umschalt+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.

8
init_testset.py

@ -2,15 +2,15 @@
import sys#
# import jsonpickle # pip install jsonpickle
import yaml # pip install pyyaml
import ulrich.program
from ulrich.componentHandling import ComponentManager
import ulrich.message
import basic.program
from basic.componentHandling import ComponentManager
import basic.message
import utils.tdata_tool
PROGRAM_NAME = "init_testset"
if __name__ == '__main__':
x = ulrich.program.Job(PROGRAM_NAME)
x = basic.program.Job(PROGRAM_NAME)
x.startJob()
x.m.logInfo("hier eine LogInfo")
x.m.logDebug("hier eine DbugMeldung")

4
test/test_config.py

@ -1,6 +1,6 @@
import unittest
import utils.config_tool as t
from ulrich.program import Job
from basic.program import Job
class MyTestCase(unittest.TestCase):
@ -11,7 +11,7 @@ class MyTestCase(unittest.TestCase):
job.par.setParameterArgs(args)
r = t.getConfigPath("tool", "path")
print (r)
self.assertEqual(r, "/home/ulrich/6_Projekte/Programme/pythonProject/utils/configs/path.yml")
self.assertEqual(r, "/home/basic/6_Projekte/Programme/pythonProject/utils/configs/path.yml")
r = t.getConfigPath("comp", "TestA2")
print (r)
self.assertEqual(r, None)

4
test/test_conn.py

@ -1,11 +1,11 @@
import unittest
import ulrich.program
import basic.program
import utils.conn_tool
class MyTestCase(unittest.TestCase):
def test_something(self):
print("# # # # tetsComponents # # # # #")
job = ulrich.program.Job("unit")
job = basic.program.Job("unit")
args = { "application" : "TEST" , "environment" : "ENV01", "modus" : "unit", "loglevel" : "debug", "tool" : "job_tool"}
job.par.setParameterArgs(args)
self.assertEqual(True, True)

19
test/test_db.py

@ -0,0 +1,19 @@
import sys, os
import unittest
import basic.program
import utils.conn_tool
sys.path.append((0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib', 'python3.9', 'site-packages', 'mysql')))
#import mysql.connector
import db_tool
class MyTestCase(unittest.TestCase):
def test_something(self):
job = basic.program.Job("unit")
args = { "application" : "TEST" , "environment" : "ENV01", "modus" : "unit", "loglevel" : "debug", "tool" : "job_tool"}
job.par.setParameterArgs(args)
print(sys.path)
dbconn = db_tool.getConnector()
print (dbconn)
pass
if __name__ == '__main__':
unittest.main()

8
test/test_file.py

@ -1,12 +1,12 @@
import unittest
import utils.file_tool as t
import utils.path_tool
import ulrich.program
import basic.program
class MyTestCase(unittest.TestCase):
def test_getFiles(self):
job = ulrich.program.Job("unit")
job = basic.program.Job("unit")
args = {"application": "TEST", "application": "ENV01", "modus": "unit", "loglevel": "debug", "tool": "job_tool",
"modus": "unit"}
job.par.setParameterArgs(args)
@ -20,12 +20,12 @@ class MyTestCase(unittest.TestCase):
print (r)
def test_pathTool(self):
job = ulrich.program.Job("unit")
job = basic.program.Job("unit")
args = {"application": "TEST", "application": "ENV01", "modus": "unit", "loglevel": "debug", "tool": "job_tool",
"modus": "unit"}
job.par.setParameterArgs(args)
self.assertEqual(utils.path_tool.generatePath("program", "komp", "testA", "CONFIG.yml"),
"/home/ulrich/6_Projekte/PythonProject/komponents/testA/COFIG.yml")
"/home/basic/6_Projekte/PythonProject/komponents/testA/COFIG.yml")
if __name__ == '__main__':

14
test/test_job.py

@ -1,7 +1,7 @@
import unittest
import os
from ulrich.program import Job
from ulrich.componentHandling import ComponentManager
from basic.program import Job
from basic.componentHandling import ComponentManager
class MyTestCase(unittest.TestCase):
def test_parameter(self):
@ -14,7 +14,7 @@ class MyTestCase(unittest.TestCase):
self.assertEqual(job.getDebugLevel("file_tool"), 23)
self.assertEqual(job.getDebugLevel("job_tool"), 23)
args = { "application" : "TEST" , "environment" : "ENV01", "modus" : "unit", "loglevel" : "debug",
"tool" : "job_tool", "tsdir": "/home/ulrich/6_Projekte/Programme/pythonProject/test/lauf/V0.1/startjob/2021-08-21_18-ß2-01"}
"tool" : "job_tool", "tsdir": "/home/ulrich/6_Projekte/Programme/holtz/test/lauf/V0.1/startjob/2021-08-21_18-ß2-01"}
job.par.setParameterArgs(args)
def test_components(self):
print("# # # # tetsComponents # # # # #")
@ -26,10 +26,10 @@ class MyTestCase(unittest.TestCase):
cm.createComponents("testa", 1, "")
def test_run(self):
os.system("python /home/ulrich/6_Projekte/Programme/pythonProject/check_environment.py -a TEST -e ENV01")
# os.system("python /home/ulrich/6_Projekte/Programme/pythonProject/init_testset.py -a TEST -e ENV01 "
# "-ts /home/ulrich/6_Projekte/Programme/pythonProject/test/lauf/V0.1/implement_2021-08-28_23-50-51 -dt csv -ds implement -dn firstunit")
# os.system("python /home/ulrich/6_Projekte/Programme/pythonProject/init_testset.py")
os.system("python /home/ulrich/6_Projekte/Programme/holtz/check_environment.py -a TEST -e ENV01")
# os.system("python /home/basic/6_Projekte/Programme/pythonProject/init_testset.py -a TEST -e ENV01 "
# "-ts /home/basic/6_Projekte/Programme/holtz/test/lauf/V0.1/implement_2021-08-28_23-50-51 -dt csv -ds implement -dn firstunit")
# os.system("python /home/basic/6_Projekte/Programme/pythonProject/init_testset.py")
if __name__ == '__main__':
unittest.main()

4
test/test_main.py

@ -1,11 +1,11 @@
import unittest
import utils.path_tool as path_tool
import ulrich.program as program
import basic.program as program
class MyTestCase(unittest.TestCase):
def test_pathTool(self):
x = program.Job("test:application=TEST:application=ENV01")
self.assertEqual(path_tool.generatePath("program", "komp", "testA", "CONFIG.yml"), "/home/ulrich/6_Projekte/PythonProject/komponents/testA/COFIG.yml")
self.assertEqual(path_tool.generatePath("program", "komp", "testA", "CONFIG.yml"), "/home/basic/6_Projekte/PythonProject/komponents/testA/COFIG.yml")
if __name__ == '__main__':

12
test/test_path.py

@ -1,6 +1,6 @@
import unittest
import utils.path_tool
from ulrich.program import Job
from basic.program import Job
class MyTestCase(unittest.TestCase):
@ -15,20 +15,20 @@ class MyTestCase(unittest.TestCase):
print(r)
r = t.getKeyValue("job.conf.results")
print(r)
self.assertEqual(r, "/home/ulrich/6_Projekte/Programme/pythonProject/test/target")
self.assertEqual(r, "/home/basic/6_Projekte/Programme/pythonProject/test/target")
r = t.composePath("tcbase", None)
#r = t.replaceNoPython("{job.conf.archiv}/{job.par.release}/{job.par.testcase}/{job.par.tctime}", "{job.conf.archiv}", "/home/ulrich/6_Projekte/Programme/pythonProject/test/lauf")
#r = t.replaceNoPython("{job.conf.archiv}/{job.par.release}/{job.par.testcase}/{job.par.tctime}", "{job.conf.archiv}", "/home/basic/6_Projekte/Programme/pythonProject/test/lauf")
print(r)
args = { "application" : "TEST" , "application" : "ENV01", "modus" : "unit", "loglevel" : "debug",
"tool" : "job_tool", "tsdir": "/home/ulrich/6_Projekte/Programme/pythonProject/test/lauf/V0.1/startjob/2021-08-21_18-ß2-01"}
"tool" : "job_tool", "tsdir": "/home/basic/6_Projekte/Programme/pythonProject/test/lauf/V0.1/startjob/2021-08-21_18-ß2-01"}
job = Job.resetInstance("unit")
job.par.setParameterArgs(args)
# r = t.extractPath("tsbase" , "/home/ulrich/6_Projekte/Programme/pythonProject/test/lauf/V0.1/startjob/2021-08-21_18-ß2-01")
# r = t.extractPath("tsbase" , "/home/basic/6_Projekte/Programme/pythonProject/test/lauf/V0.1/startjob/2021-08-21_18-ß2-01")
r = t.extractPattern("tsbase" )
print(r)
self.assertEqual(r[0][1], "job.conf.archiv")
self.assertEqual(r[3][0], "_")
r = t.extractPath("tsbase" , "/home/ulrich/6_Projekte/Programme/pythonProject/test/lauf/V0.1/startjob_2021-08-21_10-02-01")
r = t.extractPath("tsbase" , "/home/basic/6_Projekte/Programme/pythonProject/test/lauf/V0.1/startjob_2021-08-21_10-02-01")
print("r " + str(r))
print(vars(job.par))
self.assertEqual(job.par.release, "V0.1")

4
test/test_tdata.py

@ -1,10 +1,10 @@
import unittest
import utils.tdata_tool as t
import ulrich.program
import basic.program
class MyTestCase(unittest.TestCase):
def test_pathTool(self):
job = ulrich.program.Job("unit")
job = basic.program.Job("unit")
args = {"application": "TEST", "application": "ENV01", "modus": "unit", "loglevel": "debug",
"tool": "job_tool", "tdtyp": "csv", "tdsrc": "implement", "tdname": "firstunit",
"modus": "unit"}

10
utils/config_tool.py

@ -2,12 +2,12 @@
# --------------------------------------------------------------
import sys
try:
import ulrich.program
import basic.program
except ImportError:
print("ImportError: " + str(ImportError.with_traceback()))
pass
import yaml
import ulrich.componentHandling
import basic.componentHandling
import utils.path_tool
import os.path
@ -25,7 +25,7 @@ def getConfigPath(modul, name):
* testset << parameter/environ
* testcase << parameter
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = job.getDebugLevel("config_tool")
job.debug(verify, "getConfig " + modul + ", " + name)
if modul == "tool":
@ -47,7 +47,7 @@ def getConfigPath(modul, name):
job.debug(verify, "4 " + pathname)
if os.path.exists(pathname):
return pathname
pathname = job.conf.confs.get("paths").get("program") + "/components/" + ulrich.componentHandling.getComponentFolder(name) + "/CONFIG.yml"
pathname = job.conf.confs.get("paths").get("program") + "/components/" + basic.componentHandling.getComponentFolder(name) + "/CONFIG.yml"
job.debug(verify, "5 " + pathname)
if os.path.exists(pathname):
return pathname
@ -76,7 +76,7 @@ def getConfigPath(modul, name):
job.debug(verify, "12 " + pathname)
def getConfig(modul, name):
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = job.getDebugLevel("config_tool")
pathname = getConfigPath(modul, name)
confs = {}

10
utils/conn_tool.py

@ -3,10 +3,10 @@
"""
"""
import ulrich.program
import basic.program
import utils.config_tool
def getConnection(comp, nr):
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = job.getDebugLevel("conn_tool")
conn = {}
if job.conf.confs.get("tools").get("connsrc") == "yml":
@ -16,14 +16,14 @@ def getConnection(comp, nr):
return conn["env"][comp][instnr]
else:
job.m.setFatal("Conn-Tool: Comp not configured " + comp + " " + str(nr))
elif job.conf.confs.get("tools").get("connsrc") == "db":
elif job.conf.confs.get("tools").get("connsrc") == "flaskdb":
pass
elif job.conf.confs.get("tools").get("connsrc") == "csv":
pass
return None
def getConnections(comp):
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = job.getDebugLevel("conn_tool")
print("getConnections " + comp)
conn = {}
@ -32,7 +32,7 @@ def getConnections(comp):
conn = utils.config_tool.getConfig("tool", "conn")
if not comp in conn["env"]:
job.m.setFatal("Conn-Tool: Comp not configured " + comp)
elif job.conf.confs.get("tools").get("connsrc") == "db":
elif job.conf.confs.get("tools").get("connsrc") == "flaskdb":
pass
elif job.conf.confs.get("tools").get("connsrc") == "csv":
pass

4
utils/file_tool.py

@ -6,8 +6,8 @@
import os
import os.path
import re
from ulrich.message import Message
from ulrich.program import Job
from basic.message import Message
from basic.program import Job
from pprint import pp
def getDump(obj):
result=""

2
utils/job_tool.py

@ -19,7 +19,7 @@
12. Funktion -- schraenkt Verarbeitung auf parametriserte Funktionen ein
13. Tool -- schraenkt Protokollierung/Verarbeitung auf parametriserte Tools ein
"""
from ulrich.program import Job
from basic.program import Job
def hasModul(komp):
job = Job.getInstance()
return False

12
utils/path_tool.py

@ -3,13 +3,13 @@
# -----------------------------------------------------------------------
""" In diesem Modul werden alle Funktionen zusammengefasst zur Generierung und Ermittlung von pathsn """
import sys
import ulrich.program
import basic.program
import utils.config_tool
import re
def getKeyValue(key):
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = job.getDebugLevel("path_tool")
pt = PathConf.getInstance()
print("getKeyValue " + key)
@ -28,7 +28,7 @@ def getKeyValue(key):
return "xx-"+key+"-xx"
def composePath(pathname, comp):
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = job.getDebugLevel("path_tool")
pt = PathConf.getInstance()
print("composePath " + pathname + " zu " + str(pt) + "mit ")
@ -39,7 +39,7 @@ def composePath(pathname, comp):
print("in Pattern nicht vorhanden: " + pathname)
def composePatttern(pattern, comp):
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = job.getDebugLevel("path_tool")
print("composePattern " + pattern)
max=5
@ -60,7 +60,7 @@ def composePatttern(pattern, comp):
return pattern
def extractPattern(pathtyp):
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
out = []
pt = PathConf.getInstance()
pattern = pt.pattern[pathtyp]
@ -78,7 +78,7 @@ def extractPattern(pathtyp):
return out
def extractPath(pathtyp, pathname):
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
patterlist = extractPattern(pathtyp)
work = pathname
i = 0

8
utils/report_tool.py

@ -14,7 +14,7 @@ the reporting-system in bottom-up
(2.3) visualization of final result-code of each component and each testcase in test-set - result-report -
(2.4) visualization of statistical result-codes of each component and each test-set in test-context - result-report -
"""
import ulrich.program
import basic.program
def getTcExtraction(tcpath, comp):
"""
@ -22,7 +22,7 @@ def getTcExtraction(tcpath, comp):
:param comp:
:return: html-code with links to diff-files
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -0 + job.getDebugLevel("report_tool")
job.debug(verify, "writeDataTable " + str(comp))
body = '<div class="diff"><p>'
@ -37,7 +37,7 @@ def getTcBody(tcpath):
:param tcpath:
:return:
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -0+job.getDebugLevel("report_tool")
job.debug(verify, "writeDataTable " + str(tcpath))
body = '<div class="diff"><p>'
@ -52,7 +52,7 @@ def getTcHeader(tcpath):
:param tcpath:
:return: html-code with result-codes of each component
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -0+job.getDebugLevel("report_tool")
job.debug(verify, "writeDataTable " + str(tcpath))

4
utils/ssh_tool.py

@ -5,11 +5,11 @@
"""
import os
import ulrich
import basic
import paramiko
def getRemoteClass(comp):
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = job.getDebugLevel("config_tool")
if job.conf.confs.get("tools").get("remotetyp") == "ssh":
return SshCmd(comp)

16
utils/tdata_tool.py

@ -5,7 +5,7 @@ the issue of this tool is to transform extern data to the internal structure and
* * * * * * * *
the testdata have several elements
* parameter (-td --tdata) : to identify which testdata should be loaded
* source (db: dbname / dir: filename) : always structured in a table (easy to specify) with columns
* source (flaskdb: dbname / dir: filename) : always structured in a table (easy to specify) with columns
* node : where the rows are
* action : what should be done - default insert
+ fields : dates in relation of a reference<day or a formula
@ -16,19 +16,19 @@ the testdata have several elements
the testdata itself which are written in different artifacts of modern applications are mostly stored as tree
- so as xml, json, always with plain data in the leaf. So the intern structure should be also a tree - in python: dictionary.
"""
import ulrich.program
import basic.program
import csv
def getSourcefile(filename):
pass
def getTestdata():
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
reftyp = getattr(job.par, "tdtyp")
source = getattr(job.par, "tdsrc")
criteria = getattr(job.par, "tdname")
tdata = {"reftyp": reftyp, "source": source, "criteria": criteria}
if reftyp == "db":
if reftyp == "flaskdb":
# read data-structure with sourcename
# connect to source
# select with all data with datastructure
@ -41,7 +41,7 @@ def getTestdata():
return tdata
def readCsv(filename):
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -1+job.getDebugLevel("tdata_tool")
job.debug(verify, "readCsv " + filename)
fields = []
@ -110,14 +110,14 @@ def setSubnode(i, nodes, data, tree):
def getDataStructure(comp):
# gets data-structure from the vml in the component-folder
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -1+job.getDebugLevel("tdata_tool")
job.debug(verify, "getDataStructure " + comp)
def normalizeDataRow(dstruct, xpathtupel, row, referencedate):
# normalize data of the row if necessary
# raw-value is saved as new field with _raw as suffix
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -1+job.getDebugLevel("tdata_tool")
job.debug(verify, "calcDataRow " + row)
@ -129,7 +129,7 @@ def writeDataTable(teststatus, tdata, comp):
:param comp: if specific else None
:return:
"""
job = ulrich.program.Job.getInstance()
job = basic.program.Job.getInstance()
verify = -1+job.getDebugLevel("tdata_tool")
job.debug(verify, "writeDataTable " + str(comp))

Loading…
Cancel
Save