Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Tests are based on pytest#192

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes from1 commit
Commits
Show all changes
41 commits
Select commitHold shift + click to select a range
f37c299
Using pytest [pytest.raises]
dmitry-lipetskFeb 23, 2025
53e468e
Using pytest [pytest.skip]
dmitry-lipetskFeb 23, 2025
12d702a
Using pytest [assertIsNotNone]
dmitry-lipetskFeb 23, 2025
1cb664e
Using pytest [assertFalse]
dmitry-lipetskFeb 23, 2025
e2e7e8b
Using pytest [assertTrue]
dmitry-lipetskFeb 23, 2025
89784a8
Using pytest [assertEqual]
dmitry-lipetskFeb 23, 2025
2252d60
Using pytest [assertNotEqual]
dmitry-lipetskFeb 23, 2025
e8aad3d
Using pytest [assertGreaterEqual]
dmitry-lipetskFeb 23, 2025
eaaa276
Using pytest [assertGreater]
dmitry-lipetskFeb 23, 2025
4afbe00
Using pytest [assertIn]
dmitry-lipetskFeb 23, 2025
a8e57ae
Using pytest [assertListEqual]
dmitry-lipetskFeb 23, 2025
df199b9
unittest is not used
dmitry-lipetskFeb 23, 2025
a82cf3d
Code style (flake8)
dmitry-lipetskFeb 23, 2025
9745bc4
Merge commit '38b3dc3697d229b6668217f2f57825379c7f2e23' into D2025022…
dmitry-lipetskFeb 23, 2025
27c4f40
Execution signature is removed
dmitry-lipetskFeb 24, 2025
ae41d16
run_tests.sh installs pytest
dmitry-lipetskFeb 24, 2025
a14b3d7
run_tests.sh is updated
dmitry-lipetskFeb 24, 2025
e6f4448
Total refactoring of tests
dmitry-lipetskFeb 24, 2025
842bc08
Code style (flake8)
dmitry-lipetskFeb 24, 2025
d9afdcc
Merge commit 'de738f9fd8d52345677903bface575d41cbe539c' into D2025022…
dmitry-lipetskFeb 24, 2025
027d2ea
Merge branch 'D20250224_002--os_ops-in-free_utilities' into D20250223…
dmitry-lipetskFeb 24, 2025
969e49d
Root __init__.py is added
dmitry-lipetskFeb 24, 2025
6e2820d
Code style (flake8)
dmitry-lipetskFeb 24, 2025
588b28b
Merge remote-tracking branch 'origin/D20250224_002--os_ops-in-free_ut…
dmitry-lipetskFeb 24, 2025
e4e8909
pytest.ini is added
dmitry-lipetskFeb 24, 2025
66860d0
TestgresTests::test_ports_management is corrected
dmitry-lipetskFeb 24, 2025
aaaa677
coding: utf-8
dmitry-lipetskFeb 24, 2025
60bb4c5
Cleanup
dmitry-lipetskFeb 24, 2025
2d2532c
CI runs all the tests of testgres.
dmitry-lipetskFeb 24, 2025
537a9ac
Add install ssh
Feb 24, 2025
1f99813
Revert "Add install ssh"
dmitry-lipetskFeb 25, 2025
41455d6
Revert "CI runs all the tests of testgres."
dmitry-lipetskFeb 25, 2025
1c43810
Merge commit '669e134ff65b99cd285500e5f362633fc8d50e4e' into D2025022…
dmitry-lipetskFeb 25, 2025
47a51a8
Test of probackup plugin is restored
dmitry-lipetskFeb 25, 2025
f7f163d
The test suite of a probackup plugin is based on pytest
dmitry-lipetskFeb 25, 2025
ed7b187
Probackup plugin is updated
dmitry-lipetskFeb 25, 2025
8af4a49
CI test use 4 cores
dmitry-lipetskFeb 25, 2025
d35ca43
testgres.plugins.probackup2.Init was restored [thanks to Yuri Sokolov]
dmitry-lipetskFeb 25, 2025
181126b
pytest.ini is updated [testpaths]
dmitry-lipetskFeb 25, 2025
d08f659
test_child_pids (local, remote) is updated
dmitry-lipetskFeb 25, 2025
e803146
test_child_process_dies is updated
dmitry-lipetskFeb 25, 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
PrevPrevious commit
NextNext commit
testgres.plugins.probackup2.Init was restored [thanks to Yuri Sokolov]
  • Loading branch information
