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,13 +119,8 @@ 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
@@ -149,27 +139,23 @@ def test_sync_teardown_namespace_does_not_crash_on_error(self):
149
139
side_effect = Exception ()) as tdp :
150
140
self .agent .sync ()
151
141
152
- pdp .assert_has_calls (
153
- [
154
- mock .call (p .datapath )
155
- for p in self .ports
156
- ],
157
- any_order = True
158
- )
142
+ pdp .assert_has_calls ([mock .call (p ) for p in self .ports ],
143
+ any_order = True )
159
144
lnn .assert_called_once_with ()
160
145
tdp .assert_called_once_with ('3' )
161
146
162
- def test_get_networks_datapaths (self ):
163
- """Test get_networks_datapaths returns only datapath objects for the
164
- networks containing vif ports of type ''(blank) and 'external'.
147
+ def test_get_networks_port_bindings (self ):
148
+ """Test get_networks_port_bindings returns only the port binding
149
+ objects for ports with VIF type empty ('') or 'external'.
165
150
This test simulates that this chassis has the following ports:
166
- * datapath '1': 1 port type '' , 1 port 'external' and
167
- 1 port 'unknown'
168
- * datapath '2': 1 port type ''
169
- * datapath '3': 1 port with type 'external'
170
- * datapath '4': 1 port with type 'unknown'
171
-
172
- It is expected that only datapaths '1', '2' and '3' are returned
151
+ * port0: datapath 1, type ''
152
+ * port1: datapath 1, type 'external'
153
+ * port2: datapath 1, type 'unknown'
154
+ * port3: datapath 2, type ''
155
+ * port4: datapath 3, type 'external'
156
+ * port5: datapath 4, type 'unknown'
157
+
158
+ Only port bindings from ports 0, 1, 3, and 4 are expected.
173
159
"""
174
160
175
161
datapath_1 = DatapathInfo (uuid = 'uuid1' ,
@@ -192,11 +178,8 @@ def test_get_networks_datapaths(self):
192
178
193
179
with mock .patch .object (self .agent .sb_idl , 'get_ports_on_chassis' ,
194
180
return_value = ports ):
195
- expected_datapaths = set ([datapath_1 , datapath_2 , datapath_3 ])
196
- self .assertSetEqual (
197
- expected_datapaths ,
198
- self .agent .get_networks_datapaths ()
199
- )
181
+ self .assertEqual ([ports [0 ], ports [1 ], ports [3 ], ports [4 ]],
182
+ self .agent .get_networks_port_bindings ())
200
183
201
184
def test_teardown_datapath (self ):
202
185
"""Test teardown datapath.
@@ -424,7 +407,8 @@ def test_provision_datapath(self):
424
407
mock .patch .object (agent .MetadataAgent , '_get_namespace_name' ,
425
408
return_value = nemaspace_name ),\
426
409
mock .patch .object (ip_link , 'set_up' ) as link_set_up ,\
427
- mock .patch .object (ip_link , 'set_address' ) as link_set_addr ,\
410
+ mock .patch .object (ip_link , 'set_address' ) as link_set_addr , \
411
+ mock .patch .object (ip_link , 'set_mtu' ) as link_set_mtu , \
428
412
mock .patch .object (ip_addr , 'list' , return_value = []),\
429
413
mock .patch .object (
430
414
ip_addr , 'add_multiple' ) as ip_addr_add_multiple ,\
@@ -442,7 +426,11 @@ def test_provision_datapath(self):
442
426
# We need to assert that it was deleted first.
443
427
self .agent .ovs_idl .list_br .return_value .execute .return_value = (
444
428
['br-int' , 'br-fake' ])
445
- self .agent .provision_datapath ('fake_datapath' )
429
+ mtu = 1500
430
+ port_binding = mock .Mock (
431
+ datapath = 'fake_datapath' ,
432
+ external_ids = {ovn_const .OVN_NETWORK_MTU_EXT_ID_KEY : str (mtu )})
433
+ self .agent .provision_datapath (port_binding )
446
434
447
435
# Check that the port was deleted from br-fake
448
436
self .agent .ovs_idl .del_port .assert_called_once_with (
@@ -452,6 +440,7 @@ def test_provision_datapath(self):
452
440
nemaspace_name )
453
441
# Make sure that the two ends of the VETH pair have been set as up.
454
442
self .assertEqual (2 , link_set_up .call_count )
443
+ link_set_mtu .assert_has_calls ([mock .call (mtu ), mock .call (mtu )])
455
444
link_set_addr .assert_called_once_with ('aa:bb:cc:dd:ee:ff' )
456
445
# Make sure that the port has been added to OVS.
457
446
self .agent .ovs_idl .add_port .assert_called_once_with (
0 commit comments