summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJames Cammarata <jimi@sngx.net>2016-06-08 10:11:34 -0500
committerJames Cammarata <jimi@sngx.net>2016-06-08 10:44:59 -0500
commit2e003adbc8c14d815d9a1763c222a344a7267ad4 (patch)
tree5e4f12ff78f372197fec7289eb703e74e76d692a /test
parentd4c78b84f0df79b2bff6590e71177bd2d7cd01f9 (diff)
downloadansible-2e003adbc8c14d815d9a1763c222a344a7267ad4.tar.gz
Expand return code values returned by TQM and strategies
This allows the PlaybookExecutor to receive more information regarding what happened internal to the TaskQueueManager and strategy, to determine things like whether or not the play iteration should stop. Fixes #15523 (cherry picked from commit fbec2d9692cdbbddda1f6ecb68bbca67e3b783b4)
Diffstat (limited to 'test')
-rw-r--r--test/units/plugins/strategies/test_strategy_base.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/test/units/plugins/strategies/test_strategy_base.py b/test/units/plugins/strategies/test_strategy_base.py
index 9ea944a2a1..338bcc1fd6 100644
--- a/test/units/plugins/strategies/test_strategy_base.py
+++ b/test/units/plugins/strategies/test_strategy_base.py
@@ -64,12 +64,17 @@ class TestStrategyBase(unittest.TestCase):
mock_tqm._options = MagicMock()
strategy_base = StrategyBase(tqm=mock_tqm)
- self.assertEqual(strategy_base.run(iterator=mock_iterator, play_context=mock_play_context), 0)
- self.assertEqual(strategy_base.run(iterator=mock_iterator, play_context=mock_play_context, result=False), 1)
+ mock_host = MagicMock()
+ 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)
mock_tqm._failed_hosts = dict(host1=True)
- self.assertEqual(strategy_base.run(iterator=mock_iterator, play_context=mock_play_context, result=False), 2)
+ 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)
mock_tqm._unreachable_hosts = dict(host1=True)
- self.assertEqual(strategy_base.run(iterator=mock_iterator, play_context=mock_play_context, result=False), 3)
+ mock_iterator.get_failed_hosts.return_value = []
+ self.assertEqual(strategy_base.run(iterator=mock_iterator, play_context=mock_play_context, result=False), mock_tqm.RUN_UNREACHABLE_HOSTS)
def test_strategy_base_get_hosts(self):
mock_hosts = []