Skip to content

Commit ad40c0f

Browse files
authored
Remove using paramiko (#89)
* Remove using paramiko * Up version 1.9.1
1 parent 6cb3a80 commit ad40c0f

File tree

9 files changed

+108
-137
lines changed

9 files changed

+108
-137
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ the configuration file, which means that they should be called before `append_co
176176
### Remote mode
177177
Testgres supports the creation of PostgreSQL nodes on a remote host. This is useful when you want to run distributed tests involving multiple nodes spread across different machines.
178178

179-
To use this feature, you need to use the RemoteOperations class.
179+
To use this feature, you need to use the RemoteOperations class. This feature is only supported with Linux.
180180
Here is an example of how you might set this up:
181181

182182
```python

setup.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"six>=1.9.0",
1313
"psutil",
1414
"packaging",
15-
"paramiko",
1615
"fabric",
1716
"sshtunnel"
1817
]
@@ -30,7 +29,7 @@
3029
readme = f.read()
3130

3231
setup(
33-
version='1.9.0',
32+
version='1.9.1',
3433
name='testgres',
3534
packages=['testgres', 'testgres.operations'],
3635
description='Testing utility for PostgreSQL and its extensions',

testgres/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,16 @@
4646
First, \
4747
Any
4848

49+
from .config import testgres_config
50+
4951
from .operations.os_ops import OsOperations, ConnectionParams
5052
from .operations.local_ops import LocalOperations
5153
from .operations.remote_ops import RemoteOperations
5254

5355
__all__ = [
5456
"get_new_node",
5557
"get_remote_node",
56-
"NodeBackup",
58+
"NodeBackup", "testgres_config",
5759
"TestgresConfig", "configure_testgres", "scoped_config", "push_config", "pop_config",
5860
"NodeConnection", "DatabaseError", "InternalError", "ProgrammingError", "OperationalError",
5961
"TestgresException", "ExecUtilException", "QueryException", "TimeoutException", "CatchUpException", "StartNodeException", "InitNodeException", "BackupException",

testgres/cache.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ def call_initdb(initdb_dir, log=logfile):
5757
# our initdb caching mechanism breaks this contract.
5858
pg_control = os.path.join(data_dir, XLOG_CONTROL_FILE)
5959
system_id = generate_system_id()
60-
os_ops.write(pg_control, system_id, truncate=True, binary=True, read_and_write=True)
60+
cur_pg_control = os_ops.read(pg_control, binary=True)
61+
new_pg_control = system_id + cur_pg_control[len(system_id):]
62+
os_ops.write(pg_control, new_pg_control, truncate=True, binary=True, read_and_write=True)
6163

6264
# XXX: build new WAL segment with our system id
6365
_params = [get_bin_path("pg_resetwal"), "-D", data_dir, "-f"]

testgres/operations/local_ops.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,15 @@ def touch(self, filename):
198198
with open(filename, "a"):
199199
os.utime(filename, None)
200200

201-
def read(self, filename, encoding=None):
202-
with open(filename, "r", encoding=encoding) as file:
203-
return file.read()
201+
def read(self, filename, encoding=None, binary=False):
202+
mode = "rb" if binary else "r"
203+
with open(filename, mode) as file:
204+
content = file.read()
205+
if binary:
206+
return content
207+
if isinstance(content, bytes):
208+
return content.decode(encoding or 'utf-8')
209+
return content
204210

205211
def readlines(self, filename, num_lines=0, binary=False, encoding=None):
206212
"""

0 commit comments

Comments
 (0)