def setUp(self): super(APIFiltersTest, self).setUp( 'quantum.api.APIRouterV11', { test_api.NETS: nets.ControllerV11._serialization_metadata, test_api.PORTS: ports.ControllerV11._serialization_metadata, test_api.ATTS: atts.ControllerV11._serialization_metadata, }) self._successful_create_code = exc.HTTPAccepted.code self.net_op_status = test_config.get('default_net_op_status', 'UNKNOWN') self.port_op_status = test_config.get('default_port_op_status', 'UNKNOWN') self.fmt = "xml" self.content_type = "application/%s" % self.fmt # create data for validating filters # Create network "test-1" self.net1_id = self._create_network(self.fmt, name="test-1") # Add 2 ports, 1 ACTIVE, 1 DOWN self.port11_id = self._create_port(self.net1_id, "ACTIVE", self.fmt) self.port12_id = self._create_port(self.net1_id, "DOWN", self.fmt) # Put attachment "test-1-att" in active port self._set_attachment(self.net1_id, self.port11_id, "test-1-att", self.fmt) # Create network "test-2" # Add 2 ports, 2 ACTIVE, 0 DOWN self.net2_id = self._create_network(self.fmt, name="test-2") self.port21_id = self._create_port(self.net2_id, "ACTIVE", self.fmt) self.port22_id = self._create_port(self.net2_id, "ACTIVE", self.fmt)
def setUp(self): super(APIFiltersTest, self).setUp( 'quantum.api.APIRouterV11', { test_api.NETS: nets.ControllerV11._serialization_metadata, test_api.PORTS: ports.ControllerV11._serialization_metadata, test_api.ATTS: atts.ControllerV11._serialization_metadata, } ) self._successful_create_code = exc.HTTPAccepted.code self.net_op_status = test_config.get('default_net_op_status', 'UNKNOWN') self.port_op_status = test_config.get('default_port_op_status', 'UNKNOWN') self.fmt = "xml" self.content_type = "application/%s" % self.fmt # create data for validating filters # Create network "test-1" self.net1_id = self._create_network(self.fmt, name="test-1") # Add 2 ports, 1 ACTIVE, 1 DOWN self.port11_id = self._create_port(self.net1_id, "ACTIVE", self.fmt) self.port12_id = self._create_port(self.net1_id, "DOWN", self.fmt) # Put attachment "test-1-att" in active port self._set_attachment(self.net1_id, self.port11_id, "test-1-att", self.fmt) # Create network "test-2" # Add 2 ports, 2 ACTIVE, 0 DOWN self.net2_id = self._create_network(self.fmt, name="test-2") self.port21_id = self._create_port(self.net2_id, "ACTIVE", self.fmt) self.port22_id = self._create_port(self.net2_id, "ACTIVE", self.fmt)
def setUp(self): self.net_op_status = test_config.get('default_net_op_status', 'UNKNOWN') self.port_op_status = test_config.get('default_port_op_status', 'UNKNOWN') super(APITestV11, self).setUp('quantum.api.APIRouterV11', {test_api.NETS: nets.ControllerV11._serialization_metadata, test_api.PORTS: ports.ControllerV11._serialization_metadata, test_api.ATTS: atts.ControllerV11._serialization_metadata})
def setUp(self): self.net_op_status = test_config.get('default_net_op_status', 'UNKNOWN') self.port_op_status = test_config.get('default_port_op_status', 'UNKNOWN') super(APITestV11, self).setUp( 'quantum.api.APIRouterV11', { test_api.NETS: nets.ControllerV11._serialization_metadata, test_api.PORTS: ports.ControllerV11._serialization_metadata, test_api.ATTS: atts.ControllerV11._serialization_metadata })
def setUp(self, plugin=None): super(SecurityGroupsTestCase, self).setUp() db._ENGINE = None db._MAKER = None # Make sure at each test a new instance of the plugin is returned QuantumManager._instance = None # Make sure at each test according extensions for the plugin is loaded PluginAwareExtensionManager._instance = None # Save the attributes map in case the plugin will alter it # loading extensions # Note(salvatore-orlando): shallow copy is not good enough in # this case, but copy.deepcopy does not seem to work, since it # causes test failures self._attribute_map_bk = {} for item in attributes.RESOURCE_ATTRIBUTE_MAP: self._attribute_map_bk[item] = ( attributes.RESOURCE_ATTRIBUTE_MAP[item].copy()) json_deserializer = JSONDeserializer() self._deserializers = { 'application/json': json_deserializer, } if not plugin: plugin = test_config.get('plugin_name_v2', DB_PLUGIN_KLASS) # Create the default configurations args = ['--config-file', etcdir('quantum.conf.test')] # If test_config specifies some config-file, use it, as well for config_file in test_config.get('config_files', []): args.extend(['--config-file', config_file]) config.parse(args=args) # Update the plugin cfg.CONF.set_override('core_plugin', plugin) self.api = APIRouter() def _is_native_bulk_supported(): plugin_obj = QuantumManager.get_plugin() native_bulk_attr_name = ("_%s__native_bulk_support" % plugin_obj.__class__.__name__) return getattr(plugin_obj, native_bulk_attr_name, False) self._skip_native_bulk = not _is_native_bulk_supported() QuantumManager.get_plugin().supported_extension_aliases = ([ "security-groups" ]) ext_mgr = SecurityGroupTestExtensionManager() if ext_mgr: self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
def setUp(self, plugin=None): super(SecurityGroupsTestCase, self).setUp() db._ENGINE = None db._MAKER = None # Make sure at each test a new instance of the plugin is returned QuantumManager._instance = None # Make sure at each test according extensions for the plugin is loaded PluginAwareExtensionManager._instance = None # Save the attributes map in case the plugin will alter it # loading extensions # Note(salvatore-orlando): shallow copy is not good enough in # this case, but copy.deepcopy does not seem to work, since it # causes test failures self._attribute_map_bk = {} for item in attributes.RESOURCE_ATTRIBUTE_MAP: self._attribute_map_bk[item] = (attributes. RESOURCE_ATTRIBUTE_MAP[item]. copy()) json_deserializer = JSONDeserializer() self._deserializers = { 'application/json': json_deserializer, } if not plugin: plugin = test_config.get('plugin_name_v2', DB_PLUGIN_KLASS) # Create the default configurations args = ['--config-file', etcdir('quantum.conf.test')] # If test_config specifies some config-file, use it, as well for config_file in test_config.get('config_files', []): args.extend(['--config-file', config_file]) config.parse(args=args) # Update the plugin cfg.CONF.set_override('core_plugin', plugin) self.api = APIRouter() def _is_native_bulk_supported(): plugin_obj = QuantumManager.get_plugin() native_bulk_attr_name = ("_%s__native_bulk_support" % plugin_obj.__class__.__name__) return getattr(plugin_obj, native_bulk_attr_name, False) self._skip_native_bulk = not _is_native_bulk_supported() QuantumManager.get_plugin().supported_extension_aliases = ( ["security-groups"]) ext_mgr = SecurityGroupTestExtensionManager() if ext_mgr: self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
def setUp(self): self.net_op_status = test_config.get('default_net_op_status', 'UNKNOWN') self.port_op_status = test_config.get('default_port_op_status', 'UNKNOWN') super(APITestV11, self).setUp('quantum.api.APIRouterV11', {test_api.NETS: nets.ControllerV11._serialization_metadata, test_api.PORTS: ports.ControllerV11._serialization_metadata, test_api.ATTS: atts.ControllerV11._serialization_metadata}) self._network_not_found_code = exc.HTTPNotFound.code self._network_in_use_code = exc.HTTPConflict.code self._port_not_found_code = exc.HTTPNotFound.code self._port_state_invalid_code = exc.HTTPBadRequest.code self._port_in_use_code = exc.HTTPConflict.code self._already_attached_code = exc.HTTPConflict.code
def test_multiple_plugins_specified_for_service_type(self): cfg.CONF.set_override("service_plugins", [ "quantum.tests.unit.dummy_plugin." "DummyServicePlugin", "quantum.tests.unit.dummy_plugin." "DummyServicePlugin" ]) cfg.CONF.set_override( "core_plugin", test_config.get('plugin_name_v2', DB_PLUGIN_KLASS)) self.assertRaises(Exception, QuantumManager.get_instance)
def test_multiple_plugins_specified_for_service_type(self): cfg.CONF.set_override("service_plugins", ["quantum.tests.unit.dummy_plugin." "DummyServicePlugin", "quantum.tests.unit.dummy_plugin." "DummyServicePlugin"]) cfg.CONF.set_override("core_plugin", test_config.get('plugin_name_v2', DB_PLUGIN_KLASS)) self.assertRaises(ValueError, QuantumManager.get_instance)
def setUp(self): self.net_op_status = test_config.get('default_net_op_status', 'UNKNOWN') self.port_op_status = test_config.get('default_port_op_status', 'UNKNOWN') super(APITestV11, self).setUp( 'quantum.api.APIRouterV11', { test_api.NETS: nets.ControllerV11._serialization_metadata, test_api.PORTS: ports.ControllerV11._serialization_metadata, test_api.ATTS: atts.ControllerV11._serialization_metadata, } ) self._successful_create_code = exc.HTTPAccepted.code self._network_not_found_code = exc.HTTPNotFound.code self._network_in_use_code = exc.HTTPConflict.code self._port_not_found_code = exc.HTTPNotFound.code self._port_state_invalid_code = exc.HTTPBadRequest.code self._port_in_use_code = exc.HTTPConflict.code self._already_attached_code = exc.HTTPConflict.code
def setUp(self, core_plugin=None, lb_plugin=None): super(LoadBalancerPluginDbTestCase, self).setUp() db._ENGINE = None db._MAKER = None QuantumManager._instance = None PluginAwareExtensionManager._instance = None self._attribute_map_bk = {} self._attribute_map_bk = loadbalancer.RESOURCE_ATTRIBUTE_MAP.copy() self._tenant_id = "test-tenant" self._subnet_id = "0c798ed8-33ba-11e2-8b28-000c291c4d14" json_deserializer = JSONDeserializer() self._deserializers = { 'application/json': json_deserializer, } if not core_plugin: core_plugin = test_config.get('plugin_name_v2', DB_CORE_PLUGIN_KLASS) if not lb_plugin: lb_plugin = test_config.get('lb_plugin_name', DB_LB_PLUGIN_KLASS) # point config file to: quantum/tests/etc/quantum.conf.test args = ['--config-file', etcdir('quantum.conf.test')] config.parse(args=args) # Update the plugin service_plugins = [lb_plugin] cfg.CONF.set_override('core_plugin', core_plugin) cfg.CONF.set_override('service_plugins', service_plugins) cfg.CONF.set_override('base_mac', "12:34:56:78:90:ab") self.api = APIRouter() plugin = loadbalancerPlugin.LoadBalancerPlugin() ext_mgr = PluginAwareExtensionManager( extensions_path, {constants.LOADBALANCER: plugin} ) app = config.load_paste_app('extensions_test_app') self.ext_api = ExtensionMiddleware(app, ext_mgr=ext_mgr)
def test_service_plugin_is_loaded(self): cfg.CONF.set_override("core_plugin", test_config.get('plugin_name_v2', DB_PLUGIN_KLASS)) cfg.CONF.set_override("service_plugins", ["quantum.tests.unit.dummy_plugin." "DummyServicePlugin"]) mgr = QuantumManager.get_instance() plugin = mgr.get_service_plugins()[constants.DUMMY] self.assertTrue( isinstance(plugin, (dummy_plugin.DummyServicePlugin, types.ClassType)), "loaded plugin should be of type QuantumDummyPlugin")
def test_service_plugin_is_loaded(self): cfg.CONF.set_override("core_plugin", test_config.get('plugin_name_v2', DB_PLUGIN_KLASS)) cfg.CONF.set_override("service_plugins", ["quantum.tests.unit.dummy_plugin." "DummyServicePlugin"]) mgr = QuantumManager.get_instance() plugin = mgr.get_service_plugins()[constants.DUMMY] self.assertTrue( isinstance(plugin, (dummy_plugin.DummyServicePlugin, types.ClassType)), "loaded plugin should be of type QuantumDummyPlugin")