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