Skip to content

Commit ef9ac65

Browse files
committed
Merge branch 'REL_2_5' into REL_2_6
2 parents 2da1f31 + 5f66a60 commit ef9ac65

15 files changed

+84
-37
lines changed

src/dir.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1742,13 +1742,16 @@ is_forkname(char *name, size_t *pos, const char *forkname)
17421742
}
17431743

17441744
#define OIDCHARS 10
1745+
#define MAXSEGNO (((uint64_t)1<<32)/RELSEG_SIZE-1)
1746+
#define SEGNOCHARS 5 /* when BLCKSZ == (1<<15) */
17451747

17461748
/* Set forkName if possible */
17471749
bool
17481750
set_forkname(pgFile *file)
17491751
{
17501752
size_t i = 0;
17511753
uint64_t oid = 0; /* use 64bit to not check for overflow in a loop */
1754+
uint64_t segno = 0;
17521755

17531756
/* pretend it is not relation file */
17541757
file->relOid = 0;
@@ -1779,8 +1782,15 @@ set_forkname(pgFile *file)
17791782
/* /^\d+(_(vm|fsm|init|ptrack))?\.\d+$/ */
17801783
if (file->name[i] == '.' && isdigit(file->name[i+1]))
17811784
{
1785+
size_t start = i+1;
17821786
for (i++; isdigit(file->name[i]); i++)
1783-
;
1787+
{
1788+
if (i == start && file->name[i] == '0')
1789+
return false;
1790+
segno = segno * 10 + file->name[i] - '0';
1791+
}
1792+
if (i - start > SEGNOCHARS || segno > MAXSEGNO)
1793+
return false;
17841794
}
17851795

17861796
/* CFS "fork name" */
@@ -1799,6 +1809,7 @@ set_forkname(pgFile *file)
17991809
}
18001810

18011811
file->relOid = oid;
1812+
file->segno = segno;
18021813
file->is_datafile = file->forkName == none;
18031814
return true;
18041815
}

tests/archive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ def test_concurrent_archiving(self):
981981
"""
982982

983983
if self.pg_config_version < self.version_to_num('11.0'):
984-
return unittest.skip('You need PostgreSQL >= 11 for this test')
984+
self.skipTest('You need PostgreSQL >= 11 for this test')
985985

986986
fname = self.id().split('.')[3]
987987
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')

tests/backup.py

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,38 @@
1313

1414
class BackupTest(ProbackupTest, unittest.TestCase):
1515

16+
def test_basic_full_backup(self):
17+
"""
18+
Just test full backup with at least two segments
19+
"""
20+
fname = self.id().split('.')[3]
21+
node = self.make_simple_node(
22+
base_dir=os.path.join(module_name, fname, 'node'),
23+
initdb_params=['--data-checksums'],
24+
# we need to write a lot. Lets speedup a bit.
25+
pg_options={"fsync": "off", "synchronous_commit": "off"})
26+
27+
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
28+
self.init_pb(backup_dir)
29+
self.add_instance(backup_dir, 'node', node)
30+
self.set_archiving(backup_dir, 'node', node)
31+
node.slow_start()
32+
33+
# Fill with data
34+
# Have to use scale=100 to create second segment.
35+
node.pgbench_init(scale=100, no_vacuum=True)
36+
37+
# FULL
38+
backup_id = self.backup_node(backup_dir, 'node', node)
39+
40+
out = self.validate_pb(backup_dir, 'node', backup_id)
41+
self.assertIn(
42+
"INFO: Backup {0} is valid".format(backup_id),
43+
out)
44+
45+
# Clean after yourself
46+
self.del_test_dir(module_name, fname)
47+
1648
# @unittest.skip("skip")
1749
# @unittest.expectedFailure
1850
# PGPRO-707
@@ -1497,7 +1529,7 @@ def test_backup_concurrent_drop_table(self):
14971529
def test_pg_11_adjusted_wal_segment_size(self):
14981530
""""""
14991531
if self.pg_config_version < self.version_to_num('11.0'):
1500-
return unittest.skip('You need PostgreSQL >= 11 for this test')
1532+
self.skipTest('You need PostgreSQL >= 11 for this test')
15011533

15021534
fname = self.id().split('.')[3]
15031535
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@@ -1740,7 +1772,7 @@ def test_drop_table(self):
17401772
def test_basic_missing_file_permissions(self):
17411773
""""""
17421774
if os.name == 'nt':
1743-
return unittest.skip('Skipped because it is POSIX only test')
1775+
self.skipTest('Skipped because it is POSIX only test')
17441776

17451777
fname = self.id().split('.')[3]
17461778
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@@ -1787,7 +1819,7 @@ def test_basic_missing_file_permissions(self):
17871819
def test_basic_missing_dir_permissions(self):
17881820
""""""
17891821
if os.name == 'nt':
1790-
return unittest.skip('Skipped because it is POSIX only test')
1822+
self.skipTest('Skipped because it is POSIX only test')
17911823

17921824
fname = self.id().split('.')[3]
17931825
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')

tests/catchup.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def test_basic_ptrack_catchup(self):
190190
Test ptrack catchup
191191
"""
192192
if not self.ptrack:
193-
return unittest.skip('Skipped because ptrack support is disabled')
193+
self.skipTest('Skipped because ptrack support is disabled')
194194

