Commit 134db22b authored by Nicolas Wavrant's avatar Nicolas Wavrant

decrease the number of calls to rsync

parent aec0ea6f
......@@ -75,7 +75,10 @@ def rsync(rsync_binary, source, destination, extra_args=None, dry=False):
]
if isinstance(extra_args, list):
arg_list.extend(extra_args)
arg_list.append(source)
if isinstance(source, list):
arg_list.extend(source)
else:
arg_list.append(source)
arg_list.append(destination)
if dry:
......@@ -143,27 +146,28 @@ def getSha256Sum(file_path):
def synchroniseRunnerConfigurationDirectory(config, backup_path):
rsync(config.rsync_binary, 'config.json', backup_path, dry=config.dry)
for hidden_file in [
x for x in os.listdir('.')
if x[0] == '.'
]:
rsync(config.rsync_binary, hidden_file, backup_path, dry=config.dry)
file_list = ['config.json']
for hidden_file in os.listdir('.'):
if hidden_file[0] == '.':
file_list.append(hidden_file)
rsync(config.rsync_binary, file_list, backup_path, dry=config.dry)
def synchroniseRunnerWorkingDirectory(config, backup_path):
if os.path.isdir('instance'):
exclude_list = getExcludePathList('.')
rsync(
config.rsync_binary, 'instance', backup_path,
["--exclude={}".format(x) for x in exclude_list],
dry=config.dry,
)
exclude_list = getExcludePathList('.')
rsync(
config.rsync_binary, 'instance', backup_path,
["--exclude={}".format(x) for x in exclude_list],
dry=config.dry,
)
file_list = []
for file in ('project', 'public', 'proxy.db'):
if os.path.exists(file):
rsync(config.rsync_binary, file, backup_path, dry=config.dry)
file_list.append(file)
if file_list:
rsync(config.rsync_binary, file_list, backup_path, dry=config.dry)
def getSlappartSignatureMethodDict():
......
......@@ -136,15 +136,9 @@ class TestRunnerExporter(unittest.TestCase):
runner_exporter.synchroniseRunnerConfigurationDirectory(
config, 'backup/runner/etc/'
)
self.assertEqual(check_call_mock.call_count, 3)
self.assertEqual(check_call_mock.call_count, 1)
check_call_mock.assert_any_call(
['rsync', '-rlptgov', '--stats', '--safe-links', '--ignore-missing-args', '--delete', '--delete-excluded', 'config.json', 'backup/runner/etc/']
)
check_call_mock.assert_any_call(
['rsync', '-rlptgov', '--stats', '--safe-links', '--ignore-missing-args', '--delete', '--delete-excluded', '.project', 'backup/runner/etc/']
)
check_call_mock.assert_any_call(
['rsync', '-rlptgov', '--stats', '--safe-links', '--ignore-missing-args', '--delete', '--delete-excluded', '.project', 'backup/runner/etc/']
['rsync', '-rlptgov', '--stats', '--safe-links', '--ignore-missing-args', '--delete', '--delete-excluded', 'config.json', '.parameters.xml', '.project', 'backup/runner/etc/']
)
......@@ -159,11 +153,12 @@ class TestRunnerExporter(unittest.TestCase):
config, 'backup/runner/runner'
)
self.assertEqual(check_call_mock.call_count, 2)
check_call_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=srv/backup/**', '--exclude=instance/slappart0/etc/nicolas.txt', '--exclude=instance/slappart0/etc/rafael.txt', '--exclude=srv/exporter.exclude', 'instance', 'backup/runner/runner']
)
check_call_mock.assert_any_call(
['rsync', '-rlptgov', '--stats', '--safe-links', '--ignore-missing-args', '--delete', '--delete-excluded', 'proxy.db', 'backup/runner/runner']
['rsync', '-rlptgov', '--stats', '--safe-links', '--ignore-missing-args', '--delete', '--delete-excluded', 'project', 'public', 'proxy.db', '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