We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parentf131088 commit4f38bd5Copy full SHA for 4f38bd5
testgres/cache.py
@@ -39,7 +39,7 @@ def call_initdb(initdb_dir, log=None):
39
call_initdb(data_dir,logfile)
40
else:
41
# Fetch cached initdb dir
42
-cached_data_dir=testgres_config.cached_initdb_dir
+cached_data_dir=testgres_config.cached_initdb_dir()
43
44
# Initialize cached initdb
45
testgres/config.py
@@ -55,12 +55,6 @@ def cached_initdb_dir(self):
55
defcached_initdb_dir(self,value):
56
self._cached_initdb_dir=value
57
58
-# NOTE: assign initial cached dir for initdb
59
-ifself.os_ops:
60
-testgres_config.cached_initdb_dir=self.os_ops.mkdtemp(prefix=TMP_CACHE)
61
-else:
62
-testgres_config.cached_initdb_dir=mkdtemp(prefix=TMP_CACHE)
63
-
64
ifvalue:
65
cached_initdb_dirs.add(value)
66
returntestgres_config.cached_initdb_dir
@@ -208,3 +202,7 @@ def configure_testgres(**options):
208
202
"""
209
203
210
204
testgres_config.update(options)
205
+
206
207
+# NOTE: assign initial cached dir for initdb
+testgres_config.cached_initdb_dir=mkdtemp(prefix=TMP_CACHE)
testgres/connection.py
@@ -42,8 +42,7 @@ def __init__(self,
self._node=node
-self.os_ops=OsOperations(node.host,node.hostname,node.ssh_key,node.username)
46
-self._connection=self.os_ops.db_connect(dbname=dbname,
+self._connection=node.os_ops.db_connect(dbname=dbname,
47
user=username,
48
password=password,
49
host=node.host,
testgres/os_ops.py
@@ -262,32 +262,25 @@ def get_user(self):
262
user=getpass.getuser()
263
returnuser
264
265
-@contextmanager
266
defdb_connect(self,dbname,user,password=None,host='localhost',port=5432):
267
ifself.remote:
268
-withself.ssh_connect()asssh:
269
-# Set up a local port forwarding on a random port
270
-local_port=ssh.forward_remote_port(host,port)
271
-conn=pglib.connect(
272
-host=host,
273
-port=local_port,
274
-dbname=dbname,
275
-user=user,
276
-password=password,
277
- )
278
-try:
279
-yieldconn
280
-finally:
281
-conn.close()
282
-ssh.close_forwarded_tcp(local_port)
+local_port=self.ssh.forward_remote_port(host,port)
+conn=pglib.connect(
+host=host,
+port=local_port,
+dbname=dbname,
+user=user,
+password=password,
+ )
283
284
-withpglib.connect(
285
host=host,
286
port=port,
287
dbname=dbname,
288
user=user,
289
290
- )asconn:
291
+returnconn
292
293