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
6
Merge Requests
6
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
e176156e
Commit
e176156e
authored
Nov 02, 2018
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup
parent
b6f34bfd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
32 deletions
+19
-32
slapos/resilient/runner_exporter.py
slapos/resilient/runner_exporter.py
+9
-14
slapos/test/test_runner_exporter.py
slapos/test/test_runner_exporter.py
+10
-18
No files found.
slapos/resilient/runner_exporter.py
View file @
e176156e
...
...
@@ -74,20 +74,15 @@ def rsync(rsync_binary, source, destination, extra_args=None, dry=False):
print
(
'DEBUG:'
,
arg_list
)
return
rsync_process
=
subprocess
.
call
(
arg_list
)
print
(
rsync_process
.
stdout
.
read
())
# All rsync errors are not to be considered as errors
allowed_error_message_regex
=
\
'^(file has vanished: |rsync warning: some files vanished before they could be transferred)'
rsync_process_stderr
=
rsync_process
.
stderr
.
read
()
if
rsync_process
.
returncode
in
(
0
,
24
)
or
\
re
.
match
(
allowed_error_message_regex
,
rsync_process_stderr
):
return
print
(
rsync_process_stderr
)
raise
RuntimeError
(
"An issue occured when running rsync."
)
try
:
subprocess
.
check_call
(
arg_list
)
except
subprocess
.
CalledProcessError
as
e
:
# All rsync errors are not to be considered as errors
allowed_error_message_regex
=
\
'^(file has vanished: |rsync warning: some files vanished before they could be transferred)'
if
e
.
returncode
not
in
(
0
,
24
)
or
\
re
.
match
(
allowed_error_message_regex
,
e
.
output
)
is
not
None
:
raise
e
def
getExcludePathList
(
path
):
...
...
slapos/test/test_runner_exporter.py
View file @
e176156e
...
...
@@ -48,12 +48,6 @@ class Config():
pass
class
SubprocessCallReturnObject
:
returncode
=
0
stderr
=
StringIO
(
''
)
stdout
=
StringIO
(
''
)
class
TestRunnerExporter
(
unittest
.
TestCase
):
def
setUp
(
self
):
if
not
os
.
path
.
exists
(
'test_folder'
):
...
...
@@ -132,9 +126,8 @@ class TestRunnerExporter(unittest.TestCase):
)
@
mock
.
patch
(
'subprocess.call'
)
def
test_synchroniseRunnerConfigurationDirectory
(
self
,
call_mock
):
call_mock
.
return_value
=
SubprocessCallReturnObject
()
@
mock
.
patch
(
'subprocess.check_call'
)
def
test_synchroniseRunnerConfigurationDirectory
(
self
,
check_call_mock
):
self
.
_setUpFakeInstanceFolder
()
config
=
Config
()
config
.
rsync_binary
=
'rsync'
...
...
@@ -143,21 +136,20 @@ class TestRunnerExporter(unittest.TestCase):
runner_exporter
.
synchroniseRunnerConfigurationDirectory
(
config
,
'backup/runner/etc/'
)
self
.
assertEqual
(
call_mock
.
call_count
,
3
)
call_mock
.
assert_any_call
(
self
.
assertEqual
(
c
heck_c
all_mock
.
call_count
,
3
)
c
heck_c
all_mock
.
assert_any_call
(
[
'rsync'
,
'-rlptgov'
,
'--stats'
,
'--safe-links'
,
'--ignore-missing-args'
,
'--delete'
,
'--delete-excluded'
,
'config.json'
,
'backup/runner/etc/'
]
)
call_mock
.
assert_any_call
(
c
heck_c
all_mock
.
assert_any_call
(
[
'rsync'
,
'-rlptgov'
,
'--stats'
,
'--safe-links'
,
'--ignore-missing-args'
,
'--delete'
,
'--delete-excluded'
,
'.project'
,
'backup/runner/etc/'
]
)
call_mock
.
assert_any_call
(
c
heck_c
all_mock
.
assert_any_call
(
[
'rsync'
,
'-rlptgov'
,
'--stats'
,
'--safe-links'
,
'--ignore-missing-args'
,
'--delete'
,
'--delete-excluded'
,
'.project'
,
'backup/runner/etc/'
]
)
@
mock
.
patch
(
'subprocess.call'
)
def
test_synchroniseRunnerWorkingDirectory
(
self
,
call_mock
):
call_mock
.
return_value
=
SubprocessCallReturnObject
()
@
mock
.
patch
(
'subprocess.check_call'
)
def
test_synchroniseRunnerWorkingDirectory
(
self
,
check_call_mock
):
self
.
_setUpFakeInstanceFolder
()
config
=
Config
()
config
.
rsync_binary
=
'rsync'
...
...
@@ -167,10 +159,10 @@ class TestRunnerExporter(unittest.TestCase):
config
,
'backup/runner/runner'
)
call_mock
.
assert_any_call
(
c
heck_c
all_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'
]
)
call_mock
.
assert_any_call
(
c
heck_c
all_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