Mercurial > hg > orthanc-tests
annotate PerfsDb/ConfigFileBuilder.py @ 158:df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
author | am@osimis.io |
---|---|
date | Fri, 17 Aug 2018 11:58:26 +0200 |
parents | f1a75985caa8 |
children | 616da104a996 |
rev | line source |
---|---|
156 | 1 import typing |
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 |
156 | 4 |
5 from DbType import DbType | |
6 | |
7 class ConfigFileBuilder: | |
8 | |
9 @staticmethod | |
10 def generate( | |
11 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
|
12 pluginsPath: str, |
156 | 13 storagePath: str, |
14 dbType: DbType, | |
15 dbSize: str, | |
16 port: int | |
17 ): | |
18 | |
19 config = {} | |
20 config["StorageDirectory"] = storagePath | |
21 | |
22 dbConfig = {} | |
23 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
|
24 |
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
25 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
|
26 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
|
27 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
|
28 dbConfig["Port"] = port |
156 | 29 |
30 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
|
31 config["Plugins"] = [os.path.join(pluginsPath, "libOrthancMySQLIndex.so")] |
156 | 32 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
|
33 # 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
|
34 |
156 | 35 dbConfig["Database"] = "orthanc" |
36 dbConfig["Username"] = "orthanc" | |
37 dbConfig["Password"] = "orthanc" | |
38 | |
39 config["MySQL"] = dbConfig | |
40 | |
158
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
41 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
|
42 config["Plugins"] = [os.path.join(pluginsPath, "libOrthancPostgreSQLIndex.so")] |
156 | 43 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
|
44 # 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
|
45 |
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
46 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
|
47 dbConfig["Username"] = "postgres" |
156 | 48 |
49 config["PostgreSQL"] = dbConfig | |
50 | |
51 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
|
52 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
|
53 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
|
54 |
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
55 dbConfig["ConnectionString"] = "Driver={ODBC Driver 13 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 | 56 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 |
57 | |
58 config["MSSQL"] = dbConfig | |
59 | |
158
df1f9946571c
perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
156
diff
changeset
|
60 elif dbType.isSqlite(): |
156 | 61 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
|
62 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
|
63 config["Plugins"] = [os.path.join(pluginsPath, "libOrthancSQLiteIndex.so")] |
156 | 64 |
65 else: | |
66 raise NotImplementedError | |
67 | |
68 with open(outputPath, "w") as configFile: | |
69 json.dump(config, fp=configFile, indent=4) |