|
|
|
@ -20,7 +20,6 @@ from __future__ import (absolute_import, division, print_function)
|
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
|
|
from units.mock.loader import DictDataLoader
|
|
|
|
|
from copy import deepcopy
|
|
|
|
|
import uuid
|
|
|
|
|
|
|
|
|
|
from units.compat import unittest
|
|
|
|
@ -254,7 +253,7 @@ class TestStrategyBase(unittest.TestCase):
|
|
|
|
|
mock_task._parent = None
|
|
|
|
|
mock_task.ignore_errors = False
|
|
|
|
|
mock_task.ignore_unreachable = False
|
|
|
|
|
mock_task._uuid = uuid.uuid4()
|
|
|
|
|
mock_task._uuid = str(uuid.uuid4())
|
|
|
|
|
mock_task.loop = None
|
|
|
|
|
mock_task.copy.return_value = mock_task
|
|
|
|
|
|
|
|
|
@ -319,16 +318,17 @@ class TestStrategyBase(unittest.TestCase):
|
|
|
|
|
strategy_base._blocked_hosts['test01'] = True
|
|
|
|
|
strategy_base._pending_results = 1
|
|
|
|
|
|
|
|
|
|
mock_queued_task_cache = {
|
|
|
|
|
(mock_host.name, mock_task._uuid): {
|
|
|
|
|
'task': mock_task,
|
|
|
|
|
'host': mock_host,
|
|
|
|
|
'task_vars': {},
|
|
|
|
|
'play_context': {},
|
|
|
|
|
def mock_queued_task_cache():
|
|
|
|
|
return {
|
|
|
|
|
(mock_host.name, mock_task._uuid): {
|
|
|
|
|
'task': mock_task,
|
|
|
|
|
'host': mock_host,
|
|
|
|
|
'task_vars': {},
|
|
|
|
|
'play_context': {},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strategy_base._queued_task_cache = deepcopy(mock_queued_task_cache)
|
|
|
|
|
strategy_base._queued_task_cache = mock_queued_task_cache()
|
|
|
|
|
results = strategy_base._wait_on_pending_results(iterator=mock_iterator)
|
|
|
|
|
self.assertEqual(len(results), 1)
|
|
|
|
|
self.assertEqual(results[0], task_result)
|
|
|
|
@ -340,7 +340,7 @@ class TestStrategyBase(unittest.TestCase):
|
|
|
|
|
strategy_base._blocked_hosts['test01'] = True
|
|
|
|
|
strategy_base._pending_results = 1
|
|
|
|
|
mock_iterator.is_failed.return_value = True
|
|
|
|
|
strategy_base._queued_task_cache = deepcopy(mock_queued_task_cache)
|
|
|
|
|
strategy_base._queued_task_cache = mock_queued_task_cache()
|
|
|
|
|
results = strategy_base._wait_on_pending_results(iterator=mock_iterator)
|
|
|
|
|
self.assertEqual(len(results), 1)
|
|
|
|
|
self.assertEqual(results[0], task_result)
|
|
|
|
@ -354,7 +354,7 @@ class TestStrategyBase(unittest.TestCase):
|
|
|
|
|
queue_items.append(task_result)
|
|
|
|
|
strategy_base._blocked_hosts['test01'] = True
|
|
|
|
|
strategy_base._pending_results = 1
|
|
|
|
|
strategy_base._queued_task_cache = deepcopy(mock_queued_task_cache)
|
|
|
|
|
strategy_base._queued_task_cache = mock_queued_task_cache()
|
|
|
|
|
results = strategy_base._wait_on_pending_results(iterator=mock_iterator)
|
|
|
|
|
self.assertEqual(len(results), 1)
|
|
|
|
|
self.assertEqual(results[0], task_result)
|
|
|
|
@ -367,7 +367,7 @@ class TestStrategyBase(unittest.TestCase):
|
|
|
|
|
queue_items.append(task_result)
|
|
|
|
|
strategy_base._blocked_hosts['test01'] = True
|
|
|
|
|
strategy_base._pending_results = 1
|
|
|
|
|
strategy_base._queued_task_cache = deepcopy(mock_queued_task_cache)
|
|
|
|
|
strategy_base._queued_task_cache = mock_queued_task_cache()
|
|
|
|
|
results = strategy_base._wait_on_pending_results(iterator=mock_iterator)
|
|
|
|
|
self.assertEqual(len(results), 1)
|
|
|
|
|
self.assertEqual(results[0], task_result)
|
|
|
|
@ -377,7 +377,7 @@ class TestStrategyBase(unittest.TestCase):
|
|
|
|
|
queue_items.append(TaskResult(host=mock_host.name, task=mock_task._uuid, return_data=dict(add_host=dict(host_name='newhost01', new_groups=['foo']))))
|
|
|
|
|
strategy_base._blocked_hosts['test01'] = True
|
|
|
|
|
strategy_base._pending_results = 1
|
|
|
|
|
strategy_base._queued_task_cache = deepcopy(mock_queued_task_cache)
|
|
|
|
|
strategy_base._queued_task_cache = mock_queued_task_cache()
|
|
|
|
|
results = strategy_base._wait_on_pending_results(iterator=mock_iterator)
|
|
|
|
|
self.assertEqual(len(results), 1)
|
|
|
|
|
self.assertEqual(strategy_base._pending_results, 0)
|
|
|
|
@ -386,7 +386,7 @@ class TestStrategyBase(unittest.TestCase):
|
|
|
|
|
queue_items.append(TaskResult(host=mock_host.name, task=mock_task._uuid, return_data=dict(add_group=dict(group_name='foo'))))
|
|
|
|
|
strategy_base._blocked_hosts['test01'] = True
|
|
|
|
|
strategy_base._pending_results = 1
|
|
|
|
|
strategy_base._queued_task_cache = deepcopy(mock_queued_task_cache)
|
|
|
|
|
strategy_base._queued_task_cache = mock_queued_task_cache()
|
|
|
|
|
results = strategy_base._wait_on_pending_results(iterator=mock_iterator)
|
|
|
|
|
self.assertEqual(len(results), 1)
|
|
|
|
|
self.assertEqual(strategy_base._pending_results, 0)
|
|
|
|
@ -395,7 +395,7 @@ class TestStrategyBase(unittest.TestCase):
|
|
|
|
|
queue_items.append(TaskResult(host=mock_host.name, task=mock_task._uuid, return_data=dict(changed=True, _ansible_notify=['test handler'])))
|
|
|
|
|
strategy_base._blocked_hosts['test01'] = True
|
|
|
|
|
strategy_base._pending_results = 1
|
|
|
|
|
strategy_base._queued_task_cache = deepcopy(mock_queued_task_cache)
|
|
|
|
|
strategy_base._queued_task_cache = mock_queued_task_cache()
|
|
|
|
|
results = strategy_base._wait_on_pending_results(iterator=mock_iterator)
|
|
|
|
|
self.assertEqual(len(results), 1)
|
|
|
|
|
self.assertEqual(strategy_base._pending_results, 0)
|
|
|
|
|