mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-28 13:21:25 -07:00
Don't immediately return failed for any_errors_fatal tasks
Instead of immediately returning a failed code (indicating a break in the play execution), we internally 'or' that failure code with the result (now an integer flag instead of a boolean) so that we can properly handle the rescue/always portions of blocks and still remember that the break condition was hit. Fixes #16937
This commit is contained in:
parent
b44eb402bd
commit
c669a381d1
5 changed files with 26 additions and 25 deletions
|
@ -60,6 +60,9 @@ class TestStrategyBase(unittest.TestCase):
|
|||
mock_tqm._listening_handlers = {}
|
||||
mock_tqm.send_callback.return_value = None
|
||||
|
||||
for attr in ('RUN_OK', 'RUN_ERROR', 'RUN_FAILED_HOSTS', 'RUN_UNREACHABLE_HOSTS'):
|
||||
setattr(mock_tqm, attr, getattr(TaskQueueManager, attr))
|
||||
|
||||
mock_iterator = MagicMock()
|
||||
mock_iterator._play = MagicMock()
|
||||
mock_iterator._play.handlers = []
|
||||
|
@ -77,7 +80,7 @@ class TestStrategyBase(unittest.TestCase):
|
|||
mock_host.name = 'host1'
|
||||
|
||||
self.assertEqual(strategy_base.run(iterator=mock_iterator, play_context=mock_play_context), mock_tqm.RUN_OK)
|
||||
self.assertEqual(strategy_base.run(iterator=mock_iterator, play_context=mock_play_context, result=False), mock_tqm.RUN_ERROR)
|
||||
self.assertEqual(strategy_base.run(iterator=mock_iterator, play_context=mock_play_context, result=TaskQueueManager.RUN_ERROR), mock_tqm.RUN_ERROR)
|
||||
mock_tqm._failed_hosts = dict(host1=True)
|
||||
mock_iterator.get_failed_hosts.return_value = [mock_host]
|
||||
self.assertEqual(strategy_base.run(iterator=mock_iterator, play_context=mock_play_context, result=False), mock_tqm.RUN_FAILED_HOSTS)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue