You've already forked pg_probackup
mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-09-16 09:26:30 +02:00
Merge branch 'REL_2_5' into REL_2_6
This commit is contained in:
13
src/dir.c
13
src/dir.c
@@ -1742,6 +1742,8 @@ is_forkname(char *name, size_t *pos, const char *forkname)
|
||||
}
|
||||
|
||||
#define OIDCHARS 10
|
||||
#define MAXSEGNO (((uint64_t)1<<32)/RELSEG_SIZE-1)
|
||||
#define SEGNOCHARS 5 /* when BLCKSZ == (1<<15) */
|
||||
|
||||
/* Set forkName if possible */
|
||||
bool
|
||||
@@ -1749,6 +1751,7 @@ set_forkname(pgFile *file)
|
||||
{
|
||||
size_t i = 0;
|
||||
uint64_t oid = 0; /* use 64bit to not check for overflow in a loop */
|
||||
uint64_t segno = 0;
|
||||
|
||||
/* pretend it is not relation file */
|
||||
file->relOid = 0;
|
||||
@@ -1779,8 +1782,15 @@ set_forkname(pgFile *file)
|
||||
/* /^\d+(_(vm|fsm|init|ptrack))?\.\d+$/ */
|
||||
if (file->name[i] == '.' && isdigit(file->name[i+1]))
|
||||
{
|
||||
size_t start = i+1;
|
||||
for (i++; isdigit(file->name[i]); i++)
|
||||
;
|
||||
{
|
||||
if (i == start && file->name[i] == '0')
|
||||
return false;
|
||||
segno = segno * 10 + file->name[i] - '0';
|
||||
}
|
||||
if (i - start > SEGNOCHARS || segno > MAXSEGNO)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* CFS "fork name" */
|
||||
@@ -1799,6 +1809,7 @@ set_forkname(pgFile *file)
|
||||
}
|
||||
|
||||
file->relOid = oid;
|
||||
file->segno = segno;
|
||||
file->is_datafile = file->forkName == none;
|
||||
return true;
|
||||
}
|
||||
|
@@ -981,7 +981,7 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
"""
|
||||
|
||||
if self.pg_config_version < self.version_to_num('11.0'):
|
||||
return unittest.skip('You need PostgreSQL >= 11 for this test')
|
||||
self.skipTest('You need PostgreSQL >= 11 for this test')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
|
@@ -13,6 +13,38 @@ module_name = 'backup'
|
||||
|
||||
class BackupTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
def test_basic_full_backup(self):
|
||||
"""
|
||||
Just test full backup with at least two segments
|
||||
"""
|
||||
fname = self.id().split('.')[3]
|
||||
node = self.make_simple_node(
|
||||
base_dir=os.path.join(module_name, fname, 'node'),
|
||||
initdb_params=['--data-checksums'],
|
||||
# we need to write a lot. Lets speedup a bit.
|
||||
pg_options={"fsync": "off", "synchronous_commit": "off"})
|
||||
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
self.init_pb(backup_dir)
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
self.set_archiving(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
# Fill with data
|
||||
# Have to use scale=100 to create second segment.
|
||||
node.pgbench_init(scale=100, no_vacuum=True)
|
||||
|
||||
# FULL
|
||||
backup_id = self.backup_node(backup_dir, 'node', node)
|
||||
|
||||
out = self.validate_pb(backup_dir, 'node', backup_id)
|
||||
self.assertIn(
|
||||
"INFO: Backup {0} is valid".format(backup_id),
|
||||
out)
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
# @unittest.skip("skip")
|
||||
# @unittest.expectedFailure
|
||||
# PGPRO-707
|
||||
@@ -1497,7 +1529,7 @@ class BackupTest(ProbackupTest, unittest.TestCase):
|
||||
def test_pg_11_adjusted_wal_segment_size(self):
|
||||
""""""
|
||||
if self.pg_config_version < self.version_to_num('11.0'):
|
||||
return unittest.skip('You need PostgreSQL >= 11 for this test')
|
||||
self.skipTest('You need PostgreSQL >= 11 for this test')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
@@ -1740,7 +1772,7 @@ class BackupTest(ProbackupTest, unittest.TestCase):
|
||||
def test_basic_missing_file_permissions(self):
|
||||
""""""
|
||||
if os.name == 'nt':
|
||||
return unittest.skip('Skipped because it is POSIX only test')
|
||||
self.skipTest('Skipped because it is POSIX only test')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
@@ -1787,7 +1819,7 @@ class BackupTest(ProbackupTest, unittest.TestCase):
|
||||
def test_basic_missing_dir_permissions(self):
|
||||
""""""
|
||||
if os.name == 'nt':
|
||||
return unittest.skip('Skipped because it is POSIX only test')
|
||||
self.skipTest('Skipped because it is POSIX only test')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
|
@@ -190,7 +190,7 @@ class CatchupTest(ProbackupTest, unittest.TestCase):
|
||||
Test ptrack catchup
|
||||
"""
|
||||
if not self.ptrack:
|
||||
return unittest.skip('Skipped because ptrack support is disabled')
|
||||
self.skipTest('Skipped because ptrack support is disabled')
|
||||
|
||||
# preparation 1: source
|
||||
src_pg = self.make_simple_node(
|
||||
@@ -336,7 +336,7 @@ class CatchupTest(ProbackupTest, unittest.TestCase):
|
||||
Test that we correctly follow timeline change with ptrack catchup
|
||||
"""
|
||||
if not self.ptrack:
|
||||
return unittest.skip('Skipped because ptrack support is disabled')
|
||||
self.skipTest('Skipped because ptrack support is disabled')
|
||||
|
||||
# preparation 1: source
|
||||
src_pg = self.make_simple_node(
|
||||
@@ -475,7 +475,7 @@ class CatchupTest(ProbackupTest, unittest.TestCase):
|
||||
Test that dropped table in source will be dropped in ptrack catchup'ed instance too
|
||||
"""
|
||||
if not self.ptrack:
|
||||
return unittest.skip('Skipped because ptrack support is disabled')
|
||||
self.skipTest('Skipped because ptrack support is disabled')
|
||||
|
||||
# preparation 1: source
|
||||
src_pg = self.make_simple_node(
|
||||
@@ -590,7 +590,7 @@ class CatchupTest(ProbackupTest, unittest.TestCase):
|
||||
Test that truncated table in source will be truncated in ptrack catchup'ed instance too
|
||||
"""
|
||||
if not self.ptrack:
|
||||
return unittest.skip('Skipped because ptrack support is disabled')
|
||||
self.skipTest('Skipped because ptrack support is disabled')
|
||||
|
||||
# preparation 1: source
|
||||
src_pg = self.make_simple_node(
|
||||
@@ -655,7 +655,7 @@ class CatchupTest(ProbackupTest, unittest.TestCase):
|
||||
Test that we detect absence of needed --tablespace-mapping option
|
||||
"""
|
||||
if self.remote:
|
||||
return unittest.skip('Skipped because this test tests local catchup error handling')
|
||||
self.skipTest('Skipped because this test tests local catchup error handling')
|
||||
|
||||
src_pg = self.make_simple_node(base_dir = os.path.join(module_name, self.fname, 'src'))
|
||||
src_pg.slow_start()
|
||||
@@ -1035,7 +1035,7 @@ class CatchupTest(ProbackupTest, unittest.TestCase):
|
||||
Test that we correctly recover uncleanly shutdowned destination
|
||||
"""
|
||||
if not self.ptrack:
|
||||
return unittest.skip('Skipped because ptrack support is disabled')
|
||||
self.skipTest('Skipped because ptrack support is disabled')
|
||||
|
||||
# preparation 1: source
|
||||
src_pg = self.make_simple_node(
|
||||
@@ -1506,7 +1506,7 @@ class CatchupTest(ProbackupTest, unittest.TestCase):
|
||||
Test dry-run option for catchup in incremental ptrack mode
|
||||
"""
|
||||
if not self.ptrack:
|
||||
return unittest.skip('Skipped because ptrack support is disabled')
|
||||
self.skipTest('Skipped because ptrack support is disabled')
|
||||
|
||||
# preparation 1: source
|
||||
src_pg = self.make_simple_node(
|
||||
|
@@ -366,7 +366,7 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
"""Description in jira issue PGPRO-434"""
|
||||
|
||||
if not self.ptrack:
|
||||
return unittest.skip('Skipped because ptrack support is disabled')
|
||||
self.skipTest('Skipped because ptrack support is disabled')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
|
@@ -189,7 +189,7 @@ class DeleteTest(ProbackupTest, unittest.TestCase):
|
||||
def test_delete_increment_ptrack(self):
|
||||
"""delete increment and all after him"""
|
||||
if not self.ptrack:
|
||||
return unittest.skip('Skipped because ptrack support is disabled')
|
||||
self.skipTest('Skipped because ptrack support is disabled')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
node = self.make_simple_node(
|
||||
|
@@ -1535,7 +1535,7 @@ class ExternalTest(ProbackupTest, unittest.TestCase):
|
||||
but restored as directory
|
||||
"""
|
||||
if os.name == 'nt':
|
||||
return unittest.skip('Skipped for Windows')
|
||||
self.skipTest('Skipped for Windows')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
@@ -1618,7 +1618,7 @@ class ExternalTest(ProbackupTest, unittest.TestCase):
|
||||
but restored as directory
|
||||
"""
|
||||
if os.name == 'nt':
|
||||
return unittest.skip('Skipped for Windows')
|
||||
self.skipTest('Skipped for Windows')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
@@ -1703,7 +1703,7 @@ class ExternalTest(ProbackupTest, unittest.TestCase):
|
||||
but restored as directory
|
||||
"""
|
||||
if os.name == 'nt':
|
||||
return unittest.skip('Skipped for Windows')
|
||||
self.skipTest('Skipped for Windows')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
|
@@ -1,2 +1,9 @@
|
||||
__all__ = ['ptrack_helpers', 'cfs_helpers', 'expected_errors']
|
||||
#from . import *
|
||||
|
||||
import unittest
|
||||
|
||||
# python 2.7 compatibility
|
||||
if not hasattr(unittest.TestCase, "skipTest"):
|
||||
def skipTest(self, reason):
|
||||
raise unittest.SkipTest(reason)
|
||||
unittest.TestCase.skipTest = skipTest
|
@@ -242,10 +242,7 @@ class ProbackupTest(object):
|
||||
self.user = self.get_username()
|
||||
self.probackup_path = None
|
||||
if 'PGPROBACKUPBIN' in self.test_env:
|
||||
if (
|
||||
os.path.isfile(self.test_env["PGPROBACKUPBIN"]) and
|
||||
os.access(self.test_env["PGPROBACKUPBIN"], os.X_OK)
|
||||
):
|
||||
if shutil.which(self.test_env["PGPROBACKUPBIN"]):
|
||||
self.probackup_path = self.test_env["PGPROBACKUPBIN"]
|
||||
else:
|
||||
if self.verbose:
|
||||
|
@@ -796,7 +796,7 @@ class MergeTest(ProbackupTest, unittest.TestCase):
|
||||
restore last page backup and check data correctness
|
||||
"""
|
||||
if not self.ptrack:
|
||||
return unittest.skip('Skipped because ptrack support is disabled')
|
||||
self.skipTest('Skipped because ptrack support is disabled')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
|
@@ -239,5 +239,5 @@ class OptionTest(ProbackupTest, unittest.TestCase):
|
||||
help_out.read().decode("utf-8")
|
||||
)
|
||||
else:
|
||||
return unittest.skip(
|
||||
self.skipTest(
|
||||
'You need configure PostgreSQL with --enabled-nls option for this test')
|
||||
|
@@ -16,7 +16,7 @@ module_name = 'ptrack'
|
||||
class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
def setUp(self):
|
||||
if self.pg_config_version < self.version_to_num('11.0'):
|
||||
return unittest.skip('You need PostgreSQL >= 11 for this test')
|
||||
self.skipTest('You need PostgreSQL >= 11 for this test')
|
||||
self.fname = self.id().split('.')[3]
|
||||
|
||||
# @unittest.skip("skip")
|
||||
|
@@ -98,7 +98,7 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
|
||||
take full stream backup from replica
|
||||
"""
|
||||
if not self.ptrack:
|
||||
return unittest.skip('Skipped because ptrack support is disabled')
|
||||
self.skipTest('Skipped because ptrack support is disabled')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
|
@@ -492,7 +492,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
def test_restore_full_ptrack_archive(self):
|
||||
"""recovery to latest from archive full+ptrack backups"""
|
||||
if not self.ptrack:
|
||||
return unittest.skip('Skipped because ptrack support is disabled')
|
||||
self.skipTest('Skipped because ptrack support is disabled')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
node = self.make_simple_node(
|
||||
@@ -546,7 +546,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
def test_restore_ptrack(self):
|
||||
"""recovery to latest from archive full+ptrack+ptrack backups"""
|
||||
if not self.ptrack:
|
||||
return unittest.skip('Skipped because ptrack support is disabled')
|
||||
self.skipTest('Skipped because ptrack support is disabled')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
node = self.make_simple_node(
|
||||
@@ -607,7 +607,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
def test_restore_full_ptrack_stream(self):
|
||||
"""recovery in stream mode to latest from full + ptrack backups"""
|
||||
if not self.ptrack:
|
||||
return unittest.skip('Skipped because ptrack support is disabled')
|
||||
self.skipTest('Skipped because ptrack support is disabled')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
node = self.make_simple_node(
|
||||
@@ -665,7 +665,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
with loads when ptrack backup do
|
||||
"""
|
||||
if not self.ptrack:
|
||||
return unittest.skip('Skipped because ptrack support is disabled')
|
||||
self.skipTest('Skipped because ptrack support is disabled')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
node = self.make_simple_node(
|
||||
@@ -734,7 +734,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
with loads when full backup do
|
||||
"""
|
||||
if not self.ptrack:
|
||||
return unittest.skip('Skipped because ptrack support is disabled')
|
||||
self.skipTest('Skipped because ptrack support is disabled')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
node = self.make_simple_node(
|
||||
@@ -2333,7 +2333,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
test group access for PG >= 11
|
||||
"""
|
||||
if self.pg_config_version < self.version_to_num('11.0'):
|
||||
return unittest.skip('You need PostgreSQL >= 11 for this test')
|
||||
self.skipTest('You need PostgreSQL >= 11 for this test')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
node = self.make_simple_node(
|
||||
@@ -3595,7 +3595,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
self.skipTest("You must specify PGPROBACKUPBIN_OLD"
|
||||
" for run this test")
|
||||
if self.pg_config_version < self.version_to_num('12.0'):
|
||||
return unittest.skip('You need PostgreSQL >= 12 for this test')
|
||||
self.skipTest('You need PostgreSQL >= 12 for this test')
|
||||
|
||||
if self.version_to_num(self.old_probackup_version) >= self.version_to_num('2.4.5'):
|
||||
self.assertTrue(False, 'You need pg_probackup < 2.4.5 for this test')
|
||||
@@ -3667,7 +3667,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
"""
|
||||
|
||||
if self.pg_config_version < self.version_to_num('12.0'):
|
||||
return unittest.skip('You need PostgreSQL >= 12 for this test')
|
||||
self.skipTest('You need PostgreSQL >= 12 for this test')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
@@ -3712,7 +3712,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
"""
|
||||
|
||||
if self.pg_config_version < self.version_to_num('12.0'):
|
||||
return unittest.skip('You need PostgreSQL >= 12 for this test')
|
||||
self.skipTest('You need PostgreSQL >= 12 for this test')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
|
@@ -16,9 +16,9 @@ class TimeConsumingTests(ProbackupTest, unittest.TestCase):
|
||||
"""
|
||||
# init node
|
||||
if self.pg_config_version < self.version_to_num('11.0'):
|
||||
return unittest.skip('You need PostgreSQL >= 11 for this test')
|
||||
self.skipTest('You need PostgreSQL >= 11 for this test')
|
||||
if not self.ptrack:
|
||||
return unittest.skip('Skipped because ptrack support is disabled')
|
||||
self.skipTest('Skipped because ptrack support is disabled')
|
||||
|
||||
fname = self.id().split('.')[3]
|
||||
node = self.make_simple_node(
|
||||
|
Reference in New Issue
Block a user