Skip to content

Remove using paramiko #89

New issue

Have a question about this project? Sign up for a free account to open an issue and contact its maintainers and the community.

By clicking “Sign up for ”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on ? Sign in to your account

Merged
merged 4 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -176,7 +176,7 @@ the configuration file, which means that they should be called before `append_co
### Remote mode
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.

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

```python
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,6 @@
"six>=1.9.0",
"psutil",
"packaging",
"paramiko",
"fabric",
"sshtunnel"
]
Expand All@@ -30,7 +29,7 @@
readme = f.read()

setup(
version='1.9.0',
version='1.9.1',
name='testgres',
packages=['testgres', 'testgres.operations'],
description='Testing utility for PostgreSQL and its extensions',
Expand Down
4 changes: 3 additions & 1 deletion testgres/__init__.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,14 +46,16 @@
First, \
Any

from .config import testgres_config

from .operations.os_ops import OsOperations, ConnectionParams
from .operations.local_ops import LocalOperations
from .operations.remote_ops import RemoteOperations

__all__ = [
"get_new_node",
"get_remote_node",
"NodeBackup",
"NodeBackup", "testgres_config",
"TestgresConfig", "configure_testgres", "scoped_config", "push_config", "pop_config",
"NodeConnection", "DatabaseError", "InternalError", "ProgrammingError", "OperationalError",
"TestgresException", "ExecUtilException", "QueryException", "TimeoutException", "CatchUpException", "StartNodeException", "InitNodeException", "BackupException",
Expand Down
4 changes: 3 additions & 1 deletion testgres/cache.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,7 +57,9 @@ def call_initdb(initdb_dir, log=logfile):
# our initdb caching mechanism breaks this contract.
pg_control = os.path.join(data_dir, XLOG_CONTROL_FILE)
system_id = generate_system_id()
os_ops.write(pg_control, system_id, truncate=True, binary=True, read_and_write=True)
cur_pg_control = os_ops.read(pg_control, binary=True)
new_pg_control = system_id + cur_pg_control[len(system_id):]
os_ops.write(pg_control, new_pg_control, truncate=True, binary=True, read_and_write=True)

# XXX: build new WAL segment with our system id
_params = [get_bin_path("pg_resetwal"), "-D", data_dir, "-f"]
Expand Down
12 changes: 9 additions & 3 deletions testgres/operations/local_ops.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -198,9 +198,15 @@ def touch(self, filename):
with open(filename, "a"):
os.utime(filename, None)

def read(self, filename, encoding=None):
with open(filename, "r", encoding=encoding) as file:
return file.read()
def read(self, filename, encoding=None, binary=False):
mode = "rb" if binary else "r"
with open(filename, mode) as file:
content = file.read()
if binary:
return content
if isinstance(content, bytes):
return content.decode(encoding or 'utf-8')
return content

def readlines(self, filename, num_lines=0, binary=False, encoding=None):
"""
Expand Down
Loading