Merge "Do not assume order of parameters in OVSBridge.add_flow call"
This commit is contained in:
commit
96156424ae
@ -109,6 +109,24 @@ class TestBaseOVS(base.BaseTestCase):
|
|||||||
self._test_port_exists(None, False)
|
self._test_port_exists(None, False)
|
||||||
|
|
||||||
|
|
||||||
|
class OFCTLParamListMatcher(object):
|
||||||
|
|
||||||
|
def _parse(self, params):
|
||||||
|
actions_pos = params.find('actions')
|
||||||
|
return set(params[:actions_pos].split(',')), params[actions_pos:]
|
||||||
|
|
||||||
|
def __init__(self, params):
|
||||||
|
self.expected = self._parse(params)
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
return self.expected == self._parse(other)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return 'ovs-ofctl parameters: %s, "%s"' % self.expected
|
||||||
|
|
||||||
|
__repr__ = __str__
|
||||||
|
|
||||||
|
|
||||||
class OVS_Lib_Test(base.BaseTestCase):
|
class OVS_Lib_Test(base.BaseTestCase):
|
||||||
"""A test suite to exercise the OVS libraries shared by Neutron agents.
|
"""A test suite to exercise the OVS libraries shared by Neutron agents.
|
||||||
|
|
||||||
@ -261,36 +279,43 @@ class OVS_Lib_Test(base.BaseTestCase):
|
|||||||
self.br.add_flow(**flow_dict_7)
|
self.br.add_flow(**flow_dict_7)
|
||||||
expected_calls = [
|
expected_calls = [
|
||||||
mock.call(["ovs-ofctl", "add-flows", self.BR_NAME, '-'],
|
mock.call(["ovs-ofctl", "add-flows", self.BR_NAME, '-'],
|
||||||
process_input="hard_timeout=0,idle_timeout=0,"
|
process_input=OFCTLParamListMatcher(
|
||||||
"priority=2,dl_src=ca:fe:de:ad:be:ef"
|
"hard_timeout=0,idle_timeout=0,"
|
||||||
",actions=strip_vlan,output:0",
|
"priority=2,dl_src=ca:fe:de:ad:be:ef,"
|
||||||
|
"actions=strip_vlan,output:0"),
|
||||||
root_helper=self.root_helper),
|
root_helper=self.root_helper),
|
||||||
mock.call(["ovs-ofctl", "add-flows", self.BR_NAME, '-'],
|
mock.call(["ovs-ofctl", "add-flows", self.BR_NAME, '-'],
|
||||||
process_input="hard_timeout=0,idle_timeout=0,"
|
process_input=OFCTLParamListMatcher(
|
||||||
"priority=1,actions=normal",
|
"hard_timeout=0,idle_timeout=0,"
|
||||||
|
"priority=1,actions=normal"),
|
||||||
root_helper=self.root_helper),
|
root_helper=self.root_helper),
|
||||||
mock.call(["ovs-ofctl", "add-flows", self.BR_NAME, '-'],
|
mock.call(["ovs-ofctl", "add-flows", self.BR_NAME, '-'],
|
||||||
process_input="hard_timeout=0,idle_timeout=0,"
|
process_input=OFCTLParamListMatcher(
|
||||||
"priority=2,actions=drop",
|
"hard_timeout=0,idle_timeout=0,"
|
||||||
|
"priority=2,actions=drop"),
|
||||||
root_helper=self.root_helper),
|
root_helper=self.root_helper),
|
||||||
mock.call(["ovs-ofctl", "add-flows", self.BR_NAME, '-'],
|
mock.call(["ovs-ofctl", "add-flows", self.BR_NAME, '-'],
|
||||||
process_input="hard_timeout=0,idle_timeout=0,priority=2,"
|
process_input=OFCTLParamListMatcher(
|
||||||
"in_port=%s,actions=drop" % ofport,
|
"hard_timeout=0,idle_timeout=0,priority=2,"
|
||||||
|
"in_port=%s,actions=drop" % ofport),
|
||||||
root_helper=self.root_helper),
|
root_helper=self.root_helper),
|
||||||
mock.call(["ovs-ofctl", "add-flows", self.BR_NAME, '-'],
|
mock.call(["ovs-ofctl", "add-flows", self.BR_NAME, '-'],
|
||||||
process_input="hard_timeout=0,idle_timeout=0,"
|
process_input=OFCTLParamListMatcher(
|
||||||
"priority=4,dl_vlan=%s,in_port=%s,"
|
"hard_timeout=0,idle_timeout=0,"
|
||||||
"actions=strip_vlan,set_tunnel:%s,normal"
|
"priority=4,dl_vlan=%s,in_port=%s,"
|
||||||
% (vid, ofport, lsw_id),
|
"actions=strip_vlan,set_tunnel:%s,normal"
|
||||||
|
% (vid, ofport, lsw_id)),
|
||||||
root_helper=self.root_helper),
|
root_helper=self.root_helper),
|
||||||
mock.call(["ovs-ofctl", "add-flows", self.BR_NAME, '-'],
|
mock.call(["ovs-ofctl", "add-flows", self.BR_NAME, '-'],
|
||||||
process_input="hard_timeout=0,idle_timeout=0,priority=3,"
|
process_input=OFCTLParamListMatcher(
|
||||||
"tun_id=%s,actions=mod_vlan_vid:%s,"
|
"hard_timeout=0,idle_timeout=0,priority=3,"
|
||||||
"output:%s" % (lsw_id, vid, ofport),
|
"tun_id=%s,actions=mod_vlan_vid:%s,"
|
||||||
|
"output:%s" % (lsw_id, vid, ofport)),
|
||||||
root_helper=self.root_helper),
|
root_helper=self.root_helper),
|
||||||
mock.call(["ovs-ofctl", "add-flows", self.BR_NAME, '-'],
|
mock.call(["ovs-ofctl", "add-flows", self.BR_NAME, '-'],
|
||||||
process_input="hard_timeout=0,idle_timeout=0,priority=4,"
|
process_input=OFCTLParamListMatcher(
|
||||||
"nw_src=%s,arp,actions=drop" % cidr,
|
"hard_timeout=0,idle_timeout=0,priority=4,"
|
||||||
|
"nw_src=%s,arp,actions=drop" % cidr),
|
||||||
root_helper=self.root_helper),
|
root_helper=self.root_helper),
|
||||||
]
|
]
|
||||||
self.execute.assert_has_calls(expected_calls)
|
self.execute.assert_has_calls(expected_calls)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user