Browse Source

Merge "Handle errors in GETs gracefully"

changes/47/497047/3 2017.2.0
Jenkins 5 years ago committed by Gerrit Code Review
parent
commit
293e970553
  1. 1
      networking_arista/ml2/rpc/arista_json.py
  2. 27
      networking_arista/tests/unit/ml2/rpc/test_arista_json_rpc_wrapper.py

1
networking_arista/ml2/rpc/arista_json.py

@ -103,6 +103,7 @@ class AristaRPCWrapperJSON(AristaRPCWrapperBase):
# reraise the exception
with excutils.save_and_reraise_exception() as ctxt:
ctxt.reraise = True
return {} if method == 'GET' else None
def _check_if_cvx_leader(self, host):
url = 'agent/'

27
networking_arista/tests/unit/ml2/rpc/test_arista_json_rpc_wrapper.py

@ -15,6 +15,7 @@
import functools
import operator
import requests
import socket
import mock
@ -656,6 +657,32 @@ class TestAristaJSONRPCWrapper(testlib_api.SqlTestCase):
]
self._verify_send_api_request_call(mock_send_api_req, calls)
@patch('requests.get')
@patch(BASE_RPC + '_get_eos_master')
def test_get_value_error(self, mock_get_eos_master, mock_requests_get):
mock_get_eos_master.return_value = 'fake_master'
mock_requests_get.return_value = requests.Response()
self.assertIsNotNone(self.drv.get_vms_for_tenant(''))
self.assertIsNotNone(self.drv.get_dhcps_for_tenant(''))
self.assertIsNotNone(self.drv.get_baremetals_for_tenant(''))
self.assertIsNotNone(self.drv.get_routers_for_tenant(''))
self.assertIsNotNone(self.drv.get_ports_for_tenant('', 'vm'))
self.assertIsNotNone(self.drv.get_tenants())
self.assertIsNotNone(self.drv.get_networks(''))
self.assertIsNotNone(self.drv.get_instance_ports('', 'vm'))
@patch(BASE_RPC + '_get_eos_master')
def test_get_exception(self, mock_get_eos_master):
mock_get_eos_master.return_value = 'fake_master'
self.assertIsNotNone(self.drv.get_vms_for_tenant(''))
self.assertIsNotNone(self.drv.get_dhcps_for_tenant(''))
self.assertIsNotNone(self.drv.get_baremetals_for_tenant(''))
self.assertIsNotNone(self.drv.get_routers_for_tenant(''))
self.assertIsNotNone(self.drv.get_ports_for_tenant('', 'vm'))
self.assertIsNotNone(self.drv.get_tenants())
self.assertIsNotNone(self.drv.get_networks(''))
self.assertIsNotNone(self.drv.get_instance_ports('', 'vm'))
class RPCWrapperJSONValidConfigTrunkTestCase(testlib_api.SqlTestCase):
"""Test cases to test plug trunk port into network. """

Loading…
Cancel
Save