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:
parent
53c6c99f2b
commit
8ec57fb155
|
@ -16,6 +16,7 @@ import mock
|
||||||
|
|
||||||
from nova.cmd import api
|
from nova.cmd import api
|
||||||
from nova import config
|
from nova import config
|
||||||
|
from nova import exception
|
||||||
from nova import test
|
from nova import test
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,3 +40,28 @@ class TestNovaAPI(test.NoDBTestCase):
|
||||||
# collide on ports.
|
# collide on ports.
|
||||||
self.flags(osapi_compute_listen_port=0)
|
self.flags(osapi_compute_listen_port=0)
|
||||||
api.main()
|
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)
|
||||||
|
|
Loading…
Reference in New Issue