Commit 78e2361d authored by Łukasz Nowak's avatar Łukasz Nowak

resilient: Sort rsync argument lists

source and exclude can be in artbitrary order, so sort them in order to have
stable calls.

This simplifies assertions in tests and is no-op for the code.
parent 1d7a677e
......@@ -28,7 +28,7 @@ def parseArgumentList():
return parser.parse_args()
def rsync(rsync_binary, source, destination, extra_args=None, dry=False):
def rsync(rsync_binary, source, destination, exclude_list=None, extra_args=None, dry=False):
arg_list = [
rsync_binary,
'-rlptgov',
......@@ -38,10 +38,12 @@ def rsync(rsync_binary, source, destination, extra_args=None, dry=False):
'--delete',
'--delete-excluded'
]
if isinstance(exclude_list, list):
arg_list.extend(["--exclude={}".format(x) for x in sorted(exclude_list)])
if isinstance(extra_args, list):
arg_list.extend(extra_args)
if isinstance(source, list):
arg_list.extend(source)
arg_list.extend(sorted(source))
else:
arg_list.append(source)
arg_list.append(destination)
......@@ -89,7 +91,7 @@ def synchroniseRunnerWorkingDirectory(config, backup_path):
if file_list:
rsync(
config.rsync_binary, file_list, backup_path,
["--exclude={}".format(x) for x in exclude_list],
exclude_list=exclude_list,
dry=config.dry
)
......
......@@ -138,7 +138,7 @@ class TestRunnerExporter(unittest.TestCase):
)
self.assertEqual(check_output_mock.call_count, 1)
check_output_mock.assert_any_call(
['rsync', '-rlptgov', '--stats', '--safe-links', '--ignore-missing-args', '--delete', '--delete-excluded', 'config.json', '.parameters.xml', '.project', 'backup/runner/etc/']
['rsync', '-rlptgov', '--stats', '--safe-links', '--ignore-missing-args', '--delete', '--delete-excluded', '.parameters.xml', '.project', 'config.json', 'backup/runner/etc/']
)
......@@ -155,7 +155,7 @@ class TestRunnerExporter(unittest.TestCase):
self.assertEqual(check_output_mock.call_count, 1)
check_output_mock.assert_any_call(
['rsync', '-rlptgov', '--stats', '--safe-links', '--ignore-missing-args', '--delete', '--delete-excluded', '--exclude=*.sock', '--exclude=*.socket', '--exclude=*.pid', '--exclude=.installed*.cfg', '--exclude=instance/slappart0/srv/backup/**', '--exclude=instance/slappart0/etc/nicolas.txt', '--exclude=instance/slappart0/etc/rafael.txt', '--exclude=instance/slappart0/srv/exporter.exclude', 'instance', 'project', 'public', 'proxy.db', 'backup/runner/runner']
['rsync', '-rlptgov', '--stats', '--safe-links', '--ignore-missing-args', '--delete', '--delete-excluded', '--exclude=*.pid', '--exclude=*.sock', '--exclude=*.socket', '--exclude=.installed*.cfg', '--exclude=instance/slappart0/etc/nicolas.txt', '--exclude=instance/slappart0/etc/rafael.txt', '--exclude=instance/slappart0/srv/backup/**', '--exclude=instance/slappart0/srv/exporter.exclude', 'instance', 'project', 'proxy.db', 'public', 'backup/runner/runner']
)
def test_getSlappartSignatureMethodDict(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment