예제 #1
0
 def test_load_interface_driver_does_not_consume_irrelevant_errors(self):
     self.conf.set_override('interface_driver',
                            'neutron.agent.linux.interface.NullDriver')
     with mock.patch('oslo_utils.importutils.import_class',
                     side_effect=RuntimeError()):
         with testlib_api.ExpectedException(RuntimeError):
             utils.load_interface_driver(self.conf)
예제 #2
0
 def test_network_create_with_bad_vlan_transparent_attr(self):
     vlantrans = {'vlan_transparent': "abc"}
     with testlib_api.ExpectedException(
             web_exc.HTTPClientError) as ctx_manager:
         with self.network(name='net1', **vlantrans):
             pass
     self.assertEqual(web_exc.HTTPClientError.code,
                      ctx_manager.exception.code)
    def _test_update_shared_net_used(self,
                                     device_owner,
                                     expected_exception=None):
        plugin = manager.NeutronManager.get_plugin()
        ctx = context.get_admin_context()
        network, net_id = self._create_network(plugin, ctx)

        self._create_port(plugin, ctx, net_id, device_owner,
                          self._tenant_id + '1')

        network['network']['shared'] = False

        if (expected_exception):
            with testlib_api.ExpectedException(expected_exception):
                plugin.update_network(ctx, net_id, network)
        else:
            plugin.update_network(ctx, net_id, network)
 def test_associate_multiple_routers(self):
     with (self.router(tenant_id=self._tenant_id,
                       name='r1')) as r1, (self.router(
                           tenant_id=self._tenant_id,
                           name='r2')) as r2, (self.bgpvpn(
                               route_distinguishers=self.rds)) as bgpvpn:
         router_id1 = r1['router']['id']
         router_id2 = r2['router']['id']
         id = bgpvpn['bgpvpn']['id']
         with self.assoc_router(id, router_id1):
             self._assert_routers_associated([router_id1], bgpvpn)
             with testlib_api.ExpectedException(
                     webob.exc.HTTPClientError) as ctx_manager:
                 with self.assoc_router(id, router_id2):
                     pass
             self.assertEqual(webob.exc.HTTPBadRequest.code,
                              ctx_manager.exception.code)
             self._assert_routers_associated([router_id1], bgpvpn)
 def _test_resource_update(self, res, update_router_id, update_attr,
                           update_value):
     getattr(self, "_test_{0}_setup".format(res))()
     obj = getattr(self, "_{0}_create".format(res))(self._router_id)
     uattrs = getattr(self, "_{0}_update_attrs".format(res))(obj)
     uattrs[update_attr] = update_value
     data = {res: uattrs}
     if update_router_id:
         uattrs['router_id'] = self._router_id
         with testlib_api.ExpectedException(
                 webexc.HTTPClientError) as ctx_manager:
             self._do_request(
                 'PUT', _get_path('lb/{0}s/{1}'.format(res, obj['id'])),
                 data)
         self.assertEqual(ctx_manager.exception.code, 400)
     else:
         self._do_request('PUT',
                          _get_path('lb/{0}s/{1}'.format(res, obj['id'])),
                          data)
         updated = self._do_request(
             'GET', _get_path('lb/{0}s/{1}'.format(res, obj['id'])))
         self.assertEqual(updated[res][update_attr], update_value)
 def _test_router_update(self, update_service_type_id):
     router = self._router_create(self._service_type_id)
     router_id = router['id']
     new_name = _uuid()
     data = {
         "router": {
             "name": new_name,
             "admin_state_up": router['admin_state_up'],
         }
     }
     if update_service_type_id:
         data["router"]["service_type_id"] = _uuid()
         with testlib_api.ExpectedException(
                 webexc.HTTPClientError) as ctx_manager:
             res = self._do_request(
                 'PUT', _get_path('routers/{0}'.format(router_id)), data)
         self.assertEqual(ctx_manager.exception.code, 400)
     else:
         res = self._do_request(
             'PUT', _get_path('routers/{0}'.format(router_id)), data)
         res = self._do_request(
             'GET', _get_path('routers/{0}'.format(router['id'])))
         self.assertEqual(res['router']['name'], new_name)
예제 #7
0
 def test_load_interface_driver_as_alias_wrong_driver(self):
     self.conf.set_override('interface_driver', 'openvswitchXX')
     with testlib_api.ExpectedException(SystemExit):
         utils.load_interface_driver(self.conf)
예제 #8
0
 def test_load_interface_driver_wrong_driver(self):
     self.conf.set_override('interface_driver', 'neutron.NonExistentDriver')
     with testlib_api.ExpectedException(SystemExit):
         utils.load_interface_driver(self.conf)
예제 #9
0
 def test_load_interface_driver_not_set(self):
     with testlib_api.ExpectedException(SystemExit):
         utils.load_interface_driver(self.conf)
예제 #10
0
 def test_load_class_for_provider_wrong_plugin(self):
     with testlib_api.ExpectedException(ImportError):
         manager.NeutronManager.load_class_for_provider(
             'neutron.core_plugins', 'ml2XXXXXX')
예제 #11
0
 def _test_revision_autogenerate_conflicts_with_branch(self, branch):
     with testlib_api.ExpectedException(SystemExit):
         self._main_test_helper(
             ['prog', 'revision', '--autogenerate',
              '--%s' % branch], 'revision')
예제 #12
0
 def _test_upgrade_conflicts_with_delta(self, mode):
     with testlib_api.ExpectedException(SystemExit):
         self._main_test_helper(
             ['prog', 'upgrade', '--%s +3' % mode], 'upgrade')
예제 #13
0
 def test_upgrade_expand_contract_are_mutually_exclusive(self):
     with testlib_api.ExpectedException(SystemExit):
         self._main_test_helper(['prog', 'upgrade', '--expand --contract'],
                                'upgrade')