QoS DSCP fullstack tests
This patch introduces fullstack testing for the QoS/DSCP Open vSwitch implementation. It depends on the python-neutronclient patches, therefore it could not be merged in the main patch. Co-Authored-By: Miguel Angel Ajo <majopela@redhat.com> Change-Id: I0ab6a1a0d1430c5791fea1d5b54106c6cc93b937 Closes-Bug: #1468353 Depends-On: I25ad60c1b9a66e568276a772b8c496987d9f8299
This commit is contained in:
parent
a4985d16f6
commit
73546f8503
|
@ -48,7 +48,7 @@ def wait_until_dscp_marking_rule_applied(bridge, port_vif, rule):
|
|||
|
||||
expected = None
|
||||
if rule:
|
||||
expected = rule
|
||||
expected = rule << 2
|
||||
return dscp_mark == expected
|
||||
|
||||
agent_utils.wait_until_true(_dscp_marking_rule_applied)
|
||||
|
|
|
@ -133,3 +133,17 @@ class ClientFixture(fixtures.Fixture):
|
|||
qos_policy_id)
|
||||
|
||||
return rule['bandwidth_limit_rule']
|
||||
|
||||
def create_dscp_marking_rule(self, tenant_id, qos_policy_id, dscp_mark=0):
|
||||
rule = {'tenant_id': tenant_id}
|
||||
if dscp_mark:
|
||||
rule['dscp_mark'] = dscp_mark
|
||||
rule = self.client.create_dscp_marking_rule(
|
||||
policy=qos_policy_id,
|
||||
body={'dscp_marking_rule': rule})
|
||||
|
||||
self.addCleanup(_safe_method(self.client.delete_dscp_marking_rule),
|
||||
rule['dscp_marking_rule']['id'],
|
||||
qos_policy_id)
|
||||
|
||||
return rule['dscp_marking_rule']
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import functools
|
||||
|
||||
from neutron_lib import constants
|
||||
from oslo_utils import uuidutils
|
||||
import testscenarios
|
||||
|
@ -21,6 +23,7 @@ from neutron.agent.linux import bridge_lib
|
|||
from neutron.agent.linux import tc_lib
|
||||
from neutron.agent.linux import utils
|
||||
from neutron.services.qos import qos_consts
|
||||
from neutron.tests.common.agents import l2_extensions
|
||||
from neutron.tests.fullstack import base
|
||||
from neutron.tests.fullstack.resources import environment
|
||||
from neutron.tests.fullstack.resources import machine
|
||||
|
@ -36,46 +39,12 @@ from neutron.plugins.ml2.drivers.openvswitch.mech_driver import \
|
|||
load_tests = testscenarios.load_tests_apply_scenarios
|
||||
|
||||
|
||||
BANDWIDTH_LIMIT = 500
|
||||
BANDWIDTH_BURST = 100
|
||||
BANDWIDTH_LIMIT = 500
|
||||
DSCP_MARK = 16
|
||||
|
||||
|
||||
def _wait_for_rule_applied_ovs_agent(vm, limit, burst):
|
||||
utils.wait_until_true(
|
||||
lambda: vm.bridge.get_egress_bw_limit_for_port(
|
||||
vm.port.name) == (limit, burst))
|
||||
|
||||
|
||||
def _wait_for_rule_applied_linuxbridge_agent(vm, limit, burst):
|
||||
port_name = linuxbridge_agent.LinuxBridgeManager.get_tap_device_name(
|
||||
vm.neutron_port['id'])
|
||||
tc = tc_lib.TcCommand(
|
||||
port_name,
|
||||
linuxbridge_agent_config.DEFAULT_KERNEL_HZ_VALUE,
|
||||
namespace=vm.host.host_namespace
|
||||
)
|
||||
utils.wait_until_true(
|
||||
lambda: tc.get_filters_bw_limits() == (limit, burst))
|
||||
|
||||
|
||||
def _wait_for_rule_applied(vm, limit, burst):
|
||||
if isinstance(vm.bridge, ovs_lib.OVSBridge):
|
||||
_wait_for_rule_applied_ovs_agent(vm, limit, burst)
|
||||
if isinstance(vm.bridge, bridge_lib.BridgeDevice):
|
||||
_wait_for_rule_applied_linuxbridge_agent(vm, limit, burst)
|
||||
|
||||
|
||||
def _wait_for_rule_removed(vm):
|
||||
# No values are provided when port doesn't have qos policy
|
||||
_wait_for_rule_applied(vm, None, None)
|
||||
|
||||
|
||||
class TestQoSWithL2Agent(base.BaseFullStackTestCase):
|
||||
|
||||
scenarios = [
|
||||
("ovs", {'l2_agent_type': constants.AGENT_TYPE_OVS}),
|
||||
("linuxbridge", {'l2_agent_type': constants.AGENT_TYPE_LINUXBRIDGE})
|
||||
]
|
||||
class BaseQoSRuleTestCase(base.BaseFullStackTestCase):
|
||||
|
||||
def setUp(self):
|
||||
host_desc = [environment.HostDescription(
|
||||
|
@ -83,41 +52,7 @@ class TestQoSWithL2Agent(base.BaseFullStackTestCase):
|
|||
l2_agent_type=self.l2_agent_type)]
|
||||
env_desc = environment.EnvironmentDescription(qos=True)
|
||||
env = environment.Environment(env_desc, host_desc)
|
||||
super(TestQoSWithL2Agent, self).setUp(env)
|
||||
|
||||
def _create_qos_policy(self):
|
||||
return self.safe_client.create_qos_policy(
|
||||
self.tenant_id, 'fs_policy', 'Fullstack testing policy',
|
||||
shared='False')
|
||||
|
||||
def _prepare_vm_with_qos_policy(self, limit, burst):
|
||||
qos_policy = self._create_qos_policy()
|
||||
qos_policy_id = qos_policy['id']
|
||||
|
||||
rule = self.safe_client.create_bandwidth_limit_rule(
|
||||
self.tenant_id, qos_policy_id, limit, burst)
|
||||
# Make it consistent with GET reply
|
||||
qos_policy['rules'].append(rule)
|
||||
rule['type'] = qos_consts.RULE_TYPE_BANDWIDTH_LIMIT
|
||||
rule['qos_policy_id'] = qos_policy_id
|
||||
|
||||
port = self.safe_client.create_port(
|
||||
self.tenant_id, self.network['id'],
|
||||
self.environment.hosts[0].hostname,
|
||||
qos_policy_id)
|
||||
|
||||
vm = self.useFixture(
|
||||
machine.FakeFullstackMachine(
|
||||
self.environment.hosts[0],
|
||||
self.network['id'],
|
||||
self.tenant_id,
|
||||
self.safe_client,
|
||||
neutron_port=port))
|
||||
|
||||
return vm, qos_policy
|
||||
|
||||
def test_qos_policy_rule_lifecycle(self):
|
||||
new_limit = BANDWIDTH_LIMIT + 100
|
||||
super(BaseQoSRuleTestCase, self).setUp(env)
|
||||
|
||||
self.tenant_id = uuidutils.generate_uuid()
|
||||
self.network = self.safe_client.create_network(self.tenant_id,
|
||||
|
@ -129,16 +64,90 @@ class TestQoSWithL2Agent(base.BaseFullStackTestCase):
|
|||
name='subnet-test',
|
||||
enable_dhcp=False)
|
||||
|
||||
# Create port with qos policy attached
|
||||
vm, qos_policy = self._prepare_vm_with_qos_policy(BANDWIDTH_LIMIT,
|
||||
BANDWIDTH_BURST)
|
||||
_wait_for_rule_applied(vm, BANDWIDTH_LIMIT, BANDWIDTH_BURST)
|
||||
qos_policy_id = qos_policy['id']
|
||||
rule = qos_policy['rules'][0]
|
||||
def _create_qos_policy(self):
|
||||
return self.safe_client.create_qos_policy(
|
||||
self.tenant_id, 'fs_policy', 'Fullstack testing policy',
|
||||
shared='False')
|
||||
|
||||
# Remove rule from qos policy
|
||||
self.client.delete_bandwidth_limit_rule(rule['id'], qos_policy_id)
|
||||
_wait_for_rule_removed(vm)
|
||||
def _prepare_vm_with_qos_policy(self, rule_add_functions):
|
||||
qos_policy = self._create_qos_policy()
|
||||
qos_policy_id = qos_policy['id']
|
||||
|
||||
port = self.safe_client.create_port(
|
||||
self.tenant_id, self.network['id'],
|
||||
self.environment.hosts[0].hostname,
|
||||
qos_policy_id)
|
||||
|
||||
for rule_add in rule_add_functions:
|
||||
rule_add(qos_policy)
|
||||
|
||||
vm = self.useFixture(
|
||||
machine.FakeFullstackMachine(
|
||||
self.environment.hosts[0],
|
||||
self.network['id'],
|
||||
self.tenant_id,
|
||||
self.safe_client,
|
||||
neutron_port=port))
|
||||
|
||||
return vm, qos_policy
|
||||
|
||||
|
||||
class TestBwLimitQoS(BaseQoSRuleTestCase):
|
||||
|
||||
scenarios = [
|
||||
("ovs", {'l2_agent_type': constants.AGENT_TYPE_OVS}),
|
||||
("linuxbridge", {'l2_agent_type': constants.AGENT_TYPE_LINUXBRIDGE})
|
||||
]
|
||||
|
||||
def _wait_for_bw_rule_applied_ovs_agent(self, vm, limit, burst):
|
||||
utils.wait_until_true(
|
||||
lambda: vm.bridge.get_egress_bw_limit_for_port(
|
||||
vm.port.name) == (limit, burst))
|
||||
|
||||
def _wait_for_bw_rule_applied_linuxbridge_agent(self, vm, limit, burst):
|
||||
port_name = linuxbridge_agent.LinuxBridgeManager.get_tap_device_name(
|
||||
vm.neutron_port['id'])
|
||||
tc = tc_lib.TcCommand(
|
||||
port_name,
|
||||
linuxbridge_agent_config.DEFAULT_KERNEL_HZ_VALUE,
|
||||
namespace=vm.host.host_namespace
|
||||
)
|
||||
utils.wait_until_true(
|
||||
lambda: tc.get_filters_bw_limits() == (limit, burst))
|
||||
|
||||
def _wait_for_bw_rule_applied(self, vm, limit, burst):
|
||||
if isinstance(vm.bridge, ovs_lib.OVSBridge):
|
||||
self._wait_for_bw_rule_applied_ovs_agent(vm, limit, burst)
|
||||
if isinstance(vm.bridge, bridge_lib.BridgeDevice):
|
||||
self._wait_for_bw_rule_applied_linuxbridge_agent(vm, limit, burst)
|
||||
|
||||
def _wait_for_bw_rule_removed(self, vm):
|
||||
# No values are provided when port doesn't have qos policy
|
||||
self._wait_for_bw_rule_applied(vm, None, None)
|
||||
|
||||
def _add_bw_limit_rule(self, limit, burst, qos_policy):
|
||||
qos_policy_id = qos_policy['id']
|
||||
rule = self.safe_client.create_bandwidth_limit_rule(
|
||||
self.tenant_id, qos_policy_id, limit, burst)
|
||||
# Make it consistent with GET reply
|
||||
rule['type'] = qos_consts.RULE_TYPE_BANDWIDTH_LIMIT
|
||||
rule['qos_policy_id'] = qos_policy_id
|
||||
qos_policy['rules'].append(rule)
|
||||
|
||||
def test_bw_limit_qos_policy_rule_lifecycle(self):
|
||||
new_limit = BANDWIDTH_LIMIT + 100
|
||||
|
||||
# Create port with qos policy attached
|
||||
vm, qos_policy = self._prepare_vm_with_qos_policy(
|
||||
[functools.partial(self._add_bw_limit_rule,
|
||||
BANDWIDTH_LIMIT, BANDWIDTH_BURST)])
|
||||
bw_rule = qos_policy['rules'][0]
|
||||
|
||||
self._wait_for_bw_rule_applied(vm, BANDWIDTH_LIMIT, BANDWIDTH_BURST)
|
||||
qos_policy_id = qos_policy['id']
|
||||
|
||||
self.client.delete_bandwidth_limit_rule(bw_rule['id'], qos_policy_id)
|
||||
self._wait_for_bw_rule_removed(vm)
|
||||
|
||||
# Create new rule with no given burst value, in such case ovs and lb
|
||||
# agent should apply burst value as
|
||||
|
@ -148,20 +157,74 @@ class TestQoSWithL2Agent(base.BaseFullStackTestCase):
|
|||
)
|
||||
new_rule = self.safe_client.create_bandwidth_limit_rule(
|
||||
self.tenant_id, qos_policy_id, new_limit)
|
||||
_wait_for_rule_applied(vm, new_limit, new_expected_burst)
|
||||
self._wait_for_bw_rule_applied(vm, new_limit, new_expected_burst)
|
||||
|
||||
# Update qos policy rule id
|
||||
self.client.update_bandwidth_limit_rule(
|
||||
new_rule['id'], qos_policy_id,
|
||||
body={'bandwidth_limit_rule': {'max_kbps': BANDWIDTH_LIMIT,
|
||||
'max_burst_kbps': BANDWIDTH_BURST}})
|
||||
_wait_for_rule_applied(vm, BANDWIDTH_LIMIT, BANDWIDTH_BURST)
|
||||
self._wait_for_bw_rule_applied(vm, BANDWIDTH_LIMIT, BANDWIDTH_BURST)
|
||||
|
||||
# Remove qos policy from port
|
||||
self.client.update_port(
|
||||
vm.neutron_port['id'],
|
||||
body={'port': {'qos_policy_id': None}})
|
||||
_wait_for_rule_removed(vm)
|
||||
self._wait_for_bw_rule_removed(vm)
|
||||
|
||||
|
||||
class TestDscpMarkingQoS(BaseQoSRuleTestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.l2_agent_type = constants.AGENT_TYPE_OVS
|
||||
super(TestDscpMarkingQoS, self).setUp()
|
||||
|
||||
def _wait_for_dscp_marking_rule_applied(self, vm, dscp_mark):
|
||||
l2_extensions.wait_until_dscp_marking_rule_applied(
|
||||
vm.bridge, vm.port.name, dscp_mark)
|
||||
|
||||
def _wait_for_dscp_marking_rule_removed(self, vm):
|
||||
self._wait_for_dscp_marking_rule_applied(vm, None)
|
||||
|
||||
def _add_dscp_rule(self, dscp_mark, qos_policy):
|
||||
qos_policy_id = qos_policy['id']
|
||||
rule = self.safe_client.create_dscp_marking_rule(
|
||||
self.tenant_id, qos_policy_id, dscp_mark)
|
||||
# Make it consistent with GET reply
|
||||
rule['type'] = qos_consts.RULE_TYPE_DSCP_MARK
|
||||
rule['qos_policy_id'] = qos_policy_id
|
||||
qos_policy['rules'].append(rule)
|
||||
|
||||
def test_dscp_qos_policy_rule_lifecycle(self):
|
||||
new_dscp_mark = DSCP_MARK + 8
|
||||
|
||||
# Create port with qos policy attached
|
||||
vm, qos_policy = self._prepare_vm_with_qos_policy(
|
||||
[functools.partial(self._add_dscp_rule, DSCP_MARK)])
|
||||
dscp_rule = qos_policy['rules'][0]
|
||||
|
||||
self._wait_for_dscp_marking_rule_applied(vm, DSCP_MARK)
|
||||
qos_policy_id = qos_policy['id']
|
||||
|
||||
self.client.delete_dscp_marking_rule(dscp_rule['id'], qos_policy_id)
|
||||
self._wait_for_dscp_marking_rule_removed(vm)
|
||||
|
||||
# Create new rule
|
||||
new_rule = self.safe_client.create_dscp_marking_rule(
|
||||
self.tenant_id, qos_policy_id, new_dscp_mark)
|
||||
self._wait_for_dscp_marking_rule_applied(vm, new_dscp_mark)
|
||||
|
||||
# Update qos policy rule id
|
||||
self.client.update_dscp_marking_rule(
|
||||
new_rule['id'], qos_policy_id,
|
||||
body={'dscp_marking_rule': {'dscp_mark': DSCP_MARK}})
|
||||
self._wait_for_dscp_marking_rule_applied(vm, DSCP_MARK)
|
||||
|
||||
# Remove qos policy from port
|
||||
self.client.update_port(
|
||||
vm.neutron_port['id'],
|
||||
body={'port': {'qos_policy_id': None}})
|
||||
self._wait_for_dscp_marking_rule_removed(vm)
|
||||
|
||||
|
||||
class TestQoSWithL2Population(base.BaseFullStackTestCase):
|
||||
|
|
Loading…
Reference in New Issue