Esempio n. 1
0
    def setUp(self):
        super(TestQosNsxV3Notification, self).setUp()
        self.setup_coreplugin(PLUGIN_NAME)

        # Add a dummy notification driver that calls our handler directly
        # (to skip the message queue)
        cfg.CONF.set_override("notification_drivers", [
            'vmware_nsx.tests.unit.services.qos.fake_notifier.'
            'DummyNotificationDriver'
        ], "qos")
        self.qos_plugin = qos_plugin.QoSPlugin()
        self.ctxt = context.Context('fake_user', 'fake_tenant')
        mock.patch.object(self.ctxt.session, 'refresh').start()
        mock.patch.object(self.ctxt.session, 'expunge').start()
        self.policy_data = {
            'policy': {
                'id': uuidutils.generate_uuid(),
                'tenant_id': uuidutils.generate_uuid(),
                'name': 'test-policy',
                'description': 'Test policy description',
                'shared': True
            }
        }
        self.rule_data = {
            'bandwidth_limit_rule': {
                'id': uuidutils.generate_uuid(),
                'max_kbps': 2000,
                'max_burst_kbps': 150
            }
        }
        self.dscp_rule_data = {
            'dscp_marking_rule': {
                'id': uuidutils.generate_uuid(),
                'dscp_mark': 22
            }
        }

        self.policy = policy_object.QosPolicy(self.ctxt,
                                              **self.policy_data['policy'])

        self.rule = rule_object.QosBandwidthLimitRule(
            self.ctxt, **self.rule_data['bandwidth_limit_rule'])
        self.dscp_rule = rule_object.QosDscpMarkingRule(
            self.ctxt, **self.dscp_rule_data['dscp_marking_rule'])

        self.fake_profile_id = 'fake_profile'
        self.fake_profile = {'id': self.fake_profile_id}

        mock.patch('neutron.objects.db.api.create_object').start()
        mock.patch('neutron.objects.db.api.update_object').start()
        mock.patch('neutron.objects.db.api.delete_object').start()
        mock.patch(
            'neutron.objects.qos.policy.QosPolicy.obj_load_attr').start()
        mock.patch.object(nsx_db,
                          'get_switch_profile_by_qos_policy',
                          return_value=self.fake_profile_id).start()

        self.peak_bw_multiplier = cfg.CONF.NSX.qos_peak_bw_multiplier

        self.nsxlib = v3_utils.get_nsxlib_wrapper()
Esempio n. 2
0
 def setUp(self):
     super(QoSDriverTests, self).setUp()
     self.qos_plug = qos_plugin.QoSPlugin()
     directory.add_plugin('QOS', self.qos_plug)
     ext_mgr = QoSTestExtensionManager()
     self.resource_prefix_map = {'policies': '/qos'}
     self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
     tenant_id = uuidutils.generate_uuid()
     self.policy_data = {
         'policy': {'name': 'test-policy', 'tenant_id': tenant_id}}
Esempio n. 3
0
    def setUp(self):
        # Reset the drive to re-create it
        qos_driver.DRIVER = None
        super(TestQosNsxV3Notification, self).setUp()
        self.setup_coreplugin(PLUGIN_NAME)

        self.qos_plugin = qos_plugin.QoSPlugin()
        self.ctxt = context.Context('fake_user', 'fake_tenant')
        mock.patch.object(self.ctxt.session, 'refresh').start()
        mock.patch.object(self.ctxt.session, 'expunge').start()
        self.policy_data = {
            'policy': {
                'id': uuidutils.generate_uuid(),
                'project_id': uuidutils.generate_uuid(),
                'name': 'test-policy',
                'description': 'Test policy description',
                'shared': True
            }
        }
        self.rule_data = {
            'bandwidth_limit_rule': {
                'id': uuidutils.generate_uuid(),
                'max_kbps': 2000,
                'max_burst_kbps': 150
            }
        }
        self.dscp_rule_data = {
            'dscp_marking_rule': {
                'id': uuidutils.generate_uuid(),
                'dscp_mark': 22
            }
        }

        self.policy = policy_object.QosPolicy(self.ctxt,
                                              **self.policy_data['policy'])

        self.rule = rule_object.QosBandwidthLimitRule(
            self.ctxt, **self.rule_data['bandwidth_limit_rule'])
        self.dscp_rule = rule_object.QosDscpMarkingRule(
            self.ctxt, **self.dscp_rule_data['dscp_marking_rule'])

        self.fake_profile_id = 'fake_profile'
        self.fake_profile = {'id': self.fake_profile_id}

        mock.patch('neutron.objects.db.api.create_object').start()
        mock.patch('neutron.objects.db.api.update_object').start()
        mock.patch('neutron.objects.db.api.delete_object').start()
        mock.patch.object(nsx_db,
                          'get_switch_profile_by_qos_policy',
                          return_value=self.fake_profile_id).start()

        self.peak_bw_multiplier = cfg.CONF.NSX.qos_peak_bw_multiplier

        self.nsxlib = v3_utils.get_nsxlib_wrapper()