195195
# preparation 1: source
196196
src_pg = self.make_simple_node(
@@ -336,7 +336,7 @@ def test_tli_ptrack_catchup(self):
336336
Test that we correctly follow timeline change with ptrack catchup
337337
"""
338338
if not self.ptrack:
339-
return unittest.skip('Skipped because ptrack support is disabled')
339+
self.skipTest('Skipped because ptrack support is disabled')
340340

341341
# preparation 1: source
342342
src_pg = self.make_simple_node(
@@ -475,7 +475,7 @@ def test_table_drop_with_ptrack(self):
475475
Test that dropped table in source will be dropped in ptrack catchup'ed instance too
476476
"""
477477
if not self.ptrack:
478-
return unittest.skip('Skipped because ptrack support is disabled')
478+
self.skipTest('Skipped because ptrack support is disabled')
479479

480480
# preparation 1: source
481481
src_pg = self.make_simple_node(
@@ -590,7 +590,7 @@ def test_tablefile_truncation_with_ptrack(self):
590590
Test that truncated table in source will be truncated in ptrack catchup'ed instance too
591591
"""
592592
if not self.ptrack:
593-
return unittest.skip('Skipped because ptrack support is disabled')
593+
self.skipTest('Skipped because ptrack support is disabled')
594594

595595
# preparation 1: source
596596
src_pg = self.make_simple_node(
@@ -655,7 +655,7 @@ def test_local_tablespace_without_mapping(self):
655655
Test that we detect absence of needed --tablespace-mapping option
656656
"""
657657
if self.remote:
658-
return unittest.skip('Skipped because this test tests local catchup error handling')
658+
self.skipTest('Skipped because this test tests local catchup error handling')
659659

660660
src_pg = self.make_simple_node(base_dir = os.path.join(module_name, self.fname, 'src'))
661661
src_pg.slow_start()
@@ -1035,7 +1035,7 @@ def test_unclean_ptrack_catchup(self):
10351035
Test that we correctly recover uncleanly shutdowned destination
10361036
"""
10371037
if not self.ptrack:
1038-
return unittest.skip('Skipped because ptrack support is disabled')
1038+
self.skipTest('Skipped because ptrack support is disabled')
10391039

10401040
# preparation 1: source
10411041
src_pg = self.make_simple_node(
@@ -1506,7 +1506,7 @@ def test_dry_run_catchup_ptrack(self):
15061506
Test dry-run option for catchup in incremental ptrack mode
15071507
"""
15081508
if not self.ptrack:
1509-
return unittest.skip('Skipped because ptrack support is disabled')
1509+
self.skipTest('Skipped because ptrack support is disabled')
15101510

15111511
# preparation 1: source
15121512
src_pg = self.make_simple_node(

tests/compatibility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def test_backward_compatibility_ptrack(self):
366366
"""Description in jira issue PGPRO-434"""
367367

368368
if not self.ptrack:
369-
return unittest.skip('Skipped because ptrack support is disabled')
369+
self.skipTest('Skipped because ptrack support is disabled')
370370

371371
fname = self.id().split('.')[3]
372372
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')

tests/delete.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def test_delete_increment_page(self):
189189
def test_delete_increment_ptrack(self):
190190
"""delete increment and all after him"""
191191
if not self.ptrack:
192-
return unittest.skip('Skipped because ptrack support is disabled')
192+
self.skipTest('Skipped because ptrack support is disabled')
193193

194194
fname = self.id().split('.')[3]
195195
node = self.make_simple_node(

tests/external.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,7 @@ def test_external_dir_is_symlink(self):
15351535
but restored as directory
15361536
"""
15371537
if os.name == 'nt':
1538-
return unittest.skip('Skipped for Windows')
1538+
self.skipTest('Skipped for Windows')
15391539

15401540
fname = self.id().split('.')[3]
15411541
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@@ -1618,7 +1618,7 @@ def test_external_dir_contain_symlink_on_dir(self):
16181618
but restored as directory
16191619
"""
16201620
if os.name == 'nt':
1621-
return unittest.skip('Skipped for Windows')
1621+
self.skipTest('Skipped for Windows')
16221622

16231623
fname = self.id().split('.')[3]
16241624
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@@ -1703,7 +1703,7 @@ def test_external_dir_contain_symlink_on_file(self):
17031703
but restored as directory
17041704
"""
17051705
if os.name == 'nt':
1706-
return unittest.skip('Skipped for Windows')
1706+
self.skipTest('Skipped for Windows')
17071707

17081708
fname = self.id().split('.')[3]
17091709
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')

tests/helpers/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
__all__ = ['ptrack_helpers', 'cfs_helpers', 'expected_errors']
2-
#from . import *
2+
3+
import unittest
4+
5+
# python 2.7 compatibility
6+
if not hasattr(unittest.TestCase, "skipTest"):
7+
def skipTest(self, reason):
8+
raise unittest.SkipTest(reason)
9+
unittest.TestCase.skipTest = skipTest

tests/helpers/ptrack_helpers.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,7 @@ def __init__(self, *args, **kwargs):
242242
self.user = self.get_username()
243243
self.probackup_path = None
244244
if 'PGPROBACKUPBIN' in self.test_env:
245-
if (
246-
os.path.isfile(self.test_env["PGPROBACKUPBIN"]) and
247-
os.access(self.test_env["PGPROBACKUPBIN"], os.X_OK)
248-
):
245+
if shutil.which(self.test_env["PGPROBACKUPBIN"]):
249246
self.probackup_path = self.test_env["PGPROBACKUPBIN"]
250247
else:
251248
if self.verbose:

tests/merge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ def test_merge_ptrack_truncate(self):
796796
restore last page backup and check data correctness
797797
"""
798798
if not self.ptrack:
799-
return unittest.skip('Skipped because ptrack support is disabled')
799+
self.skipTest('Skipped because ptrack support is disabled')
800800

801801
fname = self.id().split('.')[3]
802802
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')

0 commit comments

Comments
 (0)