1 AT_BANNER([ovn_controller_vtep])
3 # OVN_CONTROLLER_VTEP_START
5 # Starts the test with a setup with vtep device. Each test case must first
8 # Uses vtep-ovs to simulate the vtep switch 'br-vtep' with two physical ports
11 # Configures ovn-nb with a logical switch 'br-test'.
14 m4_define([OVN_CONTROLLER_VTEP_START],
17 # this will cause skip when 'make check' using Windows setup.
18 AT_SKIP_IF([test $HAVE_PYTHON = no])
20 dnl Create databases (ovn-nb, ovn-sb, vtep).
21 AT_CHECK([ovsdb-tool create vswitchd.db $abs_top_srcdir/vswitchd/vswitch.ovsschema])
22 for daemon in ovn-nb ovn-sb vtep; do
23 AT_CHECK([ovsdb-tool create $daemon.db $abs_top_srcdir/${daemon%%-*}/${daemon}.ovsschema])
26 dnl Start ovsdb-server.
27 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile=$OVS_RUNDIR/ovsdb-server.pid --log-file --remote=punix:$OVS_RUNDIR/db.sock vswitchd.db vtep.db], [0], [], [stderr])
28 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile=$OVS_RUNDIR/ovsdb-nb-server.pid --log-file=ovsdb-nb-server.log --remote=punix:$OVS_RUNDIR/ovnnb_db.sock ovn-nb.db], [0], [], [stderr])
29 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile=$OVS_RUNDIR/ovsdb-sb-server.pid --log-file=ovsdb-sb-server.log --remote=punix:$OVS_RUNDIR/ovnsb_db.sock ovn-sb.db ovn-sb.db], [0], [], [stderr])
30 on_exit "kill `cat ovsdb-server.pid` `cat ovsdb-nb-server.pid` `cat ovsdb-sb-server.pid`"
31 AT_CHECK([[sed < stderr '
32 /vlog|INFO|opened log file/d
33 /ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']])
34 AT_CAPTURE_FILE([ovsdb-server.log])
36 dnl Start ovs-vswitchd.
37 AT_CHECK([ovs-vswitchd --enable-dummy=system --disable-system --detach --no-chdir --pidfile --log-file -vvconn -vofproto_dpif], [0], [], [stderr])
38 AT_CAPTURE_FILE([ovs-vswitchd.log])
39 on_exit "kill `cat ovs-vswitchd.pid`"
40 AT_CHECK([[sed < stderr '
41 /ovs_numa|INFO|Discovered /d
42 /vlog|INFO|opened log file/d
43 /vswitchd|INFO|ovs-vswitchd (Open vSwitch)/d
45 /ofproto|INFO|using datapath ID/d
46 /ofproto|INFO|datapath ID changed to fedcba9876543210/d']])
47 AT_CHECK([ovs-vsctl -- add-br br-vtep \
48 -- 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 \
49 -- add-port br-vtep p0 -- set Interface p0 type=dummy ofport_request=1 \
50 -- add-port br-vtep p1 -- set Interface p1 type=dummy ofport_request=2])
53 AT_CHECK([vtep-ctl add-ps br-vtep -- set Physical_Switch br-vtep tunnel_ips=1.2.3.4])
54 AT_CHECK([ovs-vtep --log-file=ovs-vtep.log --pidfile=ovs-vtep.pid --detach br-vtep \], [0], [], [stderr])
55 on_exit "kill `cat ovs-vtep.pid`"
56 AT_CHECK([[sed < stderr '
57 /vlog|INFO|opened log file/d']])
58 # waits until ovs-vtep starts up.
59 OVS_WAIT_UNTIL([test -n "`vtep-ctl show | grep Physical_Port`"])
62 AT_CHECK([ovn-nbctl ls-add br-test])
63 AT_CHECK([ovn-northd --detach --pidfile --log-file], [0], [], [stderr])
64 on_exit "kill `cat ovn-northd.pid`"
65 AT_CHECK([[sed < stderr '
66 /vlog|INFO|opened log file/d']])
67 AT_CAPTURE_FILE([ovn-northd.log])
69 dnl Start ovn-controllger-vtep.
70 AT_CHECK([ovn-controller-vtep --detach --pidfile --log-file --vtep-db=unix:$OVS_RUNDIR/db.sock --ovnsb-db=unix:$OVS_RUNDIR/ovnsb_db.sock], [0], [], [stderr])
71 AT_CAPTURE_FILE([ovn-controller-vtep.log])
72 on_exit "kill `cat ovn-controller-vtep.pid`"
73 AT_CHECK([[sed < stderr '
74 /vlog|INFO|opened log file/d
75 /reconnect|INFO|/d']])
78 # OVN_CONTROLLER_VTEP_STOP
80 # So many exits... Yeah, we started a lot daemons~
82 m4_define([OVN_CONTROLLER_VTEP_STOP],
83 [# removes all 'Broken pipe' warning logs from ovsdb-server.log. this is in
84 # that *ctl command (e.g. ovn-nbctl) exits right after committing the change
85 # to database. however, in reaction, some daemon (e.g. ovn-controller-vtep)
86 # may immediately update the database. this later update may cause database
87 # sending update back to *ctl command if *ctl has not proceeded to exit yet.
88 # and if *ctl command exits before database calling send, the send from
89 # database will fail with 'Broken pipe' error. Also removes all "connection
90 # reset" warning logs by a similar rationale (either EPIPE or ECONNRESET can
91 # be returned on a send depending on whether the peer had unconsumed data when
92 # it closed the socket).
93 AT_CHECK([check_logs "$1
96 OVS_APP_EXIT_AND_WAIT([ovs-vtep])
97 OVS_APP_EXIT_AND_WAIT([ovn-northd])
98 OVS_APP_EXIT_AND_WAIT([ovn-controller-vtep])
99 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
100 OVS_APP_EXIT_AND_WAIT([ovs-vswitchd])])
102 # Adds logical port for a vtep gateway chassis in ovn-nb database.
104 # $1: logical switch name in ovn-nb database
105 # $2: logical port name
106 # $3: physical vtep gateway name
107 # $4: logical switch name on vtep gateway chassis
108 m4_define([OVN_NB_ADD_VTEP_PORT], [
109 AT_CHECK([ovn-nbctl lsp-add $1 $2])
111 AT_CHECK([ovn-nbctl lsp-set-type $2 vtep])
112 AT_CHECK([ovn-nbctl lsp-set-options $2 vtep-physical-switch=$3 vtep-logical-switch=$4])
115 ##############################################
117 # tests chassis related updates.
118 AT_SETUP([ovn-controller-vtep - chassis])
119 OVN_CONTROLLER_VTEP_START
121 # verifies the initial ovn-sb db configuration.
122 OVS_WAIT_UNTIL([test -n "`ovn-sbctl show | grep Chassis`"])
123 AT_CHECK([ovn-sbctl show], [0], [dnl
129 # deletes the chassis via ovn-sbctl and check that it is readded back
131 AT_CHECK([ovn-sbctl chassis-del br-vtep])
132 OVS_WAIT_UNTIL([test -n "`grep WARN ovn-controller-vtep.log`"])
133 AT_CHECK([sed -n 's/^.*\(|WARN|.*\)$/\1/p' ovn-controller-vtep.log], [0], [dnl
134 |WARN|Chassis for VTEP physical switch (br-vtep) disappears, maybe deleted by ovn-sbctl, adding it back
137 # changes the tunnel_ip on physical switch, watches the update of chassis's
139 AT_CHECK([vtep-ctl set Physical_Switch br-vtep tunnel_ips=1.2.3.5])
140 OVS_WAIT_UNTIL([test -n "`ovn-sbctl show | grep 1\.2\.3\.5`"])
141 AT_CHECK([ovn-sbctl --columns=ip list Encap | cut -d ':' -f2 | tr -d ' '], [0], [dnl
145 # adds vlan_bindings to physical ports.
146 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])
147 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Chassis | grep -- lswitch0`"])
148 AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' ' ], [0], [dnl
152 # adds another logical switch and new vlan_bindings.
153 AT_CHECK([vtep-ctl add-ls lswitch1 -- bind-ls br-vtep p0 300 lswitch1])
154 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Chassis | grep -- lswitch1`"])
155 AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' '], [0], [dnl
156 [["lswitch0","lswitch1"]]
159 # unbinds one port from lswitch0, nothing should change.
160 AT_CHECK([vtep-ctl unbind-ls br-vtep p0 200])
161 OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=vlan_bindings list physical_port p0 | grep -- '200='`"])
162 AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' ' ], [0], [dnl
163 [["lswitch0","lswitch1"]]
166 # unbinds all ports from lswitch0.
167 AT_CHECK([vtep-ctl unbind-ls br-vtep p0 100 -- unbind-ls br-vtep p1 300])
168 OVS_WAIT_UNTIL([test -z "`ovn-sbctl list Chassis | grep -- br-vtep_lswitch0`"])
169 AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' ' ], [0], [dnl
173 # unbinds all ports from lswitch1.
174 AT_CHECK([vtep-ctl unbind-ls br-vtep p0 300])
175 OVS_WAIT_UNTIL([test -z "`ovn-sbctl list Chassis | grep -- br-vtep_lswitch1`"])
176 AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' '], [0], [dnl
180 OVN_CONTROLLER_VTEP_STOP([/Chassis for VTEP physical switch (br-vtep) disappears/d])
184 # Tests binding updates.
185 AT_SETUP([ovn-controller-vtep - binding 1])
186 OVN_CONTROLLER_VTEP_START
188 # adds logical switch 'lswitch0' and vlan_bindings.
189 AT_CHECK([vtep-ctl add-ls lswitch0 -- bind-ls br-vtep p0 100 lswitch0 -- bind-ls br-vtep p1 300 lswitch0])
190 # adds logical switch port in ovn-nb database, and sets the type and options.
191 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch0], [br-vtep], [lswitch0])
192 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep br-vtep_lswitch0`"])
193 # should see one binding, associated to chassis of 'br-vtep'.
194 chassis_uuid=$(ovn-sbctl --columns=_uuid list Chassis br-vtep | cut -d ':' -f2 | tr -d ' ')
195 AT_CHECK_UNQUOTED([ovn-sbctl --columns=chassis list Port_Binding br-vtep_lswitch0 | cut -d ':' -f2 | tr -d ' '], [0], [dnl
199 # adds another logical switch 'lswitch1' and vlan_bindings.
200 AT_CHECK([vtep-ctl add-ls lswitch1 -- bind-ls br-vtep p0 200 lswitch1])
201 # adds logical switch port in ovn-nb database for lswitch1.
202 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch1], [br-vtep], [lswitch1])
203 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep -- br-vtep_lswitch1`"])
204 # This is allowed, but not recommended, to have two vlan_bindings (to different vtep logical switches)
205 # from one vtep gateway physical port in one ovn-nb logical swithch.
206 AT_CHECK_UNQUOTED([ovn-sbctl --columns=chassis list Port_Binding | cut -d ':' -f2 | tr -d ' ' | sort], [0], [dnl
212 # adds another logical switch port in ovn-nb database for lswitch0.
213 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch0_dup], [br-vtep], [lswitch0])
214 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep -- br-vtep_lswitch0_dup`"])
215 # it is not allowed to have more than one ovn-nb logical port for the same
216 # vtep logical switch on a vtep gateway chassis, so should still see only
217 # two port_binding entries bound.
218 AT_CHECK_UNQUOTED([ovn-sbctl --columns=chassis list Port_Binding | cut -d ':' -f2 | tr -d ' ' | sort | sort -d], [0], [dnl
225 # confirms the warning log.
226 AT_CHECK([sed -n 's/^.*\(|WARN|.*\)$/\1/p' ovn-controller-vtep.log | sed 's/([[-_0-9a-z]][[-_0-9a-z]]*)/()/g' | uniq], [0], [dnl
227 |WARN|logical switch (), on vtep gateway chassis () has already been associated with logical port (), ignore logical port ()
230 # deletes physical ports from vtep.
231 AT_CHECK([ovs-vsctl del-port p0 -- del-port p1])
232 OVS_WAIT_UNTIL([test -z "`ovn-sbctl list Chassis | grep -- br-vtep_lswitch`"])
233 OVS_WAIT_UNTIL([test -z "`vtep-ctl list physical_port p0`"])
234 OVS_WAIT_UNTIL([test -z "`vtep-ctl list physical_port p1`"])
235 # should see empty chassis column in both binding entries.
236 AT_CHECK_UNQUOTED([ovn-sbctl --columns=chassis list Port_Binding | cut -d ':' -f2 | tr -d ' ' | sort], [0], [dnl
244 OVN_CONTROLLER_VTEP_STOP([/has already been associated with logical port/d])
248 # Tests corner case: Binding the vtep logical switch from two different
250 AT_SETUP([ovn-controller-vtep - binding 2])
251 OVN_CONTROLLER_VTEP_START
253 # adds logical switch 'lswitch0' and vlan_bindings.
254 AT_CHECK([vtep-ctl add-ls lswitch0 -- bind-ls br-vtep p0 100 lswitch0])
255 # adds logical switch port in ovn-nb database, and sets the type and options.
256 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch0], [br-vtep], [lswitch0])
257 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep br-vtep_lswitch0`"])
259 # adds another lswitch 'br-void' in ovn-nb database.
260 AT_CHECK([ovn-nbctl ls-add br-void])
261 # adds another vtep pswitch 'br-vtep-void' in vtep database.
262 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])
263 # adds a conflicting logical port (both br-vtep_lswitch0 and br-vtep-void_lswitch0
264 # are bound to the same logical switch, but they are on different datapath).
265 OVN_NB_ADD_VTEP_PORT([br-void], [br-vtep-void_lswitch0], [br-vtep-void], [lswitch0])
266 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep br-vtep-void_lswitch0`"])
267 OVS_WAIT_UNTIL([test -n "`grep WARN ovn-controller-vtep.log`"])
268 # confirms the warning log.
269 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
270 |WARN|logical switch (), on vtep gateway chassis () has already been associated with logical datapath (), ignore logical port () which belongs to logical datapath ()
273 # then deletes 'br-void' and 'br-vtep-void', should see 'br-vtep_lswitch0'
275 AT_CHECK([ovn-nbctl ls-del br-void])
276 # adds another vtep pswitch 'br-vtep-void' in vtep database.
277 AT_CHECK([vtep-ctl del-ps br-vtep-void])
278 OVS_WAIT_UNTIL([test -z "`ovn-sbctl list Port_Binding | grep br-vtep-void_lswitch0`"])
279 chassis_uuid=$(ovn-sbctl --columns=_uuid list Chassis br-vtep | cut -d ':' -f2 | tr -d ' ')
280 AT_CHECK_UNQUOTED([ovn-sbctl --columns=chassis list Port_Binding br-vtep_lswitch0 | cut -d ':' -f2 | tr -d ' '], [0], [dnl
284 OVN_CONTROLLER_VTEP_STOP([/has already been associated with logical datapath/d])
288 # Tests vtep module vtep logical switch tunnel key update.
289 AT_SETUP([ovn-controller-vtep - vtep-lswitch])
290 OVN_CONTROLLER_VTEP_START
292 # creates the logical switch in vtep and adds the corresponding logical
294 AT_CHECK([vtep-ctl add-ls lswitch0 -- bind-ls br-vtep p0 100 lswitch0])
295 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch0], [br-vtep], [lswitch0])
296 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep -- br-vtep_lswitch0`"])
298 # retrieves the expected tunnel key.
299 datapath_uuid=$(ovn-sbctl --columns=datapath list Port_Binding br-vtep_lswitch0 | cut -d ':' -f2 | tr -d ' ')
300 tunnel_key=$(ovn-sbctl --columns=tunnel_key list Datapath_Binding ${datapath_uuid} | cut -d ':' -f2 | tr -d ' ')
301 OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=tunnel_key list Logical_Switch | grep 0`"])
302 # checks the vtep logical switch tunnel key configuration.
303 AT_CHECK_UNQUOTED([vtep-ctl --columns=tunnel_key list Logical_Switch | cut -d ':' -f2 | tr -d ' '], [0], [dnl
307 # creates a second physical switch in vtep database, and binds its p0 vlan-100
308 # to the same logical switch 'lswitch0'.
309 AT_CHECK([vtep-ctl add-ps br-vtep-void -- add-port br-vtep-void p0 -- bind-ls br-vtep-void p0 100 lswitch0])
310 OVS_WAIT_UNTIL([test -n "`ovn-sbctl --columns=name list Chassis | grep -- br-vtep-void`"])
311 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep-void_lswitch0], [br-vtep-void], [lswitch0])
312 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep -- br-vtep-void_lswitch0`"])
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
319 # now, deletes br-vtep-void.
320 AT_CHECK([vtep-ctl del-ps br-vtep-void])
321 OVS_WAIT_UNTIL([test -z "`ovn-sbctl --columns=name list Chassis | grep -- br-vtep-void`"])
322 # checks the vtep logical switch tunnel key configuration.
323 AT_CHECK_UNQUOTED([vtep-ctl --columns=tunnel_key list Logical_Switch | cut -d ':' -f2 | tr -d ' '], [0], [dnl
327 # changes the ovn-nb logical port type so that it is no longer
329 AT_CHECK([ovn-nbctl lsp-set-type br-vtep_lswitch0 void])
330 OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=tunnel_key list Logical_Switch | grep 1`"])
331 # now should see the tunnel key reset.
332 AT_CHECK([vtep-ctl --columns=tunnel_key list Logical_Switch | cut -d ':' -f2 | tr -d ' '], [0], [dnl
336 OVN_CONTROLLER_VTEP_STOP
340 # Tests vtep module 'Ucast_Macs_Remote's.
341 AT_SETUP([ovn-controller-vtep - vtep-macs 1])
342 OVN_CONTROLLER_VTEP_START
344 # creates a simple logical network with the vtep device and a fake hv chassis
346 AT_CHECK([ovn-nbctl lsp-add br-test vif0])
347 AT_CHECK([ovn-nbctl lsp-set-addresses vif0 f0:ab:cd:ef:01:02])
348 AT_CHECK([ovn-sbctl chassis-add ch0 vxlan 1.2.3.5])
349 AT_CHECK([ovn-sbctl lsp-bind vif0 ch0])
351 # creates the logical switch in vtep and adds the corresponding logical
353 AT_CHECK([vtep-ctl add-ls lswitch0 -- bind-ls br-vtep p0 100 lswitch0])
354 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch0], [br-vtep], [lswitch0])
355 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep br-vtep_lswitch0`"])
357 # adds another lswitch 'br-void' in ovn-nb database.
358 AT_CHECK([ovn-nbctl ls-add br-void])
359 # adds fake hv chassis 'ch1'.
360 AT_CHECK([ovn-nbctl lsp-add br-void vif1])
361 AT_CHECK([ovn-nbctl lsp-set-addresses vif1 f0:ab:cd:ef:01:02])
362 AT_CHECK([ovn-sbctl chassis-add ch1 vxlan 1.2.3.6])
363 AT_CHECK([ovn-sbctl lsp-bind vif1 ch1])
364 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep vif1`"])
366 # checks Ucast_Macs_Remote creation.
367 OVS_WAIT_UNTIL([test -n "`vtep-ctl list Ucast_Macs_Remote | grep _uuid`"])
368 AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' '], [0], [dnl
372 # checks physical locator creation.
373 OVS_WAIT_UNTIL([test -n "`vtep-ctl list Physical_Locator | grep _uuid`"])
374 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
378 # checks tunnel creation by ovs-vtep.
379 OVS_WAIT_UNTIL([test -n "`ovs-vsctl list Interface bfd1.2.3.5`"])
380 AT_CHECK([ovs-vsctl --columns=options list Interface bfd1.2.3.5 | cut -d ':' -f2 | tr -d ' '], [0], [dnl
381 {remote_ip="1.2.3.5"}
384 # adds another mac to logical switch port.
385 AT_CHECK([ovn-nbctl lsp-set-addresses vif0 f0:ab:cd:ef:01:02 f0:ab:cd:ef:01:03])
386 OVS_WAIT_UNTIL([test -n "`vtep-ctl list Ucast_Macs_Remote | grep 03`"])
387 AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' ' | sort], [0], [dnl
393 # removes one mac to logical switch port.
394 AT_CHECK([ovn-nbctl lsp-set-addresses vif0 f0:ab:cd:ef:01:03])
395 OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=MAC list Ucast_Macs_Remote | grep 02`"])
396 AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' ' | sort], [0], [dnl
400 # migrates mac to logical switch port vif1 on 'br-void'.
401 AT_CHECK([ovn-nbctl lsp-set-addresses vif0])
402 AT_CHECK([ovn-nbctl lsp-set-addresses vif1 f0:ab:cd:ef:01:03])
403 OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=MAC list Ucast_Macs_Remote | grep 03`"])
404 AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' ' | sort], [0], [dnl
407 OVN_CONTROLLER_VTEP_STOP
411 # Tests vtep module 'Ucast_Macs_Remote's (corner cases).
412 AT_SETUP([ovn-controller-vtep - vtep-macs 2])
413 OVN_CONTROLLER_VTEP_START
415 # creates a simple logical network with the vtep device and a fake hv chassis
417 AT_CHECK([ovn-nbctl lsp-add br-test vif0])
418 AT_CHECK([ovn-nbctl lsp-set-addresses vif0 f0:ab:cd:ef:01:02])
419 AT_CHECK([ovn-sbctl chassis-add ch0 vxlan 1.2.3.5])
420 AT_CHECK([ovn-sbctl lsp-bind vif0 ch0])
422 # creates another vif in the same logical switch with duplicate mac.
423 AT_CHECK([ovn-nbctl lsp-add br-test vif1])
424 AT_CHECK([ovn-nbctl lsp-set-addresses vif1 f0:ab:cd:ef:01:02])
425 AT_CHECK([ovn-sbctl lsp-bind vif1 ch0])
427 # creates the logical switch in vtep and adds the corresponding logical
429 AT_CHECK([vtep-ctl add-ls lswitch0 -- bind-ls br-vtep p0 100 lswitch0])
430 OVN_NB_ADD_VTEP_PORT([br-test], [br-vtep_lswitch0], [br-vtep], [lswitch0])
431 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep br-vtep_lswitch0`"])
433 # checks Ucast_Macs_Remote creation. Should still only be one entry, since duplicate
434 # mac in the same logical switch is not allowed.
435 OVS_WAIT_UNTIL([test -n "`vtep-ctl list Ucast_Macs_Remote | grep _uuid`"])
436 AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' '], [0], [dnl
439 # confirms the warning log.
440 OVS_WAIT_UNTIL([test -n "`grep WARN ovn-controller-vtep.log`"])
441 AT_CHECK([sed -n 's/^.*\(|WARN|.*\)$/\1/p' ovn-controller-vtep.log | sed 's/([[-_:0-9a-z]][[-_:0-9a-z]]*)/()/g' | uniq], [0], [dnl
442 |WARN|MAC address () has already been known to be on logical port () in the same logical datapath, so just ignore this logical port ()
446 AT_CHECK([ovn-nbctl lsp-del vif1])
448 # adds another lswitch 'br-void' in ovn-nb database.
449 AT_CHECK([ovn-nbctl ls-add br-void])
450 # adds fake hv chassis 'ch1' and vif1 with same mac address as vif0.
451 AT_CHECK([ovn-nbctl lsp-add br-void vif1])
452 AT_CHECK([ovn-nbctl lsp-set-addresses vif1 f0:ab:cd:ef:01:02])
453 AT_CHECK([ovn-sbctl chassis-add ch1 vxlan 1.2.3.6])
454 AT_CHECK([ovn-sbctl lsp-bind vif1 ch1])
455 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep vif1`"])
457 # creates another logical switch in vtep and adds the corresponding logical
459 AT_CHECK([vtep-ctl add-ls lswitch1 -- bind-ls br-vtep p0 200 lswitch1])
460 OVN_NB_ADD_VTEP_PORT([br-void], [br-void_lswitch1], [br-vtep], [lswitch1])
461 OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Port_Binding | grep br-void_lswitch1`"])
463 # checks Ucast_Macs_Remote creation. Should see two entries since it is allowed
464 # to have duplicate macs in different logical switches.
465 OVS_WAIT_UNTIL([test `vtep-ctl --columns=MAC list Ucast_Macs_Remote | grep 02 | wc -l` -gt 1])
466 AT_CHECK([vtep-ctl --columns=MAC list Ucast_Macs_Remote | cut -d ':' -f2- | tr -d ' ' | sort], [0], [dnl
472 OVN_CONTROLLER_VTEP_STOP([/has already been known to be on logical port/d])