@dmitry-lipetsk
dmitry-lipetsk committedFeb 25, 2025
commitd35ca43acdc07bad1540002a50b263283947af86
151 changes: 72 additions & 79 deletionstestgres/plugins/pg_probackup2/pg_probackup2/init_helpers.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import logging
from functools import reduce
import getpass
Expand DownExpand Up@@ -39,27 +37,21 @@

class Init(object):
def __init__(self):
pass

@staticmethod
def create() -> Init:
SELF = __class__()

if '-v' in sys.argv or '--verbose' in sys.argv:
SELF.verbose = True
self.verbose = True
else:
SELF.verbose = False

SELF._pg_config = testgres.get_pg_config()
SELF.is_enterprise =SELF._pg_config.get('PGPRO_EDITION', None) == 'enterprise'
SELF.is_shardman =SELF._pg_config.get('PGPRO_EDITION', None) == 'shardman'
SELF.is_pgpro = 'PGPRO_EDITION' inSELF._pg_config
SELF.is_nls_enabled = 'enable-nls' inSELF._pg_config['CONFIGURE']
SELF.is_lz4_enabled = '-llz4' inSELF._pg_config['LIBS']
version =SELF._pg_config['VERSION'].rstrip('develalphabetapre')
self.verbose = False

self._pg_config = testgres.get_pg_config()
self.is_enterprise =self._pg_config.get('PGPRO_EDITION', None) == 'enterprise'
self.is_shardman =self._pg_config.get('PGPRO_EDITION', None) == 'shardman'
self.is_pgpro = 'PGPRO_EDITION' inself._pg_config
self.is_nls_enabled = 'enable-nls' inself._pg_config['CONFIGURE']
self.is_lz4_enabled = '-llz4' inself._pg_config['LIBS']
version =self._pg_config['VERSION'].rstrip('develalphabetapre')
parts = [*version.split(' ')[1].split('.'), '0', '0'][:3]
parts[0] = re.match(r'\d+', parts[0]).group()
SELF.pg_config_version = reduce(lambda v, x: v * 100 + int(x), parts, 0)
self.pg_config_version = reduce(lambda v, x: v * 100 + int(x), parts, 0)

os.environ['LANGUAGE'] = 'en' # set default locale language to en. All messages will use this locale
test_env = os.environ.copy()
Expand All@@ -83,31 +75,31 @@ def create() -> Init:

test_env['LC_MESSAGES'] = 'C'
test_env['LC_TIME'] = 'C'
SELF._test_env = test_env
self._test_env = test_env

