def test_qos_min_bw_allocation_update_with_multiple_ports(self): if not utils.is_network_feature_enabled('update_port_qos'): raise self.skipException("update_port_qos feature is not enabled") self._create_network_and_qos_policies( self._create_qos_policies_from_life) port1 = self.create_port(self.prov_network['id'], qos_policy_id=self.qos_policy_1['id']) port2 = self.create_port(self.prov_network['id'], qos_policy_id=self.qos_policy_2['id']) server1 = self.create_server(networks=[{ 'port': port1['id'] }, { 'port': port2['id'] }]) self._assert_allocation_is_as_expected( server1['id'], [port1['id'], port2['id']], self.BANDWIDTH_1 + self.BANDWIDTH_2) self.ports_client.update_port( port1['id'], **{'qos_policy_id': self.qos_policy_2['id']}) self._assert_allocation_is_as_expected(server1['id'], [port1['id'], port2['id']], 2 * self.BANDWIDTH_2)
def test_qos_min_bw_allocation_update_policy(self): """Test the update of QoS policy on bound port Related RFE in neutron: #1882804 The scenario is the following: * Have a port with QoS policy and minimum bandwidth rule. * Boot a VM with the port. * Update the port with a new policy with different minimum bandwidth values. * The allocation on placement side should be according to the new rules. """ if not utils.is_network_feature_enabled('update_port_qos'): raise self.skipException("update_port_qos feature is not enabled") self._create_network_and_qos_policies( self._create_qos_policies_from_life) port = self.create_port( self.prov_network['id'], qos_policy_id=self.qos_policy_1['id']) server1 = self.create_server( networks=[{'port': port['id']}]) self._assert_allocation_is_as_expected(server1['id'], [port['id']], self.BANDWIDTH_1) self.ports_client.update_port( port['id'], **{'qos_policy_id': self.qos_policy_2['id']}) self._assert_allocation_is_as_expected(server1['id'], [port['id']], self.BANDWIDTH_2) # I changed my mind self.ports_client.update_port( port['id'], **{'qos_policy_id': self.qos_policy_1['id']}) self._assert_allocation_is_as_expected(server1['id'], [port['id']], self.BANDWIDTH_1) # bad request.... self.qos_policy_not_valid = self._create_policy_and_min_bw_rule( name_prefix='test_policy_not_valid', min_kbps=self.PLACEMENT_MAX_INT) port_orig = self.ports_client.show_port(port['id'])['port'] self.assertRaises( lib_exc.Conflict, self.ports_client.update_port, port['id'], **{'qos_policy_id': self.qos_policy_not_valid['id']}) self._assert_allocation_is_as_expected(server1['id'], [port['id']], self.BANDWIDTH_1) port_upd = self.ports_client.show_port(port['id'])['port'] self.assertEqual(port_orig['qos_policy_id'], port_upd['qos_policy_id']) self.assertEqual(self.qos_policy_1['id'], port_upd['qos_policy_id'])
def test_qos_min_bw_allocation_update_policy_direction_change(self): """Test QoS min bw direction change on a bound port Related RFE in neutron: #1882804 The scenario is the following: * Have a port with QoS policy and minimum bandwidth rule with ingress direction * Boot a VM with the port. * Update the port with a new policy to egress direction in minimum bandwidth rule. * The allocation on placement side should be according to the new rules. """ if not utils.is_network_feature_enabled('update_port_qos'): raise self.skipException("update_port_qos feature is not enabled") def create_policies(): self.qos_policy_ingress = self._create_policy_and_min_bw_rule( name_prefix='test_policy_ingress', min_kbps=self.BANDWIDTH_1, direction=self.INGRESS_DIRECTION, ) self.qos_policy_egress = self._create_policy_and_min_bw_rule( name_prefix='test_policy_egress', min_kbps=self.BANDWIDTH_1, direction=self.EGRESS_DIRECTION, ) self._create_network_and_qos_policies(create_policies) port = self.create_port(self.prov_network['id'], qos_policy_id=self.qos_policy_ingress['id']) server1 = self.create_server(networks=[{'port': port['id']}]) self._assert_allocation_is_as_expected( server1['id'], [port['id']], self.BANDWIDTH_1, expected_rc=self.INGRESS_RESOURCE_CLASS) self.ports_client.update_port( port['id'], qos_policy_id=self.qos_policy_egress['id']) self._assert_allocation_is_as_expected( server1['id'], [port['id']], self.BANDWIDTH_1, expected_rc=self.EGRESS_RESOURCE_CLASS) self._assert_allocation_is_as_expected( server1['id'], [port['id']], 0, expected_rc=self.INGRESS_RESOURCE_CLASS)
def test_empty_update(self): if not utils.is_network_feature_enabled('update_port_qos'): raise self.skipException("update_port_qos feature is not enabled") self._create_network_and_qos_policies( self._create_qos_policies_from_life) port = self.create_port(self.prov_network['id'], qos_policy_id=self.qos_policy_1['id']) server1 = self.create_server(networks=[{'port': port['id']}]) self._assert_allocation_is_as_expected(server1['id'], [port['id']], self.BANDWIDTH_1) self.ports_client.update_port(port['id'], **{'description': 'foo'}) self._assert_allocation_is_as_expected(server1['id'], [port['id']], self.BANDWIDTH_1)
def test_qos_min_bw_allocation_update_policy_to_zero(self): """Test port with QoS policy to remove QoS policy In this scenario port with QoS minimum_bandwidth rule update to remove QoS policy results in 0 placement allocation. """ if not utils.is_network_feature_enabled('update_port_qos'): raise self.skipException("update_port_qos feature is not enabled") self._create_network_and_qos_policies( self._create_qos_policies_from_life) port = self.create_port(self.prov_network['id'], qos_policy_id=self.qos_policy_1['id']) server1 = self.create_server(networks=[{'port': port['id']}]) self._assert_allocation_is_as_expected(server1['id'], [port['id']], self.BANDWIDTH_1) self.ports_client.update_port(port['id'], **{'qos_policy_id': None}) self._assert_allocation_is_as_expected(server1['id'], [port['id']], 0)
def test_qos_min_bw_allocation_update_policy_from_zero(self): """Test port without QoS policy to have QoS policy This scenario checks if updating a port without QoS policy to have QoS policy with minimum_bandwidth rule succeeds only on controlplane, but placement allocation remains 0. """ if not utils.is_network_feature_enabled('update_port_qos'): raise self.skipException("update_port_qos feature is not enabled") self._create_network_and_qos_policies( self._create_qos_policies_from_life) port = self.create_port(self.prov_network['id']) server1 = self.create_server(networks=[{'port': port['id']}]) self._assert_allocation_is_as_expected(server1['id'], [port['id']], 0) self.ports_client.update_port( port['id'], **{'qos_policy_id': self.qos_policy_2['id']}) self._assert_allocation_is_as_expected(server1['id'], [port['id']], 0)
def skip_checks(cls): super(MetadataTest, cls).skip_checks() if not utils.is_network_feature_enabled('ipv6_metadata'): raise cls.skipException("Metadata over IPv6 is not enabled")