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
fae3a718
Commit
fae3a718
authored
Apr 04, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP on async tests
parent
f8eab8ed
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
8 deletions
+24
-8
lib/ansible/runner.py
+3
-2
test/TestRunner.py
+21
-6
No files found.
lib/ansible/runner.py
View file @
fae3a718
...
...
@@ -202,7 +202,8 @@ class Runner(object):
'''
runs a module that has already been transferred
'''
args
=
" "
.
join
(
module_args
)
args
=
[
str
(
x
)
for
x
in
module_args
]
args
=
" "
.
join
(
args
)
cmd
=
"
%
s
%
s"
%
(
remote_module_path
,
args
)
result
=
self
.
_exec_command
(
conn
,
cmd
)
self
.
_delete_remote_files
(
conn
,
[
tmp
])
...
...
@@ -226,7 +227,7 @@ class Runner(object):
async
=
self
.
_transfer_module
(
conn
,
tmp
,
'async_wrapper'
)
module
=
self
.
_transfer_module
(
conn
,
tmp
,
self
.
module_name
)
new_args
=
[]
new_args
=
[
self
.
generated_jid
,
module
,
self
.
background
]
new_args
=
[
self
.
generated_jid
,
self
.
background
,
module
]
new_args
.
extend
(
self
.
module_args
)
result
=
self
.
_execute_module
(
conn
,
tmp
,
async
,
new_args
)
return
self
.
_return_from_module
(
conn
,
host
,
result
)
...
...
test/TestRunner.py
View file @
fae3a718
...
...
@@ -8,6 +8,7 @@ import getpass
import
ansible.runner
import
os
import
shutil
import
time
class
TestRunner
(
unittest
.
TestCase
):
...
...
@@ -50,10 +51,11 @@ class TestRunner(unittest.TestCase):
filename
=
os
.
path
.
join
(
self
.
stage_dir
,
filename
)
return
filename
def
_run
(
self
,
module_name
,
module_args
):
def
_run
(
self
,
module_name
,
module_args
,
background
=
0
):
''' run a module and get the localhost results '''
self
.
runner
.
module_name
=
module_name
self
.
runner
.
module_args
=
module_args
self
.
runner
.
background
=
background
results
=
self
.
runner
.
run
()
print
"RESULTS=
%
s"
%
results
assert
"127.0.0.1"
in
results
[
'contacted'
]
...
...
@@ -137,9 +139,22 @@ class TestRunner(unittest.TestCase):
def
test_async
(
self
):
# test async launch and job status
# of any particular module
pass
result
=
self
.
_run
(
'command'
,
[
"/bin/sleep"
,
"10"
],
background
=
20
)
print
"RESULT1=
%
s"
%
result
assert
'ansible_job_id'
in
result
assert
'started'
in
result
jid
=
result
[
'ansible_job_id'
]
# no real chance of this op taking a while, but whatever
time
.
sleep
(
1
)
# TODO: verify we are still running
time
.
sleep
(
12
)
# CLI will abstract this, but this is how it works internally
result
=
self
.
_run
(
'async_status'
,
[
"jid=
%
s"
%
ansible_job_id
])
# TODO: would be nice to have tests for supervisory process
# killing job after X seconds
assert
'finished'
in
result
assert
'failed'
not
in
result
assert
'rc'
in
result
assert
'stdout'
in
result
assert
result
[
'ansible_job_id'
]
==
jid
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