Data-Test-Executer Framework speziell zum Test von Datenverarbeitungen mit Datengenerierung, Systemvorbereitungen, Einspielungen, ganzheitlicher diversifizierender Vergleich
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
3.0 KiB

import basic.component
import basic.constants as B
import basic.toolHandling
2 years ago
import tools.config_tool
import tools.data_const as D
import tools.file_tool
import model.table
COMP_NAME = "testserver"
COMP_TABLES = ["application", "ap_component", "ap_project", "ap_application",
"environment", "en_component", "en_project"]
class Testserver(basic.component.Component):
tables = {}
def __init__(self, job):
print('init '+COMP_NAME)
self.m = job.m
self.conf = {}
2 years ago
if B.TOPIC_NODE_DB in job.conf:
self.conf[B.SUBJECT_CONN] = {}
self.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB] = {}
for attr in B.LIST_DB_ATTR:
2 years ago
if attr in job.conf[B.TOPIC_NODE_DB]:
self.conf[B.SUBJECT_CONN][B.TOPIC_NODE_DB][attr] = job.conf[B.TOPIC_NODE_DB][attr]
if not B.DATA_NODE_DDL in self.conf:
self.conf[B.DATA_NODE_DDL] = {}
for table in COMP_TABLES:
if table in B.LIST_DB_ATTR:
continue
2 years ago
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
2 years ago
tddl = {}
tddl[table] = {}
#for k in ddl:
for k in tableDdl.fielddef:
tddl[table][k] = tableDdl.fielddef[k]
tddl[table][B.DATA_NODE_HEADER] = D.LIST_DDL_ATTR
tddl[table][B.DATA_NODE_FIELDS] = tableDdl.fieldnames
2 years ago
tddl[D.DATA_ATTR_TBL] = table
path = "/home/ulrich/workspace/Datest/temp/"+table+".yml"
2 years ago
tools.file_tool.write_file_dict(job.m, job, path, tddl)
path = "/home/ulrich/workspace/Datest/temp/"+table+".csv"
tools.file_tool.write_file_dict(job.m, job, path, tddl, ttype=D.CSV_SPECTYPE_DDL)
if B.DATA_NODE_TABLES in ddl and table in ddl[B.DATA_NODE_TABLES]:
self.conf[B.DATA_NODE_DDL][table] = ddl[B.DATA_NODE_TABLES][table]
elif table in ddl:
self.conf[B.DATA_NODE_DDL][table] = ddl[table]
else:
self.conf[B.DATA_NODE_DDL][table] = ddl
def createDBTables(self, job):
2 years ago
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)
for s in sql.split(";\n"):
if len(s) < 3:
continue
try:
2 years ago
dbi.execStatement(s+";", job.conf[B.TOPIC_NODE_DB])
print("SQL executed: "+s)
except Exception as e:
raise Exception("Fehler bei createSchema "+s)
pass