comparison PerfsDb/DbServer.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 dbc42a03ee75
comparison
equal deleted inserted replaced
157:ac14100ffbd7 158:df1f9946571c
24 self._label = None 24 self._label = None
25 25
26 def setLabel(self, label: str): 26 def setLabel(self, label: str):
27 self._label = label 27 self._label = label
28 28
29 def launch(self): 29 def isRunning(self) -> bool:
30 dockerDefinition = self.getDockerDefinition()
31
32 # check if the container is already running
33 ret = subprocess.call([ 30 ret = subprocess.call([
34 "docker", 31 "docker",
35 "top", 32 "top",
36 self._label 33 self._label
37 ]) 34 ])
38 if ret == 0: 35 return ret == 0
36
37 def launch(self):
38 dockerDefinition = self.getDockerDefinition()
39
40 # check if the container is already running
41 if self.isRunning():
39 print("DbServer is already running") 42 print("DbServer is already running")
40 return 43 return
41 44
42 # create a volume (if it already exists, it wont be modified) 45 # create a volume (if it already exists, it wont be modified)
43 subprocess.check_call([ 46 subprocess.check_call([
83 if retryCounter >= 30: 86 if retryCounter >= 30:
84 print("DbServer still not ready after 30 sec") 87 print("DbServer still not ready after 30 sec")
85 raise TimeoutError 88 raise TimeoutError
86 89
87 def stop(self): 90 def stop(self):
88 subprocess.check_call([ 91 if self.isRunning():
89 "docker", 92 subprocess.check_call([
90 "stop", 93 "docker",
91 self._label 94 "stop",
92 ]) 95 self._label
93 subprocess.check_call([ 96 ])
97
98 subprocess.call([
94 "docker", 99 "docker",
95 "rm", 100 "rm",
96 self._label 101 self._label
97 ]) 102 ])
98 103
99 def clear(self): 104 def clear(self):
100 # remove the volume 105 # remove the volume
101 self.stop() 106 self.stop()
102 subprocess.check_call([ 107 subprocess.call([
103 "docker", 108 "docker",
104 "volume", 109 "volume",
105 "rm", 110 "rm",
106 self._label 111 self._label
107 ]) 112 ])
129 "ACCEPT_EULA": "Y", 134 "ACCEPT_EULA": "Y",
130 "SA_PASSWORD": "MyStrOngPa55word!" 135 "SA_PASSWORD": "MyStrOngPa55word!"
131 }, 136 },
132 storagePath="/var/opt/mssql/data" 137 storagePath="/var/opt/mssql/data"
133 ) 138 )
134 elif self.dbType == DbType.PG9 or self.dbType == DbType.PG10: 139 elif self.dbType == DbType.PG9 or self.dbType == DbType.PG10 or self.dbType == DbType.PG11:
135 if self.dbType == DbType.PG9: 140 if self.dbType == DbType.PG9:
136 image = "postgres:9" 141 image = "postgres:9"
137 elif self.dbType == DbType.PG10: 142 elif self.dbType == DbType.PG10:
138 image = "postgres:10" 143 image = "postgres:10"
144 elif self.dbType == DbType.PG11:
145 image = "postgres:11"
139 return DbServer.DockerDefinition( 146 return DbServer.DockerDefinition(
140 image=image, 147 image=image,
141 internalPort=5432, 148 internalPort=5432,
142 envVars={ 149 envVars={
143 }, 150 },