Exemple #1
0
 def test_create404_triggers_background_sync(self):
     # allow the async background thread to run for this test
     self.spawn_p.stop()
     with contextlib.nested(
             mock.patch(SERVER_POOL + '.rest_create_port',
                        side_effect=servermanager.RemoteRestError(
                            reason=servermanager.NXNETWORK, status=404)),
             mock.patch(DRIVER + '._send_all_data'),
             self.port(
                 **{
                     'device_id': 'devid',
                     'binding:host_id': 'host',
                     'arg_list': ('binding:host_id', )
                 })) as (mock_http, mock_send_all, p):
         # wait for thread to finish
         mm = manager.NeutronManager.get_plugin().mechanism_manager
         bigdriver = mm.mech_drivers['bigswitch'].obj
         bigdriver.evpool.waitall()
         mock_send_all.assert_has_calls([
             mock.call(send_routers=False,
                       send_ports=True,
                       send_floating_ips=False,
                       triggered_by_tenant=p['port']['tenant_id'])
         ])
     self.spawn_p.start()
Exemple #2
0
 def test_consistency_watchdog(self):
     pl = manager.NeutronManager.get_plugin()
     pl.servers.capabilities = []
     self.watch_p.stop()
     with contextlib.nested(
         mock.patch('eventlet.sleep'),
         mock.patch(
             SERVERMANAGER + '.ServerPool.rest_call',
             side_effect=servermanager.RemoteRestError(
                 reason='Failure to trigger except clause.'
             )
         ),
         mock.patch(
             SERVERMANAGER + '.LOG.exception',
             side_effect=KeyError('Failure to break loop')
         )
     ) as (smock, rmock, lmock):
         # should return immediately without consistency capability
         pl.servers._consistency_watchdog()
         self.assertFalse(smock.called)
         pl.servers.capabilities = ['consistency']
         self.assertRaises(KeyError,
                           pl.servers._consistency_watchdog)
         rmock.assert_called_with('GET', '/health', '', {}, [], False)
         self.assertEqual(1, len(lmock.mock_calls))
Exemple #3
0
 def test_dont_bind_non_ivs_port(self):
     host_arg = {portbindings.HOST_ID: 'hostname'}
     with contextlib.nested(
             mock.patch(SERVER_POOL + '.rest_get_switch',
                        side_effect=servermanager.RemoteRestError(
                            reason='No such switch', status=404)),
             self.port(arg_list=(portbindings.HOST_ID, ),
                       **host_arg)) as (rmock, port):
         rmock.assert_called_once_with('hostname')
         p = port['port']
         self.assertNotEqual(portbindings.VIF_TYPE_IVS,
                             p[portbindings.VIF_TYPE])
Exemple #4
0
 def test_consistency_watchdog(self):
     pl = manager.NeutronManager.get_plugin()
     pl.servers.capabilities = []
     self.watch_p.stop()
     with contextlib.nested(
             mock.patch('eventlet.sleep'),
             mock.patch(SERVERMANAGER + '.ServerPool.rest_call',
                        side_effect=servermanager.RemoteRestError(
                            reason='Failure to break loop'))) as (smock,
                                                                  rmock):
         # should return immediately without consistency capability
         pl.servers._consistency_watchdog()
         self.assertFalse(smock.called)
         pl.servers.capabilities = ['consistency']
         self.assertRaises(servermanager.RemoteRestError,
                           pl.servers._consistency_watchdog)
Exemple #5
0
 def test_udpate404_triggers_background_sync(self):
     with contextlib.nested(
         mock.patch(SERVER_POOL + '.rest_update_port',
                    side_effect=servermanager.RemoteRestError(
                        reason=servermanager.NXNETWORK, status=404)),
         mock.patch(DRIVER + '._send_all_data'),
         self.port()
     ) as (mock_update, mock_send_all, p):
         plugin = manager.NeutronManager.get_plugin()
         context = neutron_context.get_admin_context()
         plugin.update_port(context, p['port']['id'],
                            {'port': {'device_id': 'devid',
                                      'binding:host_id': 'host'}})
         mock_send_all.assert_has_calls([
             mock.call(
                 send_routers=False, send_ports=True,
                 send_floating_ips=False,
                 triggered_by_tenant=p['port']['tenant_id']
             )
         ])