From 553c21f53a29a849f3865ce7514ce2e4ba5a7c1f Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Tue, 2 Jun 2026 11:06:05 +0300 Subject: [PATCH 1/8] cleanup: PostgresNode does not support conn_params at all. PostgresNode::__init__ - [del] argument 'conn_params' Note that it is a critical change. Please remove conn_params=None from your code. --- src/node.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/node.py b/src/node.py index cdf851c3..6fa4fed5 100644 --- a/src/node.py +++ b/src/node.py @@ -101,7 +101,6 @@ from .backup import NodeBackup -from testgres.operations.os_ops import ConnectionParams from testgres.operations.os_ops import OsOperations from testgres.operations.local_ops import LocalOperations @@ -174,7 +173,6 @@ def __init__(self, name=None, base_dir=None, port: typing.Optional[int] = None, - conn_params: typing.Optional[ConnectionParams] = None, bin_dir=None, prefix=None, os_ops: typing.Optional[OsOperations] = None, @@ -194,11 +192,6 @@ def __init__(self, assert os_ops is None or isinstance(os_ops, OsOperations) assert port_manager is None or isinstance(port_manager, PortManager) - if conn_params is not None: - assert type(conn_params) is ConnectionParams - - raise InvalidOperationException("conn_params is deprecated, please use os_ops parameter instead.") - # private if os_ops is None: self._os_ops = __class__._get_os_ops() From d809f9972e42f2e239fef3e35472af9aeaf7f19c Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Tue, 2 Jun 2026 12:53:25 +0300 Subject: [PATCH 2/8] get_remote_node is fixed and mark as deprecated --- README.md | 5 +---- docs/source/index.rst | 3 --- src/api.py | 15 +++++++++++++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 99ea468a..617453e2 100644 --- a/README.md +++ b/README.md @@ -152,16 +152,13 @@ with testgres.get_new_node().init() as master: You can provision nodes on a remote host (Linux only) by wiring `RemoteOperations` into the configuration: ```python -from testgres import ConnectionParams, RemoteOperations, TestgresConfig, get_remote_node +from testgres import ConnectionParams, get_remote_node conn_params = ConnectionParams( host='example.com', username='postgres', ssh_key='/path/to/ssh/key' ) -os_ops = RemoteOperations(conn_params) - -TestgresConfig.set_os_ops(os_ops=os_ops) def test_basic_query(): with get_remote_node(conn_params=conn_params) as node: diff --git a/docs/source/index.rst b/docs/source/index.rst index c2104a65..d44dcf19 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -165,9 +165,6 @@ Provision nodes on a remote host (Linux only) by wiring ``RemoteOperations`` int username='postgres', ssh_key='/path/to/ssh/key' ) - os_ops = RemoteOperations(conn_params) - - TestgresConfig.set_os_ops(os_ops=os_ops) def test_basic_query(): with get_remote_node(conn_params=conn_params) as node: diff --git a/src/api.py b/src/api.py index 6a96ee84..d4b565fc 100644 --- a/src/api.py +++ b/src/api.py @@ -31,6 +31,10 @@ [(3,)] """ from .node import PostgresNode +from testgres.operations.remote_ops import ConnectionParams +from testgres.operations.remote_ops import RemoteOperations + +import typing def get_new_node(name=None, base_dir=None, **kwargs): @@ -42,11 +46,18 @@ def get_new_node(name=None, base_dir=None, **kwargs): return PostgresNode(name=name, base_dir=base_dir, **kwargs) -def get_remote_node(name=None, conn_params=None): +def get_remote_node(name=None, conn_params: typing.Optional[ConnectionParams] = None): """ + NOTE: [2026-06-02][v1.14.0] It is deprecated function. It will be removed in the future. + Simply a wrapper around :class:`.PostgresNode` constructor for remote node. See :meth:`.PostgresNode.__init__` for details. For remote connection you can add the next parameter: conn_params = ConnectionParams(host='127.0.0.1', ssh_key=None, username=default_username()) """ - return get_new_node(name=name, conn_params=conn_params) + + if conn_params is None: + raise ValueError("Argument 'conn_params' is None.") + + os_ops = RemoteOperations(conn_params) + return get_new_node(name=name, os_ops=os_ops) From 057a7ed8ae2a8e2446df6920b7a4d1102b93ae39 Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Tue, 2 Jun 2026 12:56:54 +0300 Subject: [PATCH 3/8] tests/README.md is updated --- tests/README.md | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/tests/README.md b/tests/README.md index d89efc7e..233eb012 100644 --- a/tests/README.md +++ b/tests/README.md @@ -7,6 +7,8 @@ virtualenv venv source venv/bin/activate +pip install -r tests/requirements.txt + # Install local version of testgres pip install -U . @@ -14,7 +16,7 @@ pip install -U . export PG_BIN=/path/to/pg/bin # Run tests -./tests/test_simple.py +pytest -l -v -n 4 tests ``` #### All configurations + coverage @@ -22,37 +24,10 @@ export PG_BIN=/path/to/pg/bin ```bash # Set path to PostgreSQL and python version export PATH=/path/to/pg/bin:$PATH -export PYTHON_VERSION=3 # or 2 + +# Set path of python binary +export PYTHON_BINARY=python3 # Run tests ./run_tests.sh ``` - - -#### Remote host tests - -1. Start remote host or docker container -2. Make sure that you run ssh -```commandline -sudo apt-get install openssh-server -sudo systemctl start sshd -``` -3. You need to connect to the remote host at least once to add it to the known hosts file -4. Generate ssh keys -5. Set up params for tests - - -```commandline -conn_params = ConnectionParams( - host='remote_host', - username='username', - ssh_key=/path/to/your/ssh/key' -) -os_ops = RemoteOperations(conn_params) -``` -If you have different path to `PG_CONFIG` on your local and remote host you can set up `PG_CONFIG_REMOTE`, this value will be -using during work with remote host. - -`test_remote` - Tests for RemoteOperations class. - -`test_simple_remote` - Tests that create node and check it. The same as `test_simple`, but for remote node. \ No newline at end of file From a676191a046679c4f74b186b930d486af1ed4a7a Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Tue, 2 Jun 2026 12:58:19 +0300 Subject: [PATCH 4/8] NodeBackup::spawn_primary creates a clone via clone_with_new_name_and_base_dir --- src/backup.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/backup.py b/src/backup.py index 6b1b1bc6..d91db5a0 100644 --- a/src/backup.py +++ b/src/backup.py @@ -152,12 +152,7 @@ def spawn_primary(self, name=None, destroy=True): # Build a new PostgresNode assert self.original_node is not None - if (hasattr(self.original_node, "clone_with_new_name_and_base_dir")): - node = self.original_node.clone_with_new_name_and_base_dir(name=name, base_dir=base_dir) - else: - # For backward compatibility - NodeClass = self.original_node.__class__ - node = NodeClass(name=name, base_dir=base_dir, conn_params=self.original_node.os_ops.conn_params) + node = self.original_node.clone_with_new_name_and_base_dir(name=name, base_dir=base_dir) assert node is not None assert type(node) is self.original_node.__class__ From e6f4127ccc37798d24146a9c90dc44681f337ce8 Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Tue, 2 Jun 2026 13:03:38 +0300 Subject: [PATCH 5/8] tests/README.md is corrected --- tests/README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/README.md b/tests/README.md index 233eb012..66952854 100644 --- a/tests/README.md +++ b/tests/README.md @@ -9,9 +9,6 @@ source venv/bin/activate pip install -r tests/requirements.txt -# Install local version of testgres -pip install -U . - # Set path to PostgreSQL export PG_BIN=/path/to/pg/bin From 7f2c97f8227899b11dab559ecbdd81b79d8f5b4c Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Tue, 2 Jun 2026 13:31:24 +0300 Subject: [PATCH 6/8] get_remote_node is undeprecated (it is not our business) --- src/api.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/api.py b/src/api.py index d4b565fc..aae6ce2a 100644 --- a/src/api.py +++ b/src/api.py @@ -48,8 +48,6 @@ def get_new_node(name=None, base_dir=None, **kwargs): def get_remote_node(name=None, conn_params: typing.Optional[ConnectionParams] = None): """ - NOTE: [2026-06-02][v1.14.0] It is deprecated function. It will be removed in the future. - Simply a wrapper around :class:`.PostgresNode` constructor for remote node. See :meth:`.PostgresNode.__init__` for details. For remote connection you can add the next parameter: From 27eb96b447c18ed49cbe1fceb98ba4bf6abff44a Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Tue, 2 Jun 2026 17:53:05 +0300 Subject: [PATCH 7/8] README.md is restored (it is not our business) --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 617453e2..99ea468a 100644 --- a/README.md +++ b/README.md @@ -152,13 +152,16 @@ with testgres.get_new_node().init() as master: You can provision nodes on a remote host (Linux only) by wiring `RemoteOperations` into the configuration: ```python -from testgres import ConnectionParams, get_remote_node +from testgres import ConnectionParams, RemoteOperations, TestgresConfig, get_remote_node conn_params = ConnectionParams( host='example.com', username='postgres', ssh_key='/path/to/ssh/key' ) +os_ops = RemoteOperations(conn_params) + +TestgresConfig.set_os_ops(os_ops=os_ops) def test_basic_query(): with get_remote_node(conn_params=conn_params) as node: From 4ca09e301382a0a4c8f60619ee8fbb3f3a5d8496 Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Tue, 2 Jun 2026 18:26:36 +0300 Subject: [PATCH 8/8] index.rst is restored (it is not our business) --- docs/source/index.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/source/index.rst b/docs/source/index.rst index d44dcf19..c2104a65 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -165,6 +165,9 @@ Provision nodes on a remote host (Linux only) by wiring ``RemoteOperations`` int username='postgres', ssh_key='/path/to/ssh/key' ) + os_ops = RemoteOperations(conn_params) + + TestgresConfig.set_os_ops(os_ops=os_ops) def test_basic_query(): with get_remote_node(conn_params=conn_params) as node: