Merge "Fix stack_get_all call on stack watcher"
This commit is contained in:
commit
0429fa8d50
@ -236,7 +236,7 @@ class EngineService(service.Service):
|
||||
|
||||
# Create a periodic_watcher_task per-stack
|
||||
admin_context = context.get_admin_context()
|
||||
stacks = db_api.stack_get_all(admin_context)
|
||||
stacks = db_api.stack_get_all(admin_context, tenant_safe=False)
|
||||
for s in stacks:
|
||||
self._start_watch_task(s.id, admin_context)
|
||||
|
||||
|
@ -1403,6 +1403,29 @@ class StackServiceTest(HeatTestCase):
|
||||
|
||||
utils.setup_dummy_db()
|
||||
|
||||
@mock.patch.object(service.db_api, 'stack_get_all')
|
||||
@mock.patch.object(service.service.Service, 'start')
|
||||
def test_start_gets_all_stacks(self, mock_super_start, mock_stack_get_all):
|
||||
mock_stack_get_all.return_value = []
|
||||
|
||||
self.eng.start()
|
||||
mock_stack_get_all.assert_called_once_with(mock.ANY, tenant_safe=False)
|
||||
|
||||
@mock.patch.object(service.db_api, 'stack_get_all')
|
||||
@mock.patch.object(service.service.Service, 'start')
|
||||
def test_start_watches_all_stacks(self, mock_super_start, mock_get_all):
|
||||
s1 = mock.Mock(id=1)
|
||||
s2 = mock.Mock(id=2)
|
||||
mock_get_all.return_value = [s1, s2]
|
||||
mock_watch = mock.Mock()
|
||||
self.eng._start_watch_task = mock_watch
|
||||
|
||||
self.eng.start()
|
||||
calls = mock_watch.call_args_list
|
||||
self.assertEqual(2, mock_watch.call_count)
|
||||
self.assertIn(mock.call(1, mock.ANY), calls)
|
||||
self.assertIn(mock.call(2, mock.ANY), calls)
|
||||
|
||||
@stack_context('service_identify_test_stack', False)
|
||||
def test_stack_identify(self):
|
||||
self.m.StubOutWithMock(parser.Stack, 'load')
|
||||
|
Loading…
Reference in New Issue
Block a user