Merge "Protect 'show' and 'index' with Retry decorator" into stable/liberty

This commit is contained in:
Jenkins 2016-02-12 14:00:38 +00:00 committed by Gerrit Code Review
commit 61a26e7c38
2 changed files with 17 additions and 0 deletions

View File

@ -332,6 +332,7 @@ class Controller(object):
if hasattr(self, '_nova_notifier'):
self._nova_notifier.send_network_change(action, orig, returned)
@db_api.retry_db_errors
def index(self, request, **kwargs):
"""Returns a list of the requested entity."""
parent_id = kwargs.get(self._parent_id_name)
@ -339,6 +340,7 @@ class Controller(object):
policy.init()
return self._items(request, True, parent_id)
@db_api.retry_db_errors
def show(self, request, id, **kwargs):
"""Returns detailed information about the requested entity."""
try:

View File

@ -17,6 +17,7 @@ import os
import mock
from oslo_config import cfg
from oslo_db import exception as db_exc
from oslo_policy import policy as oslo_policy
from oslo_utils import uuidutils
import six
@ -1112,6 +1113,20 @@ class JSONV2TestCase(APIv2TestBase, testlib_api.WebTestCase):
expect_errors=True)
self.assertEqual(res.status_int, 400)
def test_retry_on_index(self):
instance = self.plugin.return_value
instance.get_networks.side_effect = [db_exc.RetryRequest(None), []]
api = webtest.TestApp(router.APIRouter())
api.get(_get_path('networks', fmt=self.fmt))
self.assertTrue(instance.get_networks.called)
def test_retry_on_show(self):
instance = self.plugin.return_value
instance.get_network.side_effect = [db_exc.RetryRequest(None), {}]
api = webtest.TestApp(router.APIRouter())
api.get(_get_path('networks', _uuid(), fmt=self.fmt))
self.assertTrue(instance.get_network.called)
class SubresourceTest(base.BaseTestCase):
def setUp(self):