10000 TestTestgresCommon - unified tests for local and remote by dmitry-lipetsk · Pull Request #216 · postgrespro/testgres · GitHub
[go: up one dir, main page]

Skip to content

TestTestgresCommon - unified tests for local and remote #216

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

Closed
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5488ecd
TestTestgresCommon - unified tests for local and remote
dmitry-lipetsk Mar 12, 2025
a6edd3a
TestTestgresCommon is updated
dmitry-lipetsk Mar 12, 2025
3c055af
TestTestgresCommon is updated
dmitry-lipetsk Mar 13, 2025
188b3b2
TestTestgresCommon is updated
dmitry-lipetsk Mar 13, 2025
9b137ca
Merge branch 'master' into D20250312_002--TestTestgresCommon
dmitry-lipetsk Mar 13, 2025
9bddc3b
Merge branch 'master' into D20250312_002--TestTestgresCommon
dmitry-lipetsk Mar 14, 2025
75f0326
Merge branch 'master' into D20250312_002--TestTestgresCommon
dmitry-lipetsk Mar 16, 2025
292b403
TestTestgresCommon is updated
dmitry-lipetsk Mar 16, 2025
0fb22e8
PostgresNode_Base is added
dmitry-lipetsk Mar 16, 2025
2e5bd9d
test_simple_remote.py is cleaned
dmitry-lipetsk Mar 16, 2025
7f89186
Merge branch 'master' into D20250312_002--TestTestgresCommon
dmitry-lipetsk Mar 16, 2025
48fd887
Formatting (flake8)
dmitry-lipetsk Mar 16, 2025
bf28a1a
Formatting
dmitry-lipetsk Mar 17, 2025
f64dd60
PostgresNode_Base is updated (documentation)
dmitry-lipetsk Mar 17, 2025
490130e
PostgresNode is updated (documentation)
dmitry-lipetsk Mar 17, 2025
ff9b7bc
PostgresNode_Base::_prefix is removed
dmitry-lipetsk Mar 17, 2025
9e1979f
PostgresNode::clean is corrected
dmitry-lipetsk Mar 17, 2025
3e9cad1
node_base.py is updated
dmitry-lipetsk Mar 17, 2025
12fa7f2
node_base.py is updated
dmitry-lipetsk Mar 17, 2025
cef7982
node.py is updated
dmitry-lipetsk Mar 17, 2025
61feb2c
NodeApp::make_empty is updated
dmitry-lipetsk Mar 17, 2025
84a51c7
PostgresNode::cleanup is fixed
dmitry-lipetsk Mar 17, 2025
f7f915d
PostgresNode::cleanup is updated (flake8)
dmitry-lipetsk Mar 17, 2025
882b8ec
PostgresNode_Base::clone_with_new_name_and_base_dir is added
dmitry-lipetsk Mar 17, 2025
e8e392e
PostgresNode is updated (comment)
dmitry-lipetsk Mar 17, 2025
06287f2
Merge remote-tracking branch 'origin/D20250316_003--PostgresNode_Base…
dmitry-lipetsk Mar 17, 2025
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
Prev Previous commit
Next Next commit
node_base.py is updated
Names from 'consts' module are used explicitly.
  • Loading branch information
dmitry-lipetsk committed Mar 17, 2025
commit 12fa7f278958342214481ecdbd7c779a5ad68d30
58 changes: 21 additions & 37 deletions testgres/node_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,7 @@

from .connection import NodeConnection

from .consts import \
TMP_DUMP, \
PG_CONF_FILE, \
PG_AUTO_CONF_FILE, \
HBA_CONF_FILE, \
RECOVERY_CONF_FILE, \
PG_CTL__STATUS__OK, \
PG_CTL__STATUS__NODE_IS_STOPPED, \
PG_CTL__STATUS__BAD_DATADIR \

from .consts import \
MAX_LOGICAL_REPLICATION_WORKERS, \
MAX_REPLICATION_SLOTS, \
MAX_WORKER_PROCESSES, \
MAX_WAL_SENDERS, \
WAL_KEEP_SEGMENTS, \
WAL_KEEP_SIZE
from . import consts

from .decorators import \
method_decorator, \
Expand Down Expand Up @@ -205,15 +189,15 @@ def pid(self):
assert type(error) == str # noqa: E721

# -----------------
if status_code == PG_CTL__STATUS__NODE_IS_STOPPED:
if status_code == consts.PG_CTL__STATUS__NODE_IS_STOPPED:
return 0

# -----------------
if status_code == PG_CTL__STATUS__BAD_DATADIR:
if status_code == consts.PG_CTL__STATUS__BAD_DATADIR:
return 0

# -----------------
if status_code != PG_CTL__STATUS__OK:
if status_code != consts.PG_CTL__STATUS__OK:
errMsg = "Getting of a node status [data_dir is {0}] failed.".format(self__data_dir)

