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
cb5929da
Commit
cb5929da
authored
Apr 04, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Setup module tests
parent
c71afe35
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
3 deletions
+31
-3
library/setup
+4
-3
test/TestRunner.py
+27
-0
No files found.
library/setup
View file @
cb5929da
...
...
@@ -46,7 +46,7 @@ md5sum = None
if
not
os
.
path
.
exists
(
ansible_file
):
changed
=
True
else
:
md5sum
=
os
.
popen
(
"md5sum
%
s"
%
ansible_file
)
.
read
()
md5sum
=
os
.
popen
(
"md5sum
%
s"
%
ansible_file
)
.
read
()
.
split
()[
0
]
# if facter is installed, and we can use --json because
# ruby-json is ALSO installed, include facter data in the JSON
...
...
@@ -91,14 +91,15 @@ reformat = json.dumps(new_options, sort_keys=True, indent=4)
f
.
write
(
reformat
)
f
.
close
()
md5sum2
=
os
.
popen
(
"md5sum
%
s"
%
ansible_file
)
.
read
()
md5sum2
=
os
.
popen
(
"md5sum
%
s"
%
ansible_file
)
.
read
()
.
split
()[
0
]
if
md5sum
!=
md5sum2
:
changed
=
True
result
=
{
"written"
:
ansible_file
,
"changed"
:
changed
,
"md5sum"
:
md5sum
"md5sum"
:
md5sum
2
}
print
json
.
dumps
(
result
)
test/TestRunner.py
View file @
cb5929da
...
...
@@ -9,6 +9,10 @@ import ansible.runner
import
os
import
shutil
import
time
try
:
import
json
except
:
import
simplejson
as
json
class
TestRunner
(
unittest
.
TestCase
):
...
...
@@ -138,6 +142,20 @@ class TestRunner(unittest.TestCase):
assert
'failed'
in
result
assert
'rc'
not
in
result
def
test_setup
(
self
):
output
=
self
.
_get_stage_file
(
'output.json'
)
result
=
self
.
_run
(
'setup'
,
[
"metadata=
%
s"
%
output
,
"a=2"
,
"b=3"
,
"c=4"
])
assert
'failed'
not
in
result
assert
'md5sum'
in
result
assert
result
[
'changed'
]
==
True
outds
=
json
.
loads
(
file
(
output
)
.
read
())
assert
outds
[
'c'
]
==
'4'
# not bothering to test change hooks here since ohai/facter results change
# almost every time so changed is always true, this just tests that
# rewriting the file is ok
result
=
self
.
_run
(
'setup'
,
[
"metadata=
%
s"
%
output
,
"a=2"
,
"b=3"
,
"c=4"
])
assert
'md5sum'
in
result
def
test_async
(
self
):
# test async launch and job status
# of any particular module
...
...
@@ -157,3 +175,12 @@ class TestRunner(unittest.TestCase):
assert
'stdout'
in
result
assert
result
[
'ansible_job_id'
]
==
jid
def
test_git
(
self
):
# TODO: tests for the git module
pass
def
test_service
(
self
):
# TODO: tests for the service module
pass
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