Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos.core
Commits
d5935fc7
Commit
d5935fc7
authored
Sep 24, 2021
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Plain Diff
grid: fix "log buildout output in realtime"
See merge request
!333
parents
1b95f815
f9ad242a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
2 deletions
+35
-2
slapos/grid/utils.py
slapos/grid/utils.py
+1
-0
slapos/tests/test_grid_utils.py
slapos/tests/test_grid_utils.py
+34
-2
No files found.
slapos/grid/utils.py
View file @
d5935fc7
...
...
@@ -104,6 +104,7 @@ def logAndAccumulateOutput(process_stdout, buffer, logger):
for
current_output_line
in
current_output
.
splitlines
(
True
):
if
current_output_line
.
endswith
(
'
\
n
'
):
logger
.
info
(
current_output_line
.
rstrip
(
'
\
n
'
))
current_output
=
''
else
:
current_output
=
current_output_line
...
...
slapos/tests/test_grid_utils.py
View file @
d5935fc7
...
...
@@ -61,7 +61,7 @@ class SlapPopenTestCase(unittest.TestCase):
self
.
assertEqual
(
'hello
\
n
'
,
program
.
output
)
# output is also logged "live"
logger
.
info
.
assert_called_with
(
'hello'
)
logger
.
info
.
assert_called_
once_
with
(
'hello'
)
def
test_exec_multiline
(
self
):
self
.
script
.
write
(
textwrap
.
dedent
(
'''
\
...
...
@@ -82,6 +82,25 @@ class SlapPopenTestCase(unittest.TestCase):
self
.
assertEqual
(
'hello
\
n
world
\
n
'
,
program
.
output
)
self
.
assertEqual
(
logger
.
info
.
call_args_list
,
[
mock
.
call
(
'hello'
),
mock
.
call
(
'world'
)])
def
test_exec_large_output_multiline
(
self
):
output_line_list
=
[
str
(
x
)
for
x
in
range
(
100
)]
self
.
script
.
write
((
'
\
n
'
.
join
(
[
'#!/bin/sh'
]
+
[
'echo '
+
x
for
x
in
output_line_list
]
)).
encode
())
self
.
script
.
close
()
logger
=
mock
.
MagicMock
()
program
=
slapos
.
grid
.
utils
.
SlapPopen
(
self
.
script
.
name
,
logger
=
logger
)
self
.
assertEqual
(
"
\
n
"
.
join
(
output_line_list
)
+
'
\
n
'
,
program
.
output
)
self
.
assertEqual
(
logger
.
info
.
call_args_list
,
[
mock
.
call
(
x
)
for
x
in
output_line_list
])
def
test_exec_non_ascii
(
self
):
self
.
script
.
write
(
b'#!/bin/sh
\
n
echo h
\
xc3
\
xa9
h
\
xc3
\
xa9
'
)
self
.
script
.
close
()
...
...
@@ -92,7 +111,20 @@ class SlapPopenTestCase(unittest.TestCase):
logger
=
logger
)
self
.
assertEqual
(
'héhé
\
n
'
,
program
.
output
)
logger
.
info
.
assert_called_with
(
'héhé'
)
logger
.
info
.
assert_called_once_with
(
'héhé'
)
def
test_exec_large_output
(
self
):
large_output
=
'x'
*
10000
self
.
script
.
write
((
'#!/bin/sh
\
n
echo %s'
%
large_output
).
encode
())
self
.
script
.
close
()
logger
=
mock
.
MagicMock
()
program
=
slapos
.
grid
.
utils
.
SlapPopen
(
self
.
script
.
name
,
logger
=
logger
)
self
.
assertEqual
(
large_output
+
'
\
n
'
,
program
.
output
)
logger
.
info
.
assert_called_once_with
(
large_output
)
def
test_debug
(
self
):
"""Test debug=True, which keeps interactive.
...
...
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