Esempio n. 4
0
    def setUp(self, *mocks):
        # init the nsx-v plugin for testing with DVS
        self._init_dvs_config()
        # Reset the drive to re-create it
        qos_driver.DRIVER = None
        super(TestQosNsxVNotification, self).setUp(plugin=CORE_PLUGIN,
                                                   ext_mgr=None)
        self.setup_coreplugin(CORE_PLUGIN)

        plugin_instance = directory.get_plugin()
        self._core_plugin = plugin_instance
        self._core_plugin.init_is_complete = True

        self.qos_plugin = qos_plugin.QoSPlugin()
        mock.patch.object(qos_utils.NsxVQosRule,
                          '_get_qos_plugin',
                          return_value=self.qos_plugin).start()

        # Pre defined QoS data for the tests
        self.ctxt = context.Context('fake_user', 'fake_tenant')

        self.policy_data = {
            'policy': {
                'id': uuidutils.generate_uuid(),
                'project_id': uuidutils.generate_uuid(),
                'name': 'test-policy',
                'description': 'Test policy description',
                'shared': True
            }
        }

        self.rule_data = {
            'bandwidth_limit_rule': {
                'id': uuidutils.generate_uuid(),
                'max_kbps': 100,
                'max_burst_kbps': 150,
                'type': qos_consts.RULE_TYPE_BANDWIDTH_LIMIT
            }
        }
        self.ingress_rule_data = {
            'bandwidth_limit_rule': {
                'id': uuidutils.generate_uuid(),
                'max_kbps': 200,
                'max_burst_kbps': 250,
                'direction': 'ingress',
                'type': qos_consts.RULE_TYPE_BANDWIDTH_LIMIT
            }
        }
        self.dscp_rule_data = {
            'dscp_marking_rule': {
                'id': uuidutils.generate_uuid(),
                'dscp_mark': 22,
                'type': qos_consts.RULE_TYPE_DSCP_MARKING
            }
        }

        self.policy = policy_object.QosPolicy(self.ctxt,
                                              **self.policy_data['policy'])

        # egress bw rule
        self.rule = rule_object.QosBandwidthLimitRule(
            self.ctxt, **self.rule_data['bandwidth_limit_rule'])
        # ingress bw rule
        self.ingress_rule = rule_object.QosBandwidthLimitRule(
            self.ctxt, **self.ingress_rule_data['bandwidth_limit_rule'])
        # dscp marking rule
        self.dscp_rule = rule_object.QosDscpMarkingRule(
            self.ctxt, **self.dscp_rule_data['dscp_marking_rule'])

        self._net_data = {
            'network': {
                'name': 'test-qos',
                'tenant_id': 'fake_tenant',
                'qos_policy_id': self.policy.id,
                'port_security_enabled': False,
                'admin_state_up': False,
                'shared': False
            }
        }
        self._rules = [self.rule_data['bandwidth_limit_rule']]
        self._dscp_rules = [self.dscp_rule_data['dscp_marking_rule']]

        mock.patch(
            'neutron.objects.qos.policy.QosPolicy.obj_load_attr').start()
    def setUp(self, *mocks):
        # init the nsx-v plugin for testing with DVS
        self._init_dvs_config()
        super(TestQosNsxVNotification, self).setUp(plugin=CORE_PLUGIN,
                                                   ext_mgr=None)
        plugin_instance = manager.NeutronManager.get_plugin()
        self._core_plugin = plugin_instance

        # Setup the QoS plugin:
        # Add a dummy notification driver that calls our handler directly
        # (to skip the message queue)
        cfg.CONF.set_override("notification_drivers", [
            'vmware_nsx.tests.unit.services.qos.fake_nsxv_notifier.'
            'DummyNsxVNotificationDriver'
        ], "qos")
        self.qos_plugin = qos_plugin.QoSPlugin()
        mock.patch.object(qos_utils.NsxVQosRule,
                          '_get_qos_plugin',
                          return_value=self.qos_plugin).start()

        # Pre defined QoS data for the tests
        self.ctxt = context.Context('fake_user', 'fake_tenant')
        self.policy_data = {
            'policy': {
                'id': uuidutils.generate_uuid(),
                'tenant_id': uuidutils.generate_uuid(),
                'name': 'test-policy',
                'description': 'Test policy description',
                'shared': True
            }
        }

        self.rule_data = {
            'bandwidth_limit_rule': {
                'id': uuidutils.generate_uuid(),
                'max_kbps': 100,
                'max_burst_kbps': 150
            }
        }
        self.dscp_rule_data = {
            'dscp_marking_rule': {
                'id': uuidutils.generate_uuid(),
                'dscp_mark': 22
            }
        }

        self.policy = policy_object.QosPolicy(self.ctxt,
                                              **self.policy_data['policy'])

        self.rule = rule_object.QosBandwidthLimitRule(
            self.ctxt, **self.rule_data['bandwidth_limit_rule'])
        self.dscp_rule = rule_object.QosDscpMarkingRule(
            self.ctxt, **self.dscp_rule_data['dscp_marking_rule'])

        self._net_data = {
            'network': {
                'name': 'test-qos',
                'tenant_id': 'fake_tenant',
                'qos_policy_id': self.policy.id,
                'port_security_enabled': False,
                'admin_state_up': False,
                'shared': False
            }
        }
        self._rules = [self.rule_data['bandwidth_limit_rule']]
        self._dscp_rules = [self.dscp_rule_data['dscp_marking_rule']]

        mock.patch('neutron.objects.db.api.create_object').start()
        mock.patch('neutron.objects.db.api.update_object').start()
        mock.patch('neutron.objects.db.api.delete_object').start()
        mock.patch('neutron.objects.db.api.get_object').start()
        mock.patch(
            'neutron.objects.qos.policy.QosPolicy.obj_load_attr').start()