# Get the directory from which the script was executed
SELF.source_path = os.getcwd()
self.source_path = os.getcwd()
tmp_path = test_env.get('PGPROBACKUP_TMP_DIR')
if tmp_path and os.path.isabs(tmp_path):
SELF.tmp_path = tmp_path
self.tmp_path = tmp_path
else:
SELF.tmp_path = os.path.abspath(
os.path.join(SELF.source_path, tmp_path or os.path.join('tests', 'tmp_dirs'))
self.tmp_path = os.path.abspath(
os.path.join(self.source_path, tmp_path or os.path.join('tests', 'tmp_dirs'))
)

os.makedirs(SELF.tmp_path, exist_ok=True)
os.makedirs(self.tmp_path, exist_ok=True)

SELF.username = getpass.getuser()
self.username = getpass.getuser()

SELF.probackup_path = None
self.probackup_path = None
if 'PGPROBACKUPBIN' in test_env:
if shutil.which(test_env["PGPROBACKUPBIN"]):
SELF.probackup_path = test_env["PGPROBACKUPBIN"]
self.probackup_path = test_env["PGPROBACKUPBIN"]
else:
ifSELF.verbose:
ifself.verbose:
print('PGPROBACKUPBIN is not an executable file')

if notSELF.probackup_path:
if notself.probackup_path:
probackup_path_tmp = os.path.join(
testgres.get_pg_config()['BINDIR'], 'pg_probackup')

Expand All@@ -116,118 +108,119 @@ def create() -> Init:
logging.warning('{0} is not an executable file'.format(
probackup_path_tmp))
else:
SELF.probackup_path = probackup_path_tmp
self.probackup_path = probackup_path_tmp

if notSELF.probackup_path:
probackup_path_tmp =SELF.source_path
if notself.probackup_path:
probackup_path_tmp =self.source_path

if os.path.isfile(probackup_path_tmp):
if not os.access(probackup_path_tmp, os.X_OK):
logging.warning('{0} is not an executable file'.format(
probackup_path_tmp))
else:
SELF.probackup_path = probackup_path_tmp
self.probackup_path = probackup_path_tmp

if not SELF.probackup_path:
logging.error('pg_probackup binary is not found')
return None
if not self.probackup_path:
raise Exception('pg_probackup binary is not found')

if os.name == 'posix':
SELF.EXTERNAL_DIRECTORY_DELIMITER = ':'
self.EXTERNAL_DIRECTORY_DELIMITER = ':'
os.environ['PATH'] = os.path.dirname(
SELF.probackup_path) + ':' + os.environ['PATH']
self.probackup_path) + ':' + os.environ['PATH']

elif os.name == 'nt':
SELF.EXTERNAL_DIRECTORY_DELIMITER = ';'
self.EXTERNAL_DIRECTORY_DELIMITER = ';'
os.environ['PATH'] = os.path.dirname(
SELF.probackup_path) + ';' + os.environ['PATH']
self.probackup_path) + ';' + os.environ['PATH']

SELF.probackup_old_path = None
self.probackup_old_path = None
if 'PGPROBACKUPBIN_OLD' in test_env:
if (os.path.isfile(test_env['PGPROBACKUPBIN_OLD']) and os.access(test_env['PGPROBACKUPBIN_OLD'], os.X_OK)):
SELF.probackup_old_path = test_env['PGPROBACKUPBIN_OLD']
self.probackup_old_path = test_env['PGPROBACKUPBIN_OLD']
else:
ifSELF.verbose:
ifself.verbose:
print('PGPROBACKUPBIN_OLD is not an executable file')

SELF.probackup_version = None
SELF.old_probackup_version = None
self.probackup_version = None
self.old_probackup_version = None

probackup_version_output = subprocess.check_output(
[SELF.probackup_path, "--version"],
[self.probackup_path, "--version"],
stderr=subprocess.STDOUT,
).decode('utf-8')
match = re.search(r"\d+\.\d+\.\d+",
probackup_version_output)
SELF.probackup_version = match.group(0) if match else None
self.probackup_version = match.group(0) if match else None
match = re.search(r"\(compressions: ([^)]*)\)", probackup_version_output)
compressions = match.group(1) if match else None
if compressions:
SELF.probackup_compressions = {s.strip() for s in compressions.split(',')}
self.probackup_compressions = {s.strip() for s in compressions.split(',')}
else:
SELF.probackup_compressions = []
self.probackup_compressions = []

ifSELF.probackup_old_path:
ifself.probackup_old_path:
old_probackup_version_output = subprocess.check_output(
[SELF.probackup_old_path, "--version"],
[self.probackup_old_path, "--version"],
stderr=subprocess.STDOUT,
).decode('utf-8')
match = re.search(r"\d+\.\d+\.\d+",
old_probackup_version_output)
SELF.old_probackup_version = match.group(0) if match else None
self.old_probackup_version = match.group(0) if match else None

