comparison PerfsDb/TestConfig.py @ 160:6995d5d12d88

filtering tests
author am@osimis.io
date Fri, 17 Aug 2018 16:17:57 +0200
parents df1f9946571c
children 27b3b0df5f90
comparison
equal deleted inserted replaced
159:616da104a996 160:6995d5d12d88
21 dbServer: DbServer=None 21 dbServer: DbServer=None
22 ): 22 ):
23 23
24 self._dbSize = dbSize 24 self._dbSize = dbSize
25 self._dbServer = dbServer 25 self._dbServer = dbServer
26 self._label = label 26 self.label = label
27 self._port = None 27 self._port = None
28 self._name = "unknown"
29 self._orthancProcess = None 28 self._orthancProcess = None
30 self._repeatCount = 10 29 self._repeatCount = 10
31 30
32 if dbServer is not None: 31 if dbServer is not None:
33 self._dbType = dbServer.dbType 32 self._dbType = dbServer.dbType
34 self._dbServer.setLabel(self._label) 33 self._dbServer.setLabel(self.label)
35 self._port = dbServer.port 34 self._port = dbServer.port
36 else: 35 else:
37 self._dbType = dbType 36 self._dbType = dbType
38
39 def setName(self, name: str):
40 self._name = name
41 37
42 def setRepeatCount(self, repeatCount: int): 38 def setRepeatCount(self, repeatCount: int):
43 self._repeatCount = repeatCount 39 self._repeatCount = repeatCount
44 40
45 def launchDbServer(self): 41 def launchDbServer(self):
55 return False 51 return False
56 52
57 print("Launching Orthanc") 53 print("Launching Orthanc")
58 self._orthancProcess = subprocess.Popen([ 54 self._orthancProcess = subprocess.Popen([
59 os.path.join(orthancPath, "Orthanc"), 55 os.path.join(orthancPath, "Orthanc"),
60 os.path.join(os.path.abspath(os.path.dirname(__file__)), "ConfigFiles", self._name + ".json"), 56 os.path.join(os.path.abspath(os.path.dirname(__file__)), "ConfigFiles", self.label + ".json"),
61 ]) 57 ])
62 58
63 print("Waiting for Orthanc to start") 59 print("Waiting for Orthanc to start")
64 orthanc.waitStarted(timeout=30) 60 orthanc.waitStarted(timeout=30)
65 print("Orthanc has started") 61 print("Orthanc has started")
72 68
73 def initializeDb(self): 69 def initializeDb(self):
74 dbPopulator = DbPopulator(orthanc=OrthancClient("http://127.0.0.1:8042"), dbSize=self._dbSize) 70 dbPopulator = DbPopulator(orthanc=OrthancClient("http://127.0.0.1:8042"), dbSize=self._dbSize)
75 dbPopulator.populate() 71 dbPopulator.populate()
76 72
77 def runTests(self) -> typing.List[TestResult]: 73 def runTests(self, tests: typing.List[Test]) -> typing.List[TestResult]:
78 allTests = [
79 TestStatistics(),
80 TestFindStudyByStudyDescription1Result(),
81 TestFindStudyByPatientId1Result(),
82 TestFindStudyByStudyDescription0Results(),
83 TestFindStudyByPatientId0Results(),
84 TestFindStudyByPatientId5Results(),
85 TestUploadFile(),
86 ]
87 74
88 results = [] 75 results = []
89 for test in allTests: 76 for test in tests:
90 test.setOrthancClient(OrthancClient("http://127.0.0.1:8042")) 77 test.setOrthancClient(OrthancClient("http://127.0.0.1:8042"))
91 test.setRepeatCount(self._repeatCount) 78 test.setRepeatCount(self._repeatCount)
92 result = test.run() 79 result = test.run()
93 print(str(result)) 80 print(str(result))
94 81
98 def clearDb(self): 85 def clearDb(self):
99 if self._dbServer is not None: 86 if self._dbServer is not None:
100 self._dbServer.clear() 87 self._dbServer.clear()
101 88
102 # clear storage (in case of Sqlite DB, it will also clear the DB) 89 # clear storage (in case of Sqlite DB, it will also clear the DB)
103 shutil.rmtree(os.path.join(os.path.abspath(os.path.dirname(__file__)), "Storages/{name}".format(name=self._name)), ignore_errors=True) 90 shutil.rmtree(os.path.join(os.path.abspath(os.path.dirname(__file__)), "Storages/{name}".format(name=self.label)), ignore_errors=True)
104 91
105 def generateOrthancConfigurationFile(self, pluginsPath: str): 92 def generateOrthancConfigurationFile(self, pluginsPath: str):
106 93
107 ConfigFileBuilder.generate( 94 ConfigFileBuilder.generate(
108 outputPath=os.path.join(os.path.abspath(os.path.dirname(__file__)), "ConfigFiles/{name}.json".format(name=self._name)), 95 outputPath=os.path.join(os.path.abspath(os.path.dirname(__file__)), "ConfigFiles/{name}.json".format(name=self.label)),
109 pluginsPath=pluginsPath, 96 pluginsPath=pluginsPath,
110 storagePath=os.path.join(os.path.abspath(os.path.dirname(__file__)), "Storages/{name}".format(name=self._name)), 97 storagePath=os.path.join(os.path.abspath(os.path.dirname(__file__)), "Storages/{name}".format(name=self.label)),
111 dbType=self._dbType, 98 dbType=self._dbType,
112 dbSize=self._dbSize, 99 dbSize=self._dbSize,
113 port=self._port 100 port=self._port
114 ) 101 )