Esempio n. 6
0
    def setUp(self, *mocks):
        # init the nsx-v plugin for testing with DVS
        self._init_dvs_config()
        # Reset the drive to re-create it
        qos_driver.DRIVER = None
        # Skip Octavia init because of RPC conflicts
        with mock.patch("vmware_nsx.services.lbaas.octavia.octavia_listener."
                        "NSXOctaviaListener.__init__", return_value=None),\
            mock.patch("vmware_nsx.services.lbaas.octavia.octavia_listener."
                       "NSXOctaviaStatisticsCollector.__init__",
                       return_value=None):
            super(TestQosNsxVNotification, self).setUp(plugin=CORE_PLUGIN,
                                                       ext_mgr=None,
                                                       with_md_proxy=False)
        self.setup_coreplugin(CORE_PLUGIN)

        plugin_instance = directory.get_plugin()
        self._core_plugin = plugin_instance
        self._core_plugin.init_is_complete = True

        self.qos_plugin = qos_plugin.QoSPlugin()
        mock.patch.object(qos_utils.NsxVQosRule,
                          '_get_qos_plugin',
                          return_value=self.qos_plugin).start()

        # Pre defined QoS data for the tests
        self.test_tenant_id = '1d7ddf4daf1f47529b5cc93b2e843980'
        self.ctxt = context.Context('fake_user', self.test_tenant_id)

        self.policy_data = {
            'policy': {'id': uuidutils.generate_uuid(),
                       'project_id': self.test_tenant_id,
                       'name': 'test-policy',
                       'description': 'Test policy description',
                       'shared': True}}

        self.rule_data = {
            'bandwidth_limit_rule': {
                'id': uuidutils.generate_uuid(),
                'max_kbps': 100,
                'max_burst_kbps': 150,
                'type': qos_consts.RULE_TYPE_BANDWIDTH_LIMIT}}
        self.ingress_rule_data = {
            'bandwidth_limit_rule': {
                'id': uuidutils.generate_uuid(),
                'max_kbps': 200,
                'max_burst_kbps': 250,
                'direction': 'ingress',
                'type': qos_consts.RULE_TYPE_BANDWIDTH_LIMIT}}
        self.dscp_rule_data = {
            'dscp_marking_rule': {
                'id': uuidutils.generate_uuid(),
                'dscp_mark': 22,
                'type': qos_consts.RULE_TYPE_DSCP_MARKING}}

        self.policy = QosPolicy(
            self.ctxt, **self.policy_data['policy'])

        # egress bw rule
        self.rule = QosBandwidthLimitRule(
            self.ctxt, **self.rule_data['bandwidth_limit_rule'])
        # ingress bw rule
        self.ingress_rule = QosBandwidthLimitRule(
            self.ctxt, **self.ingress_rule_data['bandwidth_limit_rule'])
        # dscp marking rule
        self.dscp_rule = QosDscpMarkingRule(
            self.ctxt, **self.dscp_rule_data['dscp_marking_rule'])

        self._net_data = {'network': {
            'name': 'test-qos',
            'tenant_id': self.test_tenant_id,
            'qos_policy_id': self.policy.id,
            'port_security_enabled': False,
            'admin_state_up': False,
            'shared': False
        }}
        self._rules = [self.rule_data['bandwidth_limit_rule']]
        self._dscp_rules = [self.dscp_rule_data['dscp_marking_rule']]

        mock.patch.object(QosPolicy, 'obj_load_attr').start()