28
28
from neutron .agent .linux .ip_lib import IPWrapper as ip_wrap
29
29
from neutron .agent .ovn .metadata import agent
30
30
from neutron .agent .ovn .metadata import driver
31
+ from neutron .common .ovn import constants as ovn_const
31
32
from neutron .conf .agent .metadata import config as meta_conf
32
33
from neutron .conf .agent .ovn .metadata import config as ovn_meta_conf
33
34
from neutron .conf .plugins .ml2 .drivers .ovn import ovn_conf
@@ -100,14 +101,8 @@ def test_sync(self):
100
101
101
102
self .agent .sync ()
102
103
103
- pdp .assert_has_calls (
104
- [
105
- mock .call (p .datapath )
106
- for p in self .ports
107
- ],
108
- any_order = True
109
- )
110
-
104
+ pdp .assert_has_calls ([mock .call (p ) for p in self .ports ],
105
+ any_order = True )
111
106
lnn .assert_called_once_with ()
112
107
tdp .assert_not_called ()
113
108
@@ -124,27 +119,23 @@ def test_sync_teardown_namespace(self):
124
119
125
120
self .agent .sync ()
126
121
127
- pdp .assert_has_calls (
128
- [
129
- mock .call (p .datapath )
130
- for p in self .ports
131
- ],
132
- any_order = True
133
- )
122
+ pdp .assert_has_calls ([mock .call (p ) for p in self .ports ],
123
+ any_order = True )
134
124
lnn .assert_called_once_with ()
135
125
tdp .assert_called_once_with ('3' )
136
126
137
- def test_get_networks_datapaths (self ):
138
- """Test get_networks_datapaths returns only datapath objects for the
139
- networks containing vif ports of type ''(blank) and 'external'.
127
+ def test_get_networks_port_bindings (self ):
128
+ """Test get_networks_port_bindings returns only the port binding
129
+ objects for ports with VIF type empty ('') or 'external'.
140
130
This test simulates that this chassis has the following ports:
141
- * datapath '1': 1 port type '' , 1 port 'external' and
142
- 1 port 'unknown'
143
- * datapath '2': 1 port type ''
144
- * datapath '3': 1 port with type 'external'
145
- * datapath '4': 1 port with type 'unknown'
146
-
147
- It is expected that only datapaths '1', '2' and '3' are returned
131
+ * port0: datapath 1, type ''
132
+ * port1: datapath 1, type 'external'
133
+ * port2: datapath 1, type 'unknown'
134
+ * port3: datapath 2, type ''
135
+ * port4: datapath 3, type 'external'
136
+ * port5: datapath 4, type 'unknown'
137
+
138
+ Only port bindings from ports 0, 1, 3, and 4 are expected.
148
139
"""
149
140
150
141
datapath_1 = DatapathInfo (uuid = 'uuid1' ,
@@ -167,11 +158,8 @@ def test_get_networks_datapaths(self):
167
158
168
159
with mock .patch .object (self .agent .sb_idl , 'get_ports_on_chassis' ,
169
160
return_value = ports ):
170
- expected_datapaths = set ([datapath_1 , datapath_2 , datapath_3 ])
171
- self .assertSetEqual (
172
- expected_datapaths ,
173
- self .agent .get_networks_datapaths ()
174
- )
161
+ self .assertEqual ([ports [0 ], ports [1 ], ports [3 ], ports [4 ]],
162
+ self .agent .get_networks_port_bindings ())
175
163
176
164
def test_teardown_datapath (self ):
177
165
"""Test teardown datapath.
@@ -399,7 +387,8 @@ def test_provision_datapath(self):
399
387
mock .patch .object (agent .MetadataAgent , '_get_namespace_name' ,
400
388
return_value = nemaspace_name ),\
401
389
mock .patch .object (ip_link , 'set_up' ) as link_set_up ,\
402
- mock .patch .object (ip_link , 'set_address' ) as link_set_addr ,\
390
+ mock .patch .object (ip_link , 'set_address' ) as link_set_addr , \
391
+ mock .patch .object (ip_link , 'set_mtu' ) as link_set_mtu , \
403
392
mock .patch .object (ip_addr , 'list' , return_value = []),\
404
393
mock .patch .object (ip_addr , 'add' ) as ip_addr_add ,\
405
394
mock .patch .object (
@@ -416,7 +405,11 @@ def test_provision_datapath(self):
416
405
# We need to assert that it was deleted first.
417
406
self .agent .ovs_idl .list_br .return_value .execute .return_value = (
418
407
['br-int' , 'br-fake' ])
419
- self .agent .provision_datapath ('fake_datapath' )
408
+ mtu = 1500
409
+ port_binding = mock .Mock (
410
+ datapath = 'fake_datapath' ,
411
+ external_ids = {ovn_const .OVN_NETWORK_MTU_EXT_ID_KEY : str (mtu )})
412
+ self .agent .provision_datapath (port_binding )
420
413
421
414
# Check that the port was deleted from br-fake
422
415
self .agent .ovs_idl .del_port .assert_called_once_with (
@@ -426,6 +419,7 @@ def test_provision_datapath(self):
426
419
nemaspace_name )
427
420
# Make sure that the two ends of the VETH pair have been set as up.
428
421
self .assertEqual (2 , link_set_up .call_count )
422
+ link_set_mtu .assert_has_calls ([mock .call (mtu ), mock .call (mtu )])
429
423
link_set_addr .assert_called_once_with ('aa:bb:cc:dd:ee:ff' )
430
424
# Make sure that the port has been added to OVS.
431
425
self .agent .ovs_idl .add_port .assert_called_once_with (
0 commit comments