Test that nova-api ignores paste failures, but continues on

Change-Id: I3232016c61f7a598d15b9e8a11a9975f5cfad3d0
Related-Bug: #1572495
(cherry picked from commit 8182a55043)
This commit is contained in:
Dan Smith 2016-04-22 14:15:14 -07:00 committed by Matt Riedemann
parent 53c6c99f2b
commit 8ec57fb155
1 changed files with 26 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import mock
from nova.cmd import api
from nova import config
from nova import exception
from nova import test
@ -39,3 +40,28 @@ class TestNovaAPI(test.NoDBTestCase):
# collide on ports.
self.flags(osapi_compute_listen_port=0)
api.main()
def test_continues_on_failure(self):
count = [1, 2]
fake_server = mock.MagicMock()
fake_server.workers = 123
def fake_service(api, **kw):
while count:
count.pop()
raise exception.PasteAppNotFound(name=api, path='/')
return fake_server
self.flags(enabled_apis=['foo', 'bar', 'baz'])
with mock.patch.object(api, 'service') as mock_service:
mock_service.WSGIService.side_effect = fake_service
api.main()
mock_service.WSGIService.assert_has_calls([
mock.call('foo', use_ssl=False),
mock.call('bar', use_ssl=False),
mock.call('baz', use_ssl=False),
])
launcher = mock_service.process_launcher.return_value
launcher.launch_service.assert_called_once_with(
fake_server, workers=123)