Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.toolbox
Commits
cc02d299
Commit
cc02d299
authored
Oct 31, 2018
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
several fixes
parent
676aba12
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
14 deletions
+16
-14
slapos/resilient/runner_exporter.py
slapos/resilient/runner_exporter.py
+6
-4
slapos/test/test_runner_exporter.py
slapos/test/test_runner_exporter.py
+10
-10
No files found.
slapos/resilient/runner_exporter.py
View file @
cc02d299
...
...
@@ -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
...
...
slapos/test/test_runner_exporter.py
View file @
cc02d299
...
...
@@ -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'
]
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment