Skip to content

Commit 3831039

Browse files
committed
Fixes if tests/archive.py for passing tests on Windows
1 parent 4194d7e commit 3831039

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

Diff for: tests/archive.py

+15-7
Original file line numberDiff line numberDiff line change
@@ -1845,8 +1845,15 @@ def test_undefined_wal_file_path(self):
18451845
self.init_pb(backup_dir)
18461846
self.add_instance(backup_dir, 'node', node)
18471847
self.set_archiving(backup_dir, 'node', node)
1848-
archive_command = '\"{0}\" archive-push -B \"{1}\" --instance \"{2}\" --wal-file-name=%f'.format(
1849-
self.probackup_path, backup_dir, 'node')
1848+
if os.name == 'posix':
1849+
archive_command = '\"{0}\" archive-push -B \"{1}\" --instance \"{2}\" --wal-file-name=%f'.format(
1850+
self.probackup_path, backup_dir, 'node')
1851+
elif os.name == 'nt':
1852+
archive_command = '\"{0}\" archive-push -B \"{1}\" --instance \"{2}\" --wal-file-name=%f'.format(
1853+
self.probackup_path, backup_dir, 'node').replace("\\","\\\\")
1854+
else:
1855+
self.assertTrue(False, 'Unexpected os family')
1856+
18501857
self.set_auto_conf(
18511858
node,
18521859
{'archive_command': archive_command})
@@ -1892,7 +1899,7 @@ def test_intermediate_archiving(self):
18921899
if os.name == 'posix':
18931900
self.set_archiving(backup_dir, 'node', node, custom_archive_command='cp -v %p {0}/%f'.format(wal_dir))
18941901
elif os.name == 'nt':
1895-
self.set_archiving(backup_dir, 'node', node, custom_archive_command='xcopy /F "%p" "{0}\\%f"'.format(wal_dir.replace("\\","\\\\")))
1902+
self.set_archiving(backup_dir, 'node', node, custom_archive_command='copy /Y "%p" "{0}\\\\%f"'.format(wal_dir.replace("\\","\\\\")))
18961903
else:
18971904
self.assertTrue(False, 'Unexpected os family')
18981905

@@ -1919,10 +1926,6 @@ def test_waldir_outside_pgdata_archiving(self):
19191926
"""
19201927
check that archive-push works correct with symlinked waldir
19211928
"""
1922-
if self.pg_config_version < self.version_to_num('10.0'):
1923-
return unittest.skip(
1924-
'Skipped because waldir outside pgdata is supported since PG 10')
1925-
19261929
fname = self.id().split('.')[3]
19271930
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
19281931
external_wal_dir = os.path.join(self.tmp_path, module_name, fname, 'ext_wal_dir')
@@ -1932,6 +1935,11 @@ def test_waldir_outside_pgdata_archiving(self):
19321935
base_dir=os.path.join(module_name, fname, 'node'),
19331936
initdb_params=['--data-checksums', '--waldir={0}'.format(external_wal_dir)])
19341937

1938+
if self.get_version(node) < self.version_to_num('10.0'):
1939+
self.del_test_dir(module_name, fname)
1940+
return unittest.skip(
1941+
'Skipped because waldir outside pgdata is supported since PG 10')
1942+
19351943
self.init_pb(backup_dir)
19361944
self.add_instance(backup_dir, 'node', node)
19371945
self.set_archiving(backup_dir, 'node', node)

0 commit comments

Comments
 (0)