annotate PerfsDb/ConfigFileBuilder.py @ 188:7d585263808b

new test: test_queries_hierarchy
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 08 Dec 2018 18:17:10 +0100
parents 616da104a996
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
156
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
1 import typing
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
2 import json
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
3 import os
159
616da104a996 fix for ubuntu 18.04
am@osimis.io
parents: 158
diff changeset
4 import platform
156
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
5
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
6 from DbType import DbType
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
7
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
8 class ConfigFileBuilder:
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
9
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
10 @staticmethod
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
11 def generate(
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
12 outputPath: str,
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
13 pluginsPath: str,
156
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
14 storagePath: str,
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
15 dbType: DbType,
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
16 dbSize: str,
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
17 port: int
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
18 ):
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
19
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
20 config = {}
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
21 config["StorageDirectory"] = storagePath
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
22
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
23 dbConfig = {}
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
24 dbConfig["EnableIndex"] = True
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
25
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
26 if dbType.isServer():
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
27 dbConfig["Host"] = "127.0.0.1"
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
28 dbConfig["Lock"] = False
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
29 dbConfig["Port"] = port
156
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
30
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
31 if dbType == DbType.MySQL:
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
32 config["Plugins"] = [os.path.join(pluginsPath, "libOrthancMySQLIndex.so")]
156
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
33 dbConfig["EnableStorage"] = False
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
34 # config["Plugins"] = [os.path.join(pluginsPath, "libOrthancMySQLStorage.so")]
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
35
156
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
36 dbConfig["Database"] = "orthanc"
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
37 dbConfig["Username"] = "orthanc"
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
38 dbConfig["Password"] = "orthanc"
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
39
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
40 config["MySQL"] = dbConfig
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
41
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
42 elif dbType.isPG():
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
43 config["Plugins"] = [os.path.join(pluginsPath, "libOrthancPostgreSQLIndex.so")]
156
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
44 dbConfig["EnableStorage"] = False
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
45 # config["Plugins"] = [os.path.join(pluginsPath, "libOrthancPostgreSQLStorage.so")]
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
46
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
47 dbConfig["Database"] = "postgres"
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
48 dbConfig["Username"] = "postgres"
156
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
49
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
50 config["PostgreSQL"] = dbConfig
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
51
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
52 elif dbType == DbType.MSSQL:
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
53 config["Plugins"] = [os.path.join(pluginsPath, "libOrthancMsSqlIndex.so")]
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
54 dbConfig["EnableStorage"] = False
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
55
159
616da104a996 fix for ubuntu 18.04
am@osimis.io
parents: 158
diff changeset
56 if platform.node() == "benchmark": # the benchmark VM on Azure is a 18.04 -> it has version 17
616da104a996 fix for ubuntu 18.04
am@osimis.io
parents: 158
diff changeset
57 odbcVersion = 17
616da104a996 fix for ubuntu 18.04
am@osimis.io
parents: 158
diff changeset
58 else:
616da104a996 fix for ubuntu 18.04
am@osimis.io
parents: 158
diff changeset
59 odbcVersion = 13
616da104a996 fix for ubuntu 18.04
am@osimis.io
parents: 158
diff changeset
60
616da104a996 fix for ubuntu 18.04
am@osimis.io
parents: 158
diff changeset
61 dbConfig["ConnectionString"] = "Driver={ODBC Driver " + str(odbcVersion) + " for SQL Server};Server=tcp:127.0.0.1," + str(port) + ";Database=master;Uid=sa;Pwd=MyStrOngPa55word!;Encrypt=yes;TrustServerCertificate=yes;Connection Timeout=30"
156
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
62 dbConfig["LicenseString"] = "1abaamBcReVXv6EtE_X___demo-orthanc%osimis.io___HHHnqVHYvEkR3jGs2Y3EvpbxZgTt7yaCniJa2Bz7hFWTMa" # note: this is a trial license expiring on 2018-09-30, replace with your license code
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
63
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
64 config["MSSQL"] = dbConfig
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
65
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
66 elif dbType.isSqlite():
156
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
67 config["IndexDirectory"] = storagePath
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
68 if dbType == DbType.SqlitePlugin:
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents: 156
diff changeset
69 config["Plugins"] = [os.path.join(pluginsPath, "libOrthancSQLiteIndex.so")]
156
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
70
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
71 else:
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
72 raise NotImplementedError
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
73
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
74 with open(outputPath, "w") as configFile:
f1a75985caa8 first Db test framework - work in progress
am@osimis.io
parents:
diff changeset
75 json.dump(config, fp=configFile, indent=4)