Commit cc02d299 authored by Nicolas Wavrant's avatar Nicolas Wavrant

several fixes

parent 676aba12
......@@ -73,8 +73,7 @@ def rsync(rsync_binary, source, destination, extra_args=None, dry=False):
if dry:
print('DEBUG:', arg_list)
else:
rsync_process = subprocess.Popen(arg_list)
rsync_process.wait()
rsync_process = subprocess.check_call(arg_list)
# TODO : pipe stdout dans : (egrep -v "$IGNOREOUT" || true) || [ $? = "$IGNOREEXIT" ]
# with :
# IGNOREEXIT=24
......@@ -127,7 +126,7 @@ def getSha256Sum(file_path):
# TODO : introduce reading by chunk,
# otherwise reading backup files of 5Gb
# may crash the server.
# XXX : Use os.open ?
# XXX : Use os.open ?
with open(file_path, 'rb') as f:
return sha256(f.read()).hexdigest()
......@@ -183,7 +182,10 @@ def writeSignatureFile(slappart_signature_method_dict, runner_working_path, sign
# Find if special signature function should be applied
for special_slappart in special_slappart_list:
if dirpath.startswith(special_slappart):
signature_function = lambda x: getCustomSignature(os.path.join(runner_working_path, slappart_signature_method_dict[special_slappart]), x)
signature_function = lambda x: subprocess.check_output([
os.path.join(runner_working_path, slappart_signature_method_dict[special_slappart]),
x
])
break
else:
signature_function = getSha256Sum
......
......@@ -123,8 +123,8 @@ class TestRunnerExporter(unittest.TestCase):
)
@mock.patch('subprocess.Popen')
def test_synchroniseRunnerConfigurationDirectory(self, popen_mock):
@mock.patch('subprocess.check_call')
def test_synchroniseRunnerConfigurationDirectory(self, check_call_mock):
self._setUpFakeInstanceFolder()
config = Config()
config.rsync_binary = 'rsync'
......@@ -133,20 +133,20 @@ class TestRunnerExporter(unittest.TestCase):
runner_exporter.synchroniseRunnerConfigurationDirectory(
config, 'backup/runner/etc/'
)
self.assertEqual(popen_mock.call_count, 3)
popen_mock.assert_any_call(
self.assertEqual(check_call_mock.call_count, 3)
check_call_mock.assert_any_call(
['rsync', '-rlptgov', '--stats', '--safe-links', '--ignore-missing-args', '--delete', '--delete-excluded', 'config.json', 'backup/runner/etc/']
)
popen_mock.assert_any_call(
check_call_mock.assert_any_call(
['rsync', '-rlptgov', '--stats', '--safe-links', '--ignore-missing-args', '--delete', '--delete-excluded', '.project', 'backup/runner/etc/']
)
popen_mock.assert_any_call(
check_call_mock.assert_any_call(
['rsync', '-rlptgov', '--stats', '--safe-links', '--ignore-missing-args', '--delete', '--delete-excluded', '.project', 'backup/runner/etc/']
)
@mock.patch('subprocess.Popen')
def test_synchroniseRunnerWorkingDirectory(self, popen_mock):
@mock.patch('subprocess.check_call')
def test_synchroniseRunnerWorkingDirectory(self, check_call_mock):
self._setUpFakeInstanceFolder()
config = Config()
config.rsync_binary = 'rsync'
......@@ -156,10 +156,10 @@ class TestRunnerExporter(unittest.TestCase):
config, 'backup/runner/runner'
)
popen_mock.assert_any_call(
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']
)
popen_mock.assert_any_call(
check_call_mock.assert_any_call(
['rsync', '-rlptgov', '--stats', '--safe-links', '--ignore-missing-args', '--delete', '--delete-excluded', 'proxy.db', 'backup/runner/runner']
)
......
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