Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
38ad3da6
Commit
38ad3da6
authored
May 11, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #365 from jkleint/devel
Fix hang on large command output.
parents
4e65b537
64673cc9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
18 deletions
+22
-18
lib/ansible/connection.py
+1
-1
test/TestRunner.py
+21
-17
No files found.
lib/ansible/connection.py
View file @
38ad3da6
...
...
@@ -164,7 +164,7 @@ class ParamikoConnection(object):
stdin
=
chan
.
makefile
(
'wb'
,
bufsize
)
stdout
=
chan
.
makefile
(
'rb'
,
bufsize
)
stderr
=
chan
.
makefile_stderr
(
'rb'
,
bufsize
)
# stderr goes to stdout when using a pty, so this will never output anything.
stderr
=
''
# stderr goes to stdout when using a pty, so this will never output anything.
return
stdin
,
stdout
,
stderr
def
put_file
(
self
,
in_path
,
out_path
):
...
...
test/TestRunner.py
View file @
38ad3da6
...
...
@@ -78,13 +78,13 @@ class TestRunner(unittest.TestCase):
return
results
[
'contacted'
][
'127.0.0.2'
]
def
test_ping
(
self
):
result
=
self
.
_run
(
'ping'
,
[])
result
=
self
.
_run
(
'ping'
,
[])
assert
"ping"
in
result
def
test_facter
(
self
):
if
not
get_binary
(
"facter"
):
raise
SkipTest
result
=
self
.
_run
(
'facter'
,
[])
result
=
self
.
_run
(
'facter'
,
[])
assert
"hostname"
in
result
# temporarily disbabled since it occasionally hangs
...
...
@@ -99,35 +99,32 @@ class TestRunner(unittest.TestCase):
def
test_copy
(
self
):
# test copy module, change trigger, etc
pass
def
test_copy
(
self
):
input
=
self
.
_get_test_file
(
'sample.j2'
)
input_
=
self
.
_get_test_file
(
'sample.j2'
)
output
=
self
.
_get_stage_file
(
'sample.out'
)
assert
not
os
.
path
.
exists
(
output
)
result
=
self
.
_run
(
'copy'
,
[
"src=
%
s"
%
input
,
"src=
%
s"
%
input_
,
"dest=
%
s"
%
output
,
])
assert
os
.
path
.
exists
(
output
)
data_in
=
file
(
input
)
.
read
()
data_in
=
file
(
input_
)
.
read
()
data_out
=
file
(
output
)
.
read
()
assert
data_in
==
data_out
assert
'failed'
not
in
result
assert
result
[
'changed'
]
==
True
assert
'md5sum'
in
result
result
=
self
.
_run
(
'copy'
,
[
"src=
%
s"
%
input
,
"src=
%
s"
%
input_
,
"dest=
%
s"
%
output
,
])
assert
result
[
'changed'
]
==
False
def
test_template
(
self
):
input
=
self
.
_get_test_file
(
'sample.j2'
)
input_
=
self
.
_get_test_file
(
'sample.j2'
)
metadata
=
self
.
_get_test_file
(
'metadata.json'
)
output
=
self
.
_get_stage_file
(
'sample.out'
)
result
=
self
.
_run
(
'template'
,
[
"src=
%
s"
%
input
,
"src=
%
s"
%
input_
,
"dest=
%
s"
%
output
,
"metadata=
%
s"
%
metadata
])
...
...
@@ -138,14 +135,13 @@ class TestRunner(unittest.TestCase):
assert
'md5sum'
in
result
assert
'failed'
not
in
result
result
=
self
.
_run
(
'template'
,
[
"src=
%
s"
%
input
,
"src=
%
s"
%
input_
,
"dest=
%
s"
%
output
,
"metadata=
%
s"
%
metadata
])
assert
result
[
'changed'
]
==
False
def
test_command
(
self
):
# test command module, change trigger, etc
result
=
self
.
_run
(
'command'
,
[
"/bin/echo"
,
"hi"
])
assert
"failed"
not
in
result
...
...
@@ -167,6 +163,14 @@ class TestRunner(unittest.TestCase):
assert
'failed'
not
in
result
assert
result
[
'rc'
]
==
0
def
test_large_output
(
self
):
# Ensure reading a large amount of output from a command doesn't hang.
result
=
self
.
_run
(
'command'
,
[
"/bin/cat"
,
"/usr/share/dict/words"
])
assert
"failed"
not
in
result
assert
"msg"
not
in
result
assert
result
[
'rc'
]
==
0
assert
len
(
result
[
'stdout'
])
>
100000
assert
result
[
'stderr'
]
==
''
def
test_setup
(
self
):
output
=
self
.
_get_stage_file
(
'output.json'
)
...
...
@@ -203,11 +207,11 @@ class TestRunner(unittest.TestCase):
assert
result
[
'ansible_job_id'
]
==
jid
def
test_fetch
(
self
):
input
=
self
.
_get_test_file
(
'sample.j2'
)
output
=
os
.
path
.
join
(
self
.
stage_dir
,
'127.0.0.2'
,
input
)
result
=
self
.
_run
(
'fetch'
,
[
"src=
%
s"
%
input
,
"dest=
%
s"
%
self
.
stage_dir
])
input_
=
self
.
_get_test_file
(
'sample.j2'
)
output
=
os
.
path
.
join
(
self
.
stage_dir
,
'127.0.0.2'
,
input_
)
result
=
self
.
_run
(
'fetch'
,
[
"src=
%
s"
%
input_
,
"dest=
%
s"
%
self
.
stage_dir
])
assert
os
.
path
.
exists
(
output
)
assert
open
(
input
)
.
read
()
==
open
(
output
)
.
read
()
assert
open
(
input_
)
.
read
()
==
open
(
output
)
.
read
()
def
test_yum
(
self
):
if
not
get_binary
(
"yum"
):
...
...
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