Fixing some small bugs related to integration tests (v2)

This commit is contained in:
James Cammarata
2015-06-01 16:41:52 -05:00
parent 816b20af0b
commit 4bc7703db3
12 changed files with 81 additions and 39 deletions

View File

@@ -38,16 +38,21 @@ from jinja2.filters import environmentfilter
from distutils.version import LooseVersion, StrictVersion
from ansible import errors
from ansible.parsing.yaml.dumper import AnsibleDumper
from ansible.utils.hashing import md5s, checksum_s
from ansible.utils.unicode import unicode_wrap, to_unicode
UUID_NAMESPACE_ANSIBLE = uuid.UUID('361E6D51-FAEC-444A-9079-341386DA8E2E')
def to_nice_yaml(*a, **kw):
def to_yaml(a, *args, **kw):
'''Make verbose, human readable yaml'''
transformed = yaml.safe_dump(*a, indent=4, allow_unicode=True, default_flow_style=False, **kw)
transformed = yaml.dump(a, Dumper=AnsibleDumper, allow_unicode=True, **kw)
return to_unicode(transformed)
def to_nice_yaml(a, *args, **kw):
'''Make verbose, human readable yaml'''
transformed = yaml.dump(a, Dumper=AnsibleDumper, indent=4, allow_unicode=True, default_flow_style=False, **kw)
return to_unicode(transformed)
def to_json(a, *args, **kw):
@@ -288,7 +293,7 @@ class FilterModule(object):
'from_json': json.loads,
# yaml
'to_yaml': yaml.safe_dump,
'to_yaml': to_yaml,
'to_nice_yaml': to_nice_yaml,
'from_yaml': yaml.safe_load,

View File

@@ -73,24 +73,28 @@ class StrategyBase:
self._blocked_hosts = dict()
def run(self, iterator, connection_info, result=True):
# save the counts on failed/unreachable hosts, as the cleanup/handler
# methods will clear that information during their runs
num_failed = len(self._tqm._failed_hosts)
num_unreachable = len(self._tqm._unreachable_hosts)
# save the failed/unreachable hosts, as the run_handlers()
# method will clear that information during its execution
failed_hosts = self._tqm._failed_hosts.keys()
unreachable_hosts = self._tqm._unreachable_hosts.keys()
debug("running handlers")
result &= self.run_handlers(iterator, connection_info)
# now update with the hosts (if any) that failed or were
# unreachable during the handler execution phase
failed_hosts = set(failed_hosts).union(self._tqm._failed_hosts.keys())
unreachable_hosts = set(unreachable_hosts).union(self._tqm._unreachable_hosts.keys())
# send the stats callback
self._tqm.send_callback('v2_playbook_on_stats', self._tqm._stats)
if not result:
if num_unreachable > 0:
return 3
elif num_failed > 0:
return 2
else:
return 1
if len(unreachable_hosts) > 0:
return 3
elif len(failed_hosts) > 0:
return 2
elif not result:
return 1
else:
return 0
@@ -145,7 +149,7 @@ class StrategyBase:
task_result = result[1]
host = task_result._host
task = task_result._task
if result[0] == 'host_task_failed':
if result[0] == 'host_task_failed' or 'failed' in task_result._result:
if not task.ignore_errors:
debug("marking %s as failed" % host.name)
iterator.mark_host_failed(host)

View File

@@ -211,7 +211,7 @@ class StrategyModule(StrategyBase):
try:
included_files = IncludedFile.process_include_results(host_results, self._tqm, iterator=iterator, loader=self._loader)
except AnsibleError, e:
return 1
return False
if len(included_files) > 0:
noop_task = Task()
@@ -252,7 +252,7 @@ class StrategyModule(StrategyBase):
except (IOError, EOFError), e:
debug("got IOError/EOFError in task loop: %s" % e)
# most likely an abort, return failed
return 1
return False
# run the base class run() method, which executes the cleanup function
# and runs any outstanding handlers which have been triggered