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.

89 lines
3.7 KiB

import basic.component
import basic.constants as B
import utils.config_tool
import utils.data_const as D
import utils.file_tool
COMP_NAME = "testserver"
COMP_TABLES = ["application", "ap_component", "ap_project", "ap_application",
"environment", "en_component", "en_project"]
class Testserver(basic.component.Component):
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
ddl = utils.config_tool.getConfig(job, D.DDL_FILENAME, COMP_NAME, table)
path = "/home/ulrich/workspace/Datest/temp/DATASTRUCTURE.yml"
utils.file_tool.writeFileDict(job.m, job, path, 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 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
def getDBSchema(self, job, dbi, table):
sqlTable = ""
sqlSub = ""
sqlTable += dbi.getCreateTable(table)
tableId = ""
for f in self.conf[B.DATA_NODE_DDL][table]:
if f[0:1] == "_":
continue
fo = self.conf[B.DATA_NODE_DDL][table][f]
if D.DDL_INDEX in fo and len(fo[D.DDL_INDEX]) > 0:
a = fo[D.DDL_INDEX].split(":")
if a[0] == "I":
sqlSub += dbi.getSchemaIndex(table, fo[D.DDL_FNAME]) + "\n"
elif a[0] == "S":
attrList = []
attr = {"attr":fo[D.DDL_FNAME], "atype": fo[D.DDL_TYPE]}
attrList.append(attr)
for i in range(2, len(a)):
if i % 2 == 1:
continue
if a[i] == "attr":
attr = {"attr":"attributes", "atype": D.TYPE_TEXT}
elif i+1 < len(a):
attr = {"attr": a[i], "atype": a[i+1]}
attrList.append(attr)
sqlSub += dbi.getSchemaSubtable(a[1], attrList) + "\n"
sqlSub += dbi.getSchemaIndex(dbi.getSubTableName(a[1], fo[D.DDL_FNAME]), tableId)+"\n"
continue
sqlTable += dbi.getSchemaAttribut(fo[D.DDL_FNAME], fo[D.DDL_TYPE]) + ","
if fo[D.DDL_TYPE] == D.TYPE_PK:
tableId = fo[D.DDL_FNAME]
sql = sqlTable[0:-1]+");\n"+sqlSub
print(sql)
return sql