SELF.remote = test_env.get('PGPROBACKUP_SSH_REMOTE', None) == 'ON'
SELF.ptrack = test_env.get('PG_PROBACKUP_PTRACK', None) == 'ON' andSELF.pg_config_version >= 110000
SELF.wal_tree_enabled = test_env.get('PG_PROBACKUP_WAL_TREE_ENABLED', None) == 'ON'
self.remote = test_env.get('PGPROBACKUP_SSH_REMOTE', None) == 'ON'
self.ptrack = test_env.get('PG_PROBACKUP_PTRACK', None) == 'ON' andself.pg_config_version >= 110000
self.wal_tree_enabled = test_env.get('PG_PROBACKUP_WAL_TREE_ENABLED', None) == 'ON'

SELF.bckp_source = test_env.get('PG_PROBACKUP_SOURCE', 'pro').lower()
ifSELF.bckp_source not in ('base', 'direct', 'pro'):
self.bckp_source = test_env.get('PG_PROBACKUP_SOURCE', 'pro').lower()
ifself.bckp_source not in ('base', 'direct', 'pro'):
raise Exception("Wrong PG_PROBACKUP_SOURCE value. Available options: base|direct|pro")

SELF.paranoia = test_env.get('PG_PROBACKUP_PARANOIA', None) == 'ON'
self.paranoia = test_env.get('PG_PROBACKUP_PARANOIA', None) == 'ON'
env_compress = test_env.get('ARCHIVE_COMPRESSION', None)
if env_compress:
env_compress = env_compress.lower()
if env_compress in ('on', 'zlib'):
SELF.compress_suffix = '.gz'
SELF.archive_compress = 'zlib'
self.compress_suffix = '.gz'
self.archive_compress = 'zlib'
elif env_compress == 'lz4':
if not HAVE_LZ4:
raise LZ4_error
if 'lz4' not inSELF.probackup_compressions:
if 'lz4' not inself.probackup_compressions:
raise Exception("pg_probackup is not compiled with lz4 support")
SELF.compress_suffix = '.lz4'
SELF.archive_compress = 'lz4'
self.compress_suffix = '.lz4'
self.archive_compress = 'lz4'
elif env_compress == 'zstd':
if not HAVE_ZSTD:
raise ZSTD_error
if 'zstd' not inSELF.probackup_compressions:
if 'zstd' not inself.probackup_compressions:
raise Exception("pg_probackup is not compiled with zstd support")
SELF.compress_suffix = '.zst'
SELF.archive_compress = 'zstd'
self.compress_suffix = '.zst'
self.archive_compress = 'zstd'
else:
SELF.compress_suffix = ''
SELF.archive_compress = False
self.compress_suffix = ''
self.archive_compress = False

cfs_compress = test_env.get('PG_PROBACKUP_CFS_COMPRESS', None)
if cfs_compress:
SELF.cfs_compress = cfs_compress.lower()
self.cfs_compress = cfs_compress.lower()
else:
SELF.cfs_compress =SELF.archive_compress
self.cfs_compress =self.archive_compress

os.environ["PGAPPNAME"] = "pg_probackup"
SELF.delete_logs = delete_logs
self.delete_logs = delete_logs

ifSELF.probackup_version.split('.')[0].isdigit():
SELF.major_version = int(SELF.probackup_version.split('.')[0])
ifself.probackup_version.split('.')[0].isdigit():
self.major_version = int(self.probackup_version.split('.')[0])
else:
logging.error('Can\'t process pg_probackup version \"{}\": the major version is expected to be a number'.format(SELF.probackup_version))
return None

return SELF
raise Exception('Can\'t process pg_probackup version \"{}\": the major version is expected to be a number'.format(self.probackup_version))

def test_env(self):
return self._test_env.copy()


init_params = Init.create()
try:
init_params = Init()
except Exception as e:
logging.error(str(e))
logging.warning("testgres.plugins.probackup2.init_params is set to None.")
init_params = None

[8]ページ先頭

©2009-2025 Movatter.jp