Fix stack_get_all call on stack watcher

This reverts the Engine.start() behavior to what it was before the patch
Ifdcfc44a3483a089ae803cfd044151262957674a.

Co-Authored-By: Richard Lee <rblee88@gmail.com>
Closes-Bug: #1285681
Change-Id: I47891c41fd345fe614675aeb9f82ff5d74d50a76
This commit is contained in:
Anderson Mesquita 2014-02-21 14:58:59 -05:00
parent cc1d2dddfb
commit 78ce3328c4
2 changed files with 24 additions and 1 deletions

View File

@ -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)

View File

@ -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')