Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b7a9a20

Browse files
committed
tests: fixes for Windows
1 parent e771c97 commit b7a9a20

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

tests/delete.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ def test_delete_increment_ptrack(self):
148148

149149
# full backup mode
150150
self.backup_node(backup_dir, 'node', node)
151-
# page backup mode
151+
# ptrack backup mode
152152
self.backup_node(backup_dir, 'node', node, backup_type="ptrack")
153-
# page backup mode
153+
# ptrack backup mode
154154
self.backup_node(backup_dir, 'node', node, backup_type="ptrack")
155155
# full backup mode
156156
self.backup_node(backup_dir, 'node', node)
@@ -249,8 +249,7 @@ def test_delete_backup_with_empty_control_file(self):
249249
node = self.make_simple_node(
250250
base_dir=os.path.join(module_name, fname, 'node'),
251251
initdb_params=['--data-checksums'],
252-
set_replication=True,
253-
pg_options={'ptrack_enable': 'on'})
252+
set_replication=True)
254253

255254
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
256255
self.init_pb(backup_dir)

tests/delta.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,9 @@ def test_delta_nullified_heap_page_backup(self):
12681268
backup_dir, 'node', node)
12691269

12701270
# Nullify some block in PostgreSQL
1271-
file = os.path.join(node.data_dir, file_path)
1271+
file = os.path.join(node.data_dir, file_path).replace("\\","/")
1272+
if os.name == 'nt':
1273+
file = file.replace("\\","/")
12721274

12731275
with open(file, 'r+b', 0) as f:
12741276
f.seek(8192)
@@ -1286,10 +1288,14 @@ def test_delta_nullified_heap_page_backup(self):
12861288
if not self.remote:
12871289
log_file_path = os.path.join(backup_dir, "log", "pg_probackup.log")
12881290
with open(log_file_path) as f:
1289-
self.assertTrue("LOG: File: {0} blknum 1, empty page".format(
1290-
file) in f.read())
1291-
self.assertFalse("Skipping blknum: 1 in file: {0}".format(
1292-
file) in f.read())
1291+
content = f.read()
1292+
1293+
self.assertIn(
1294+
"LOG: File: {0} blknum 1, empty page".format(file),
1295+
content)
1296+
self.assertNotIn(
1297+
"Skipping blknum: 1 in file: {0}".format(file),
1298+
content)
12931299

12941300
# Restore DELTA backup
12951301
node_restored = self.make_simple_node(

tests/merge.py

-7
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ def test_merge_tablespaces(self):
485485
base_dir=os.path.join(module_name, fname, 'node'),
486486
set_replication=True, initdb_params=['--data-checksums'],
487487
pg_options={
488-
'max_wal_senders': '2',
489488
'autovacuum': 'off'
490489
}
491490
)
@@ -564,7 +563,6 @@ def test_merge_tablespaces_1(self):
564563
base_dir=os.path.join(module_name, fname, 'node'),
565564
set_replication=True, initdb_params=['--data-checksums'],
566565
pg_options={
567-
'max_wal_senders': '2',
568566
'autovacuum': 'off'
569567
}
570568
)
@@ -648,7 +646,6 @@ def test_merge_page_truncate(self):
648646
set_replication=True,
649647
initdb_params=['--data-checksums'],
650648
pg_options={
651-
'max_wal_senders': '2',
652649
'checkpoint_timeout': '300s',
653650
'autovacuum': 'off'
654651
}
@@ -742,7 +739,6 @@ def test_merge_delta_truncate(self):
742739
set_replication=True,
743740
initdb_params=['--data-checksums'],
744741
pg_options={
745-
'max_wal_senders': '2',
746742
'checkpoint_timeout': '300s',
747743
'autovacuum': 'off'
748744
}
@@ -836,7 +832,6 @@ def test_merge_ptrack_truncate(self):
836832
set_replication=True,
837833
initdb_params=['--data-checksums'],
838834
pg_options={
839-
'max_wal_senders': '2',
840835
'checkpoint_timeout': '300s',
841836
'autovacuum': 'off',
842837
'ptrack_enable': 'on'
@@ -930,7 +925,6 @@ def test_merge_delta_delete(self):
930925
base_dir=os.path.join(module_name, fname, 'node'),
931926
set_replication=True, initdb_params=['--data-checksums'],
932927
pg_options={
933-
'max_wal_senders': '2',
934928
'checkpoint_timeout': '30s',
935929
'autovacuum': 'off'
936930
}
@@ -1683,7 +1677,6 @@ def test_merge_backup_from_future(self):
16831677
set_replication=True,
16841678
initdb_params=['--data-checksums'],
16851679
pg_options={
1686-
'max_wal_senders': '2',
16871680
'autovacuum': 'off'})
16881681

16891682
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')

tests/page.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ def test_page_backup_with_alien_wal_segment(self):
911911
"create table t_heap_alien as select i as id, "
912912
"md5(i::text) as text, "
913913
"md5(repeat(i::text,10))::tsvector as tsvector "
914-
"from generate_series(0,1000) i;")
914+
"from generate_series(0,100000) i;")
915915

916916
# copy lastest wal segment
917917
wals_dir = os.path.join(backup_dir, 'wal', 'alien_node')
@@ -925,6 +925,7 @@ def test_page_backup_with_alien_wal_segment(self):
925925
# file = os.path.join(wals_dir, '000000010000000000000004')
926926
print(file)
927927
print(file_destination)
928+
os.remove(file_destination)
928929
os.rename(file, file_destination)
929930

930931
# Single-thread PAGE backup
@@ -944,8 +945,7 @@ def test_page_backup_with_alien_wal_segment(self):
944945
'Could not read WAL record at' in e.message and
945946
'WAL file is from different database system: WAL file database system identifier is' in e.message and
946947
'pg_control database system identifier is' in e.message and
947-
'Possible WAL corruption. Error has occured during reading WAL segment "{0}"'.format(
948-
file_destination) in e.message,
948+
'Possible WAL corruption. Error has occured during reading WAL segment' in e.message,
949949
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
950950
repr(e.message), self.cmd))
951951

@@ -971,8 +971,7 @@ def test_page_backup_with_alien_wal_segment(self):
971971
'Could not read WAL record at' in e.message and
972972
'WAL file is from different database system: WAL file database system identifier is' in e.message and
973973
'pg_control database system identifier is' in e.message and
974-
'Possible WAL corruption. Error has occured during reading WAL segment "{0}"'.format(
975-
file_destination) in e.message,
974+
'Possible WAL corruption. Error has occured during reading WAL segment' in e.message,
976975
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
977976
repr(e.message), self.cmd))
978977

tests/retention.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,8 @@ def test_window_merge_multiple_descendants(self):
762762
fname = self.id().split('.')[3]
763763
node = self.make_simple_node(
764764
base_dir=os.path.join(module_name, fname, 'node'),
765-
initdb_params=['--data-checksums'])
765+
initdb_params=['--data-checksums'],
766+
pg_options={'autovacuum': 'off'})
766767

767768
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
768769
self.init_pb(backup_dir)

0 commit comments

Comments
 (0)