raise ExecUtilException(
Expand All @@ -225,7 +209,7 @@ def pid(self):
)

# -----------------
assert status_code == PG_CTL__STATUS__OK
assert status_code == consts.PG_CTL__STATUS__OK

if out == "":
__class__._throw_error__pg_ctl_returns_an_empty_string(
Expand Down Expand Up @@ -568,7 +552,7 @@ def _create_recovery_conf(self, username, slot=None):
if self.version >= utils.PgVer('12'):
self.append_conf(line=line)
else:
self.append_conf(filename=RECOVERY_CONF_FILE, line=line)
self.append_conf(filename=consts.RECOVERY_CONF_FILE, line=line)

def _maybe_start_logger(self):
if testgres_config.use_python_logging:
Expand All @@ -586,10 +570,10 @@ def _collect_special_files(self):

# list of important files + last N lines
files = [
(os.path.join(self.data_dir, PG_CONF_FILE), 0),
(os.path.join(self.data_dir, PG_AUTO_CONF_FILE), 0),
(os.path.join(self.data_dir, RECOVERY_CONF_FILE), 0),
(os.path.join(self.data_dir, HBA_CONF_FILE), 0),
(os.path.join(self.data_dir, consts.PG_CONF_FILE), 0),
(os.path.join(self.data_dir, consts.PG_AUTO_CONF_FILE), 0),
(os.path.join(self.data_dir, consts.RECOVERY_CONF_FILE), 0),
(os.path.join(self.data_dir, consts.HBA_CONF_FILE), 0),
(self.pg_log_file, testgres_config.error_log_lines)
] # yapf: disable

Expand Down Expand Up @@ -676,8 +660,8 @@ def default_conf(self,
This instance of :class:`.PostgresNode_Base`.
"""

postgres_conf = os.path.join(self.data_dir, PG_CONF_FILE)
hba_conf = os.path.join(self.data_dir, HBA_CONF_FILE)
postgres_conf = os.path.join(self.data_dir, consts.PG_CONF_FILE)
hba_conf = os.path.join(self.data_dir, consts.HBA_CONF_FILE)

# filter lines in hba file
# get rid of comments and blank lines
Expand Down Expand Up @@ -719,15 +703,15 @@ def get_auth_method(t):
self._os_ops.write(postgres_conf, '', truncate=True)

self.append_conf(fsync=fsync,
max_worker_processes=MAX_WORKER_PROCESSES,
max_worker_processes=consts.MAX_WORKER_PROCESSES,
log_statement=log_statement,
listen_addresses=self.host,
port=self.port) # yapf:disable

# common replication settings
if allow_streaming or allow_logical:
self.append_conf(max_replication_slots=MAX_REPLICATION_SLOTS,
max_wal_senders=MAX_WAL_SENDERS) # yapf: disable
self.append_conf(max_replication_slots=consts.MAX_REPLICATION_SLOTS,
max_wal_senders=consts.MAX_WAL_SENDERS) # yapf: disable
D23E
# binary replication
if allow_streaming:
Expand All @@ -736,11 +720,11 @@ def get_auth_method(t):

if self._pg_version < utils.PgVer('13'):
self.append_conf(hot_standby=True,
wal_keep_segments=WAL_KEEP_SEGMENTS,
wal_keep_segments=consts.WAL_KEEP_SEGMENTS,
wal_level=wal_level) # yapf: disable
else:
self.append_conf(hot_standby=True,
wal_keep_size=WAL_KEEP_SIZE,
wal_keep_size=consts.WAL_KEEP_SIZE,
wal_level=wal_level) # yapf: disable

# logical replication
Expand All @@ -750,7 +734,7 @@ def get_auth_method(t):
"available on PostgreSQL 10 and newer")

self.append_conf(
max_logical_replication_workers=MAX_LOGICAL_REPLICATION_WORKERS,
max_logical_replication_workers=consts.MAX_LOGICAL_REPLICATION_WORKERS,
wal_level='logical')

# disable UNIX sockets if asked to
Expand All @@ -760,7 +744,7 @@ def get_auth_method(t):
return self

@method_decorator(positional_args_hack(['filename', 'line']))
def append_conf(self, line='', filename=PG_CONF_FILE, **kwargs):
def append_conf(self, line='', filename=consts.PG_CONF_FILE, **kwargs):
"""
Append line to a config file.

Expand Down Expand Up @@ -1339,9 +1323,9 @@ def dump(self,
# Generate tmpfile or tmpdir
def tmpfile():
if format == DumpFormat.Directory:
fname = self._os_ops.mkdtemp(prefix=TMP_DUMP)
fname = self._os_ops.mkdtemp(prefix=consts.TMP_DUMP)
else:
fname = self._os_ops.mkstemp(prefix=TMP_DUMP)
fname = self._os_ops.mkstemp(prefix=consts.TMP_DUMP)
return fname

filename = filename or tmpfile()
Expand Down
0