Skip to content

Pass a DB port to NodeApp #132

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2024
Merged
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
12 changes: 7 additions & 5 deletions testgres/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def __repr__(self):


class PostgresNode(object):
def __init__(self, name=None, port=None, base_dir=None, conn_params: ConnectionParams = ConnectionParams(), bin_dir=None, prefix=None):
def __init__(self, name=None, base_dir=None, port=None, conn_params: ConnectionParams = ConnectionParams(), bin_dir=None, prefix=None):
"""
PostgresNode constructor.

Expand Down Expand Up @@ -156,9 +156,9 @@ def __init__(self, name=None, port=None, base_dir=None, conn_params: ConnectionP
else:
self.os_ops = LocalOperations(conn_params)

self.host = self.os_ops.host
self.port = port or reserve_port()

self.host = self.os_ops.host
self.ssh_key = self.os_ops.ssh_key

# defaults for __exit__()
Expand Down Expand Up @@ -1690,12 +1690,13 @@ def __init__(self, test_path, nodes_to_cleanup, os_ops=LocalOperations()):

def make_empty(
self,
base_dir=None):
base_dir=None,
port=None):
real_base_dir = os.path.join(self.test_path, base_dir)
self.os_ops.rmdirs(real_base_dir, ignore_errors=True)
self.os_ops.makedirs(real_base_dir)

node = PostgresNode(base_dir=real_base_dir)
node = PostgresNode(base_dir=real_base_dir, port=port)
node.should_rm_dirs = True
self.nodes_to_cleanup.append(node)

Expand All @@ -1704,14 +1705,15 @@ def make_empty(
def make_simple(
self,
base_dir=None,
port=None,
set_replication=False,
ptrack_enable=False,
initdb_params=[],
pg_options={},
checksum=True):
if checksum and '--data-checksums' not in initdb_params:
initdb_params.append('--data-checksums')
node = self.make_empty(base_dir)
node = self.make_empty(base_dir, port)
node.init(
initdb_params=initdb_params, allow_streaming=set_replication)

Expand Down