Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
64b9079
NodeApp::_paramlist_append is updated (pylance)
dmitry-lipetsk Nov 23, 2026
6f971ed
PostgresNode::source_walsender is updated
dmitry-lipetsk Nov 23, 2026
2e7a525
PostgresNode::_try_shutdown_internal is updated
dmitry-lipetsk Nov 23, 2026
9e0c06b
fix: TestTestgresCommon::tag_rmdirs_protector::proxy__rmdirs is corre…
dmitry-lipetsk Nov 23, 2026
528e916
TestOsOpsCommon::test_popen_garbage_collection is updated (pylance)
dmitry-lipetsk Nov 23, 2026
041d3d2
misc (formatting)
dmitry-lipetsk Nov 23, 2026
8838cd2
TestTestgresCommon::test_pgbench is updated (pyright, asserts)
dmitry-lipetsk Nov 23, 2026
43a7058
TestTestgresCommon::test_poll_query_until is updated (formatting)
dmitry-lipetsk Nov 23, 2026
2fb4241
fix: (node::poll_query_until) expected has type typing.Any (pylance)
dmitry-lipetsk Nov 23, 2026
f4edcf4
TestTestgresCommon::test_init_unique_system_id is updated/corrected (…
dmitry-lipetsk Nov 23, 2026
e980ad0
TestTestgresCommon::test_custom_init__hba is updated (pyright)
dmitry-lipetsk Nov 23, 2026
4fcec6f
Merge branch 'master' into D20261123_001--refactoring
dmitry-lipetsk Nov 23, 2026
6d814ee
fix: (PostgresNode::poll_query_until) type of 'suppress' is fixed
dmitry-lipetsk Nov 23, 2026
6cdc8df
NodeApp::make_simple is updated (pylance)
dmitry-lipetsk Nov 23, 2026
b551682
cached_initdb is updated (pylance, asserts)
dmitry-lipetsk Nov 23, 2026
684e7d1
safe_psql overloads are added (pylance)
dmitry-lipetsk Nov 23, 2026
8d5e7c3
fix: PortManager__Generic::_guard has type typing.Any (pylance)
dmitry-lipetsk Nov 23, 2026
5274ce9
NodeConnection::begin is updated (T_ISOLATIONLEVEL_OR_STR)
dmitry-lipetsk Nov 23, 2026
f894540
test_testgres_remote::util_exists is updated (pylance)
dmitry-lipetsk Nov 23, 2026
b046649
test_testgres_local::test_upgrade_node is updated (+assert)
dmitry-lipetsk Nov 23, 2026
8e4c43b
test_file_line_reader::helper__player is corrected
dmitry-lipetsk Nov 23, 2026
9417bd5
test_testgres_common is updated (pylance)
dmitry-lipetsk Nov 23, 2026
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
3 changes: 3 additions & 0 deletions src/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def call_initdb(initdb_dir, log=logfile):
cached_data_dir = testgres_config.cached_initdb_dir

# Initialize cached initdb
assert cached_data_dir is not None

if not os_ops.path_exists(cached_data_dir) or \
not os_ops.listdir(cached_data_dir):
Expand All @@ -82,6 +83,8 @@ def call_initdb(initdb_dir, log=logfile):
pg_control = os_ops.build_path(data_dir, XLOG_CONTROL_FILE)
system_id = generate_system_id()
cur_pg_control = os_ops.read(pg_control, binary=True)
assert cur_pg_control is not None
assert type(cur_pg_control) is bytes
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)

Expand Down
7 changes: 6 additions & 1 deletion src/impl/connection_psycopg2.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ def __exit__(self, type, value, traceback):
self.close()
return

def begin(self, isolation_level=IsolationLevel.ReadCommitted):
T_ISOLATIONLEVEL_OR_STR = typing.Union[IsolationLevel, str]

def begin(
self,
isolation_level: T_ISOLATIONLEVEL_OR_STR = IsolationLevel.ReadCommitted,
):
# Check if level isn't an IsolationLevel
if not isinstance(isolation_level, IsolationLevel):
# Get name of isolation level
Expand Down
2 changes: 1 addition & 1 deletion src/impl/port_manager__generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PortManager__Generic(PortManager):
_C_MAX_PORT_NUMBER = 65535

_os_ops: OsOperations
_guard: object
_guard: typing.Any
# TODO: is there better to use bitmap fot _available_ports?
_available_ports: typing.Set[int]
_reserved_ports: typing.Set[int]
Expand Down
64 changes: 53 additions & 11 deletions src/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,10 +565,23 @@ def source_walsender(self):
assert type(self.master) is PostgresNode

with self.master.connect() as con:
for row in con.execute(sql, self.name):
execute_r = con.execute(sql, self.name)
assert execute_r is not None
assert isinstance(execute_r, typing.Iterable)
for row in execute_r:
assert row is not None
assert type(row) in [list, tuple]
assert len(row) == 1
row_col0 = row[0]
assert row_col0 is not None
row_col0_typed = int(row[0])
for child in self.master.auxiliary_processes:
if child.pid == int(row[0]):
return child
if child.pid != row_col0_typed:
continue

assert child.pid == row_col0_typed
return child
continue

msg = "Master doesn't send WAL to {}".format(self.name)
raise TestgresException(msg)
Expand Down Expand Up @@ -696,11 +709,16 @@ def _try_shutdown_internal(self, max_attempts, with_force):

ps_command = ['ps', '-o', 'pid=', '-p', str(node_pid)]

ps_output = self._os_ops.run(
run_r = self._os_ops.run(
cmd=ps_command,
shell=True,
check=False,
).stdout.decode('utf-8')
)
assert run_r is not None
assert run_r.stdout is not None
assert type(run_r.stdout) is bytes

ps_output = run_r.stdout.decode('utf-8')
assert type(ps_output) is str

if ps_output == "":
Expand All @@ -722,11 +740,16 @@ def _try_shutdown_internal(self, max_attempts, with_force):
pass

# Check that node stopped - print only column pid without headers
ps_output = self._os_ops.run(
run_r = self._os_ops.run(
cmd=ps_command,
shell=True,
check=False,
).stdout.decode('utf-8')
)
assert run_r is not None
assert run_r.stdout is not None
assert type(run_r.stdout) is bytes

ps_output = run_r.stdout.decode('utf-8')
assert type(ps_output) is str

if ps_output == "":
Expand Down Expand Up @@ -1786,13 +1809,30 @@ def _psql(
assert type(r) is OsCommandResult
return r

@method_decorator(positional_args_hack(['dbname', 'query']))
@typing.overload
def safe_psql(
self,
query: typing.Optional[str] = None,
expect_error: bool = False,
**kwargs: typing.Any,
) -> typing.Any: ...

@typing.overload
def safe_psql(
self,
dbname: str,
query: str,
expect_error: bool = False,
**kwargs: typing.Any,
) -> typing.Any: ...

@method_decorator(positional_args_hack(['dbname', 'query']))
def safe_psql( # pyright: ignore[reportInconsistentOverload]
self,
query=None,
expect_error=False,
**kwargs,
):
) -> typing.Any:
"""
Execute a query using psql.

Expand Down Expand Up @@ -1935,6 +1975,8 @@ def restore(
except ExecUtilException:
self.psql(filename=filename, dbname=dbname, username=username)

T_SUPPRESS_EXCS = typing.Iterable[typing.Type[BaseException]]

@method_decorator(positional_args_hack(['dbname', 'query']))
def poll_query_until(
self,
Expand All @@ -1943,9 +1985,9 @@ def poll_query_until(
username: typing.Optional[str] = None,
max_attempts: int = 0,
sleep_time: typing.Union[int, float] = 1,
expected: bool = True,
expected: typing.Any = True,
commit: bool = True,
suppress: typing.Optional[typing.Iterable[BaseException]] = None,
suppress: typing.Optional[T_SUPPRESS_EXCS] = None,
) -> None:
"""
Run a query once per second until it returns 'expected'.
Expand Down
17 changes: 11 additions & 6 deletions src/node_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,16 @@ def make_simple(
)

# set major version
pg_version_file = self._os_ops.read(self._os_ops.build_path(node.data_dir, 'PG_VERSION'))
pg_version_file = self._os_ops.read(
self._os_ops.build_path(node.data_dir, 'PG_VERSION'),
)
assert type(pg_version_file) is str

# What is it ???
node.major_version_str = str(pg_version_file.rstrip())
node.major_version = float(node.major_version_str)
major_version_str = pg_version_file.rstrip()
setattr(node, "major_version_str", major_version_str)
major_version = float(major_version_str)
setattr(node, "major_version", major_version)

# Set default parameters
options = {
Expand All @@ -187,7 +192,7 @@ def make_simple(
options['ptrack.map_size'] = '1'
options['shared_preload_libraries'] = 'ptrack'

if node.major_version >= 13:
if major_version >= 13:
options['wal_keep_size'] = '200MB'
else:
options['wal_keep_segments'] = '12'
Expand All @@ -208,7 +213,7 @@ def make_simple(
# kludge for testgres
# https://github.com/postgrespro/testgres/issues/54
# for PG >= 13 remove 'wal_keep_segments' parameter
if node.major_version >= 13:
if major_version >= 13:
node.set_auto_conf(
{},
'postgresql.conf',
Expand Down Expand Up @@ -249,7 +254,7 @@ def _paramlist_append(

assert updated_params is not None
if updated_params is user_params:
return [*user_params, param]
return [*updated_params, param]

updated_params.append(param)
return updated_params
Expand Down
4 changes: 2 additions & 2 deletions tests/test_os_ops_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5007,9 +5007,9 @@ def test_popen_garbage_collection(

# Запоминаем локальный процесс транспорта, чтобы проверить его смерть в конце
if type(controller).__name__ == "LocalProcessController":
local_p = controller._local_process
local_p = getattr(controller, "_local_process")
elif type(controller).__name__ == "RemoteProcessController":
local_p = controller._local_process
local_p = getattr(controller, "_local_process")
else:
raise RuntimeError("Unknown controller type: {}.".format(
type(controller).__name__,
Expand Down
Loading
Loading