1fbedf5fb954f9ab10fbd30423d1627e38e18d5c
[cascardo/ovs.git] / tests / ovn-controller-vtep.at
1 AT_BANNER([ovn_controller_vtep])
2
3 # OVN_CONTROLLER_VTEP_START
4 #
5 # Starts the test with a setup with vtep device.  Each test case must first
6 # call this macro.
7 #
8 # Uses vtep-ovs to simulate the vtep switch 'br-vtep' with two physical ports
9 # 'p0', 'p1'.
10 #
11 # Configures ovn-nb with a logical switch 'br-test'.
12 #
13 #
14 m4_define([OVN_CONTROLLER_VTEP_START],
15   [
16    # this will cause skip when 'make check' using Windows setup.
17    AT_SKIP_IF([test $HAVE_PYTHON = no])
18
19    dnl Create databases (ovn-nb, ovn-sb, vtep).
20    AT_CHECK([ovsdb-tool create vswitchd.db $abs_top_srcdir/vswitchd/vswitch.ovsschema])
21    for daemon in ovn-nb ovn-sb vtep; do
22       AT_CHECK([ovsdb-tool create $daemon.db $abs_top_srcdir/${daemon%%-*}/${daemon}.ovsschema])
23    done
24
25    dnl Start ovsdb-server.
26    AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock vswitchd.db vtep.db ovn-nb.db ovn-sb.db], [0], [], [stderr])
27    on_exit "kill `cat ovsdb-server.pid`"
28    AT_CHECK([[sed < stderr '
29 /vlog|INFO|opened log file/d
30 /ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']])
31    AT_CAPTURE_FILE([ovsdb-server.log])
32
33    dnl Start ovs-vswitchd.
34    AT_CHECK([ovs-vswitchd --enable-dummy --disable-system --detach --no-chdir --pidfile --log-file -vvconn -vofproto_dpif], [0], [], [stderr])
35    AT_CAPTURE_FILE([ovs-vswitchd.log])
36    on_exit "kill `cat ovs-vswitchd.pid`"
37    AT_CHECK([[sed < stderr '
38 /ovs_numa|INFO|Discovered /d
39 /vlog|INFO|opened log file/d
40 /vswitchd|INFO|ovs-vswitchd (Open vSwitch)/d
41 /reconnect|INFO|/d
42 /ofproto|INFO|using datapath ID/d
43 /ofproto|INFO|datapath ID changed to fedcba9876543210/d']])
44    AT_CHECK([ovs-vsctl -- add-br br-vtep \
45               -- set bridge br-vtep datapath-type=dummy other-config:datapath-id=fedcba9876543210 other-config:hwaddr=aa:55:aa:55:00:00 protocols=[[OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13,OpenFlow14,OpenFlow15]] fail-mode=secure \
46               -- add-port br-vtep p0 -- set Interface p0 type=dummy ofport_request=1 \
47               -- add-port br-vtep p1 -- set Interface p1 type=dummy ofport_request=2])
48
49    dnl Start ovs-vtep.
50    AT_CHECK([vtep-ctl add-ps br-vtep -- set Physical_Switch br-vtep tunnel_ips=1.2.3.4])
51    AT_CHECK([ovs-vtep --log-file=ovs-vtep.log --pidfile=ovs-vtep.pid --detach br-vtep \], [0], [], [stderr])
52    on_exit "kill `cat ovs-vtep.pid`"
53    AT_CHECK([[sed < stderr '
54 /vlog|INFO|opened log file/d']])
55    # waits until ovs-vtep starts up.
56    OVS_WAIT_UNTIL([test -n "`vtep-ctl show | grep Physical_Port`"])
57
58    dnl Start ovn-northd.
59    AT_CHECK([ovn-nbctl lswitch-add br-test])
60    AT_CHECK([ovn-northd --detach --pidfile --log-file --ovnnb-db=unix:$OVS_RUNDIR/db.sock --ovnsb-db=unix:$OVS_RUNDIR/db.sock], [0], [], [stderr])
61    on_exit "kill `cat ovn-northd.pid`"
62    AT_CHECK([[sed < stderr '
63 /vlog|INFO|opened log file/d']])
64    AT_CAPTURE_FILE([ovn-northd.log])
65
66    dnl Start ovn-controllger-vtep.
67    AT_CHECK([ovn-controller-vtep --detach --pidfile --log-file --vtep-db=unix:$OVS_RUNDIR/db.sock --ovnsb-db=unix:$OVS_RUNDIR/db.sock], [0], [], [stderr])
68    AT_CAPTURE_FILE([ovn-controller-vtep.log])
69    on_exit "kill `cat ovn-controller-vtep.pid`"
70    AT_CHECK([[sed < stderr '
71 /vlog|INFO|opened log file/d
72 /reconnect|INFO|/d']])
73 ])
74
75 # OVN_CONTROLLER_VTEP_STOP
76 #
77 # So many exits... Yeah, we started a lot daemons~
78 #
79 m4_define([OVN_CONTROLLER_VTEP_STOP],
80   [# removes all 'Broken pipe' warning logs from ovsdb-server.log.  this is in
81    # that *ctl command (e.g. ovn-nbctl) exits right after committing the change
82    # to database.  however, in reaction, some daemon (e.g. ovn-controller-vtep)
83    # may immediately update the database.  this later update may cause database
84    # sending update back to *ctl command if *ctl has not proceeded to exit yet.
85    # and if *ctl command exits before database calling send, the send from
86    # database will fail with 'Broken pipe' error.
87    AT_CHECK([check_logs "$1
88 /Broken pipe/d"])
89    AT_CHECK([ovs-appctl -t ovs-vtep exit])
90    AT_CHECK([ovs-appctl -t ovn-northd exit])
91    AT_CHECK([ovs-appctl -t ovn-controller-vtep exit])
92    # makes sure ovn-controller-vtep exits.
93    OVS_WAIT_UNTIL([test ! -f ovn-controller-vtep.pid])
94    AT_CHECK([ovs-appctl -t ovsdb-server exit])
95    AT_CHECK([ovs-appctl -t ovs-vswitchd exit])])
96
97 # Adds logical port for a vtep gateway chassis in ovn-nb database.
98 #
99 # $1: logical switch name in ovn-nb database
100 # $2: logical port name
101 # $3: physical vtep gateway name
102 # $4: logical switch name on vtep gateway chassis
103 m4_define([OVN_NB_ADD_VTEP_PORT], [
104 AT_CHECK([ovn-nbctl lport-add $1 $2])
105 AT_CHECK([ovn-nbctl lport-set-type $2 vtep])
106 AT_CHECK([ovn-nbctl lport-set-options $2 vtep-physical-switch=$3 vtep-logical-switch=$4])
107 ])
108
109 ##############################################
110
111 # tests chassis related updates.
112 AT_SETUP([ovn-controller-vtep - test chassis])
113 OVN_CONTROLLER_VTEP_START
114
115 # verifies the initial ovn-sb db configuration.
116 AT_CHECK([ovn-sbctl show], [0], [dnl
117 Chassis br-vtep
118     Encap vxlan
119         ip: "1.2.3.4"
120 ])
121
122 # deletes the chassis via ovn-sbctl and check that it is readded back
123 # with the log.
124 AT_CHECK([ovn-sbctl chassis-del br-vtep])
125 OVS_WAIT_UNTIL([test -n "`grep WARN ovn-controller-vtep.log`"])
126 AT_CHECK([sed -n 's/^.*\(|WARN|.*\)$/\1/p' ovn-controller-vtep.log], [0], [dnl
127 |WARN|Chassis for VTEP physical switch (br-vtep) disappears, maybe deleted by ovn-sbctl, adding it back
128 ])
129
130 # changes the tunnel_ip on physical switch, watches the update of chassis's
131 # encap.
132 AT_CHECK([vtep-ctl set Physical_Switch br-vtep tunnel_ips=1.2.3.5])
133 OVS_WAIT_UNTIL([test -n "`ovn-sbctl show | grep 1\.2\.3\.5`"])
134 AT_CHECK([ovn-sbctl --columns=ip list Encap | cut -d ':' -f2 | tr -d ' '], [0], [dnl
135 "1.2.3.5"
136 ])
137
138 # adds vlan_bindings to physical ports.
139 AT_CHECK([vtep-ctl add-ls lswitch0 -- bind-ls br-vtep p0 100 lswitch0 -- bind-ls br-vtep p0 200 lswitch0 -- bind-ls br-vtep p1 300 lswitch0])
140 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Chassis | grep -- lswitch0`"])
141 AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' ' ], [0], [dnl
142 [["lswitch0"]]
143 ])
144
145 # adds another logical switch and new vlan_bindings.
146 AT_CHECK([vtep-ctl add-ls lswitch1 -- bind-ls br-vtep p0 300 lswitch1])
147 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Chassis | grep -- lswitch1`"])
148 AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' '], [0], [dnl
149 [["lswitch0","lswitch1"]]
150 ])
151
152 # unbinds one port from lswitch0, nothing should change.
153 AT_CHECK([vtep-ctl unbind-ls br-vtep p0 200])
154 OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=vlan_bindings list physical_port p0 | grep -- '200='`"])
155 AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' ' ], [0], [dnl
156 [["lswitch0","lswitch1"]]
157 ])
158
159 # unbinds all ports from lswitch0.
160 AT_CHECK([vtep-ctl unbind-ls br-vtep p0 100 -- unbind-ls br-vtep p1 300])
161 OVS_WAIT_UNTIL([test -z "`ovn-sbctl list Chassis | grep -- br-vtep_lswitch0`"])
162 AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' ' ], [0], [dnl
163 [["lswitch1"]]
164 ])
165
166 # unbinds all ports from lswitch1.
167 AT_CHECK([vtep-ctl unbind-ls br-vtep p0 300])
168 OVS_WAIT_UNTIL([test -z "`ovn-sbctl list Chassis | grep -- br-vtep_lswitch1`"])
169 AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' '], [0], [dnl
170 [[]]
171 ])
172
173 OVN_CONTROLLER_VTEP_STOP([/Chassis for VTEP physical switch (br-vtep) disappears/d])
174 AT_CLEANUP
175
176
177 # Tests binding updates.
178 AT_SETUP([ovn-controller-vtep - test binding 1])
179 OVN_CONTROLLER_VTEP_START
180
181 # adds logical switch 'lswitch0' and vlan_bindings.
182 AT_CHECK([vtep-ctl add-ls lswitch0 -- bind-ls br-vtep p0 100 lswitch0 -- bind-ls br-vtep p1 300 lswitch0])
183 # adds lport in ovn-nb database, and sets the type and options.
184 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch0], [br-vtep], [lswitch0])
185 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding  | grep br-vtep_lswitch0`"])
186 # should see one binding, associated to chassis of 'br-vtep'.
187 chassis_uuid=$(ovn-sbctl --columns=_uuid list Chassis br-vtep | cut -d ':' -f2 | tr -d ' ')
188 AT_CHECK_UNQUOTED([ovn-sbctl --columns=chassis list Port_Binding br-vtep_lswitch0 | cut -d ':' -f2 | tr -d ' '], [0], [dnl
189 ${chassis_uuid}
190 ])
191
192 # adds another logical switch 'lswitch1' and vlan_bindings.
193 AT_CHECK([vtep-ctl add-ls lswitch1 -- bind-ls br-vtep p0 200 lswitch1])
194 # adds lport in ovn-nb database for lswitch1.
195 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch1], [br-vtep], [lswitch1])
196 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep -- br-vtep_lswitch1`"])
197 # This is allowed, but not recommended, to have two vlan_bindings (to different vtep logical switches)
198 # from one vtep gateway physical port in one ovn-nb logical swithch.
199 AT_CHECK_UNQUOTED([ovn-sbctl --columns=chassis list Port_Binding | cut -d ':' -f2 | tr -d ' ' | sort -d], [0], [dnl
200
201 ${chassis_uuid}
202 ${chassis_uuid}
203 ])
204
205 # adds another lport in ovn-nb database for lswitch0.
206 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch0_dup], [br-vtep], [lswitch0])
207 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep -- br-vtep_lswitch0_dup`"])
208 # it is not allowed to have more than one ovn-nb logical port for the same
209 # vtep logical switch on a vtep gateway chassis, so should still see only
210 # two port_binding entries bound.
211 AT_CHECK_UNQUOTED([ovn-sbctl --columns=chassis list Port_Binding | cut -d ':' -f2 | tr -d ' ' | sort -d], [0], [dnl
212
213
214 [[]]
215 ${chassis_uuid}
216 ${chassis_uuid}
217 ])
218 # confirms the warning log.
219 AT_CHECK([sed -n 's/^.*\(|WARN|.*\)$/\1/p' ovn-controller-vtep.log | sed 's/([[-_0-9a-z]][[-_0-9a-z]]*)/()/g' | uniq], [0], [dnl
220 |WARN|logical switch (), on vtep gateway chassis () has already been associated with logical port (), ignore logical port ()
221 ])
222
223 # deletes physical ports from vtep.
224 AT_CHECK([ovs-vsctl del-port p0 -- del-port p1])
225 AT_CHECK([vtep-ctl del-port br-vtep p0 -- del-port br-vtep p1])
226 OVS_WAIT_UNTIL([test -z "`ovn-sbctl list Chassis | grep -- br-vtep_lswitch`"])
227 # should see empty chassis column in both binding entries.
228 AT_CHECK_UNQUOTED([ovn-sbctl --columns=chassis list Port_Binding | cut -d ':' -f2 | tr -d ' ' | sort], [0], [dnl
229
230
231 [[]]
232 [[]]
233 [[]]
234 ])
235
236 OVN_CONTROLLER_VTEP_STOP([/has already been associated with logical port/d])
237 AT_CLEANUP
238
239
240 # Tests corner case: Binding the vtep logical switch from two different
241 # datapath.
242 AT_SETUP([ovn-controller-vtep - test binding 2])
243 OVN_CONTROLLER_VTEP_START
244
245 # adds logical switch 'lswitch0' and vlan_bindings.
246 AT_CHECK([vtep-ctl add-ls lswitch0 -- bind-ls br-vtep p0 100 lswitch0])
247 # adds lport in ovn-nb database, and sets the type and options.
248 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch0], [br-vtep], [lswitch0])
249 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding  | grep br-vtep_lswitch0`"])
250
251 # adds another lswitch 'br-void' in ovn-nb database.
252 AT_CHECK([ovn-nbctl lswitch-add br-void])
253 # adds another vtep pswitch 'br-vtep-void' in vtep database.
254 AT_CHECK([vtep-ctl add-ps br-vtep-void -- add-port br-vtep-void p0-void -- bind-ls br-vtep-void p0-void 100 lswitch0])
255 # adds a conflicting logical port (both br-vtep_lswitch0 and br-vtep-void_lswitch0
256 # are bound to the same logical switch, but they are on different datapath).
257 OVN_NB_ADD_VTEP_PORT([br-void], [br-vtep-void_lswitch0], [br-vtep-void], [lswitch0])
258 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding  | grep br-vtep-void_lswitch0`"])
259 OVS_WAIT_UNTIL([test -n "`grep WARN ovn-controller-vtep.log`"])
260 # confirms the warning log.
261 AT_CHECK([sed -n 's/^.*\(|WARN|.*\)$/\1/p' ovn-controller-vtep.log | sed 's/([[-_0-9a-z]][[-_0-9a-z]]*)/()/g;s/(with tunnel key [[0-9]][[0-9]]*)/()/g' | uniq], [0], [dnl
262 |WARN|logical switch (), on vtep gateway chassis () has already been associated with logical datapath (), ignore logical port () which belongs to logical datapath ()
263 ])
264
265 # then deletes 'br-void' and 'br-vtep-void', should see 'br-vtep_lswitch0'
266 # bound correctly.
267 AT_CHECK([ovn-nbctl lswitch-del br-void])
268 # adds another vtep pswitch 'br-vtep-void' in vtep database.
269 AT_CHECK([vtep-ctl del-ps br-vtep-void])
270 OVS_WAIT_UNTIL([test -z "`ovn-sbctl list Port_Binding | grep br-vtep-void_lswitch0`"])
271 chassis_uuid=$(ovn-sbctl --columns=_uuid list Chassis br-vtep | cut -d ':' -f2 | tr -d ' ')
272 AT_CHECK_UNQUOTED([ovn-sbctl --columns=chassis list Port_Binding br-vtep_lswitch0 | cut -d ':' -f2 | tr -d ' '], [0], [dnl
273 ${chassis_uuid}
274 ])
275
276 OVN_CONTROLLER_VTEP_STOP([/has already been associated with logical datapath/d])
277 AT_CLEANUP
278
279
280 # Tests vtep module vtep logical switch tunnel key update.
281 AT_SETUP([ovn-controller-vtep - test vtep-lswitch])
282 OVN_CONTROLLER_VTEP_START
283
284 # creates the logical switch in vtep and adds the corresponding logical
285 # port to 'br-test'.
286 AT_CHECK([vtep-ctl add-ls lswitch0 -- bind-ls br-vtep p0 100 lswitch0])
287 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch0], [br-vtep], [lswitch0])
288 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding  | grep -- br-vtep_lswitch0`"])
289
290 # retrieves the expected tunnel key.
291 datapath_uuid=$(ovn-sbctl --columns=datapath list Port_Binding br-vtep_lswitch0 | cut -d ':' -f2 | tr -d ' ')
292 tunnel_key=$(ovn-sbctl --columns=tunnel_key list Datapath_Binding ${datapath_uuid} | cut -d ':' -f2 | tr -d ' ')
293 OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=tunnel_key list Logical_Switch | grep 0`"])
294 # checks the vtep logical switch tunnel key configuration.
295 AT_CHECK_UNQUOTED([vtep-ctl --columns=tunnel_key list Logical_Switch | cut -d ':' -f2 | tr -d ' '], [0], [dnl
296 ${tunnel_key}
297 ])
298
299 # creates a second physical switch in vtep database, and binds its p0 vlan-100
300 # to the same logical switch 'lswitch0'.
301 AT_CHECK([vtep-ctl add-ps br-vtep-void -- add-port br-vtep-void p0 -- bind-ls br-vtep-void p0 100 lswitch0])
302 OVS_WAIT_UNTIL([test -n "`ovn-sbctl --columns=name list Chassis  | grep -- br-vtep-void`"])
303 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep-void_lswitch0], [br-vtep-void], [lswitch0])
304 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding  | grep -- br-vtep-void_lswitch0`"])
305
306 # checks the vtep logical switch tunnel key configuration.
307 AT_CHECK_UNQUOTED([vtep-ctl --columns=tunnel_key list Logical_Switch | cut -d ':' -f2 | tr -d ' '], [0], [dnl
308 ${tunnel_key}
309 ])
310
311 # now, deletes br-vtep-void.
312 AT_CHECK([vtep-ctl del-ps br-vtep-void])
313 OVS_WAIT_UNTIL([test -z "`ovn-sbctl --columns=name list Chassis  | grep -- br-vtep-void`"])
314 # checks the vtep logical switch tunnel key configuration.
315 AT_CHECK_UNQUOTED([vtep-ctl --columns=tunnel_key list Logical_Switch | cut -d ':' -f2 | tr -d ' '], [0], [dnl
316 ${tunnel_key}
317 ])
318
319 # changes the ovn-nb logical port type so that it is no longer
320 # vtep port.
321 AT_CHECK([ovn-nbctl lport-set-type br-vtep_lswitch0 void])
322 OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=tunnel_key list Logical_Switch | grep 1`"])
323 # now should see the tunnel key reset.
324 AT_CHECK([vtep-ctl --columns=tunnel_key list Logical_Switch | cut -d ':' -f2 | tr -d ' '], [0], [dnl
325 0
326 ])
327
328 OVN_CONTROLLER_VTEP_STOP
329 AT_CLEANUP
330
331
332 # Tests vtep module 'Ucast_Macs_Remote's.
333 AT_SETUP([ovn-controller-vtep - test vtep-macs 1])
334 OVN_CONTROLLER_VTEP_START
335
336 # creates a simple logical network with the vtep device and a fake hv chassis
337 # 'ch0'.
338 AT_CHECK([ovn-nbctl lport-add br-test vif0])
339 AT_CHECK([ovn-nbctl lport-set-macs vif0 f0:ab:cd:ef:01:02])
340 AT_CHECK([ovn-sbctl chassis-add ch0 vxlan 1.2.3.5])
341 AT_CHECK([ovn-sbctl lport-bind vif0 ch0])
342
343 # creates the logical switch in vtep and adds the corresponding logical
344 # port to 'br-test'.
345 AT_CHECK([vtep-ctl add-ls lswitch0 -- bind-ls br-vtep p0 100 lswitch0])
346 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch0], [br-vtep], [lswitch0])
347 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding  | grep br-vtep_lswitch0`"])
348
349 # adds another lswitch 'br-void' in ovn-nb database.
350 AT_CHECK([ovn-nbctl lswitch-add br-void])
351 # adds fake hv chassis 'ch1'.
352 AT_CHECK([ovn-nbctl lport-add br-void vif1])
353 AT_CHECK([ovn-nbctl lport-set-macs vif1 f0:ab:cd:ef:01:02])
354 AT_CHECK([ovn-sbctl chassis-add ch1 vxlan 1.2.3.6])
355 AT_CHECK([ovn-sbctl lport-bind vif1 ch1])
356 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep vif1`"])
357
358 # checks Ucast_Macs_Remote creation.
359 OVS_WAIT_UNTIL([test -n "`vtep-ctl list Ucast_Macs_Remote | grep _uuid`"])
360 AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' '], [0], [dnl
361 "f0:ab:cd:ef:01:02"
362 ])
363
364 # checks physical locator creation.
365 OVS_WAIT_UNTIL([test -n "`vtep-ctl list Physical_Locator | grep _uuid`"])
366 AT_CHECK([vtep-ctl --columns=dst_ip list Physical_Locator | cut -d ':' -f2 | tr -d ' ' | grep -v 1.2.3.4 | sed '/^$/d'], [0], [dnl
367 "1.2.3.5"
368 ])
369
370 # checks tunnel creation by ovs-vtep.
371 OVS_WAIT_UNTIL([test -n "`ovs-vsctl list Interface bfd1.2.3.5`"])
372 AT_CHECK([ovs-vsctl --columns=options list Interface bfd1.2.3.5 | cut -d ':' -f2 | tr -d ' '], [0], [dnl
373 {remote_ip="1.2.3.5"}
374 ])
375
376 # adds another mac to lport.
377 AT_CHECK([ovn-nbctl lport-set-macs vif0 f0:ab:cd:ef:01:02 f0:ab:cd:ef:01:03])
378 OVS_WAIT_UNTIL([test -n "`vtep-ctl list Ucast_Macs_Remote | grep 03`"])
379 AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' ' | sort], [0], [dnl
380
381 "f0:ab:cd:ef:01:02"
382 "f0:ab:cd:ef:01:03"
383 ])
384
385 # removes one mac to lport.
386 AT_CHECK([ovn-nbctl lport-set-macs vif0 f0:ab:cd:ef:01:03])
387 OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=MAC list Ucast_Macs_Remote | grep 02`"])
388 AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' ' | sort], [0], [dnl
389 "f0:ab:cd:ef:01:03"
390 ])
391
392 # migrates mac to lport vif1 on 'br-void'.
393 AT_CHECK([ovn-nbctl lport-set-macs vif0])
394 AT_CHECK([ovn-nbctl lport-set-macs vif1 f0:ab:cd:ef:01:03])
395 OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=MAC list Ucast_Macs_Remote | grep 03`"])
396 AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' ' | sort], [0], [dnl
397 ])
398
399 OVN_CONTROLLER_VTEP_STOP
400 AT_CLEANUP
401
402
403 # Tests vtep module 'Ucast_Macs_Remote's (corner cases).
404 AT_SETUP([ovn-controller-vtep - test vtep-macs 2])
405 OVN_CONTROLLER_VTEP_START
406
407 # creates a simple logical network with the vtep device and a fake hv chassis
408 # 'ch0'.
409 AT_CHECK([ovn-nbctl lport-add br-test vif0])
410 AT_CHECK([ovn-nbctl lport-set-macs vif0 f0:ab:cd:ef:01:02])
411 AT_CHECK([ovn-sbctl chassis-add ch0 vxlan 1.2.3.5])
412 AT_CHECK([ovn-sbctl lport-bind vif0 ch0])
413
414 # creates another vif in the same logical switch with duplicate mac.
415 AT_CHECK([ovn-nbctl lport-add br-test vif1])
416 AT_CHECK([ovn-nbctl lport-set-macs vif1 f0:ab:cd:ef:01:02])
417 AT_CHECK([ovn-sbctl lport-bind vif1 ch0])
418
419 # creates the logical switch in vtep and adds the corresponding logical
420 # port to 'br-test'.
421 AT_CHECK([vtep-ctl add-ls lswitch0 -- bind-ls br-vtep p0 100 lswitch0])
422 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch0], [br-vtep], [lswitch0])
423 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding  | grep br-vtep_lswitch0`"])
424
425 # checks Ucast_Macs_Remote creation.  Should still only be one entry, since duplicate
426 # mac in the same logical switch is not allowed.
427 OVS_WAIT_UNTIL([test -n "`vtep-ctl list Ucast_Macs_Remote | grep _uuid`"])
428 AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' '], [0], [dnl
429 "f0:ab:cd:ef:01:02"
430 ])
431 # confirms the warning log.
432 OVS_WAIT_UNTIL([test -n "`grep WARN ovn-controller-vtep.log`"])
433 AT_CHECK([sed -n 's/^.*\(|WARN|.*\)$/\1/p' ovn-controller-vtep.log | sed 's/([[-_:0-9a-z]][[-_:0-9a-z]]*)/()/g' | uniq], [0], [dnl
434 |WARN|MAC address () has already been known to be on logical port () in the same logical datapath, so just ignore this logical port ()
435 ])
436
437 # deletes vif1.
438 AT_CHECK([ovn-nbctl lport-del vif1])
439
440 # adds another lswitch 'br-void' in ovn-nb database.
441 AT_CHECK([ovn-nbctl lswitch-add br-void])
442 # adds fake hv chassis 'ch1' and vif1 with same mac address as vif0.
443 AT_CHECK([ovn-nbctl lport-add br-void vif1])
444 AT_CHECK([ovn-nbctl lport-set-macs vif1 f0:ab:cd:ef:01:02])
445 AT_CHECK([ovn-sbctl chassis-add ch1 vxlan 1.2.3.6])
446 AT_CHECK([ovn-sbctl lport-bind vif1 ch1])
447 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep vif1`"])
448
449 # creates another logical switch in vtep and adds the corresponding logical
450 # port to 'br-void'.
451 AT_CHECK([vtep-ctl add-ls lswitch1 -- bind-ls br-vtep p0 200 lswitch1])
452 OVN_NB_ADD_VTEP_PORT([br-void], [br-void_lswitch1], [br-vtep], [lswitch1])
453 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding  | grep br-void_lswitch1`"])
454
455 # checks Ucast_Macs_Remote creation.  Should see two entries since it is allowed
456 # to have duplicate macs in different logical switches.
457 OVS_WAIT_UNTIL([test `vtep-ctl --columns=MAC list Ucast_Macs_Remote | grep 02 | wc -l` -gt 1])
458 AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' ' | sort], [0], [dnl
459
460 "f0:ab:cd:ef:01:02"
461 "f0:ab:cd:ef:01:02"
462 ])
463
464 OVN_CONTROLLER_VTEP_STOP([/has already been known to be on logical port/d])
465 AT_CLEANUP