]> git.proxmox.com Git - mirror_ovs.git/blame - tests/ovn-nbctl.at
odp-execute: Add missing break statement for CLONE action.
[mirror_ovs.git] / tests / ovn-nbctl.at
CommitLineData
f4e38e30
JP
1AT_BANNER([ovn-nbctl])
2
3# OVN_NBCTL_TEST_START
4m4_define([OVN_NBCTL_TEST_START],
6132b241 5 [dnl Create ovn-nb database.
dfef14ee 6 AT_KEYWORDS([ovn])
f4e38e30
JP
7 AT_CHECK([ovsdb-tool create ovn-nb.db $abs_top_srcdir/ovn/ovn-nb.ovsschema])
8
9 dnl Start ovsdb-server.
60bdd011 10 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/ovnnb_db.sock ovn-nb.db], [0], [], [stderr])
53eb8cb8 11 on_exit "kill `cat ovsdb-server.pid`"
fa183acc 12 AT_CHECK([ovn-nbctl init])
f4e38e30
JP
13 AT_CHECK([[sed < stderr '
14/vlog|INFO|opened log file/d
15/ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']])
16 AT_CAPTURE_FILE([ovsdb-server.log])
17])
18
19# OVN_NBCTL_TEST_STOP
20m4_define([OVN_NBCTL_TEST_STOP],
fb496f92
NS
21 [# removes all 'Broken pipe' warning logs from ovsdb-server.log. this is in
22 # that *ctl command (e.g. ovn-nbctl) exits right after committing the change
23 # to database. however, in reaction, some daemon (e.g. ovn-controller-vtep)
24 # may immediately update the database. this later update may cause database
25 # sending update back to *ctl command if *ctl has not proceeded to exit yet.
26 # and if *ctl command exits before database calling send, the send from
247447ff
LR
27 # database will fail with 'Broken pipe' error. Also removes all "connection
28 # reset" warning logs by a similar rationale (either EPIPE or ECONNRESET can
29 # be returned on a send depending on whether the peer had unconsumed data when
30 # it closed the socket).
fb496f92 31 AT_CHECK([check_logs "$1
247447ff 32/reset by peer/d
fb496f92 33/Broken pipe/d"])
d9c8c57c 34 OVS_APP_EXIT_AND_WAIT([ovsdb-server])])
f4e38e30
JP
35
36
ea46a4e9 37AT_SETUP([ovn-nbctl - basic switch commands])
f4e38e30
JP
38OVN_NBCTL_TEST_START
39
ea46a4e9
JP
40AT_CHECK([ovn-nbctl ls-add ls0])
41AT_CHECK([ovn-nbctl ls-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
f4e38e30
JP
42<0> (ls0)
43])
44
ea46a4e9
JP
45AT_CHECK([ovn-nbctl ls-add ls1])
46AT_CHECK([ovn-nbctl ls-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
f4e38e30
JP
47<0> (ls0)
48<1> (ls1)
49])
50
ea46a4e9
JP
51AT_CHECK([ovn-nbctl ls-del ls0])
52AT_CHECK([ovn-nbctl ls-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
f4e38e30
JP
53<0> (ls1)
54])
55
d24d3372 56AT_CHECK([ovn-nbctl show ls0])
ea46a4e9 57AT_CHECK([ovn-nbctl ls-add ls0])
d24d3372 58AT_CHECK([ovn-nbctl show ls0 | ${PERL} $srcdir/uuidfilt.pl], [0],
7a16f569 59 [switch <0> (ls0)
d24d3372 60])
ea46a4e9
JP
61AT_CHECK([ovn-nbctl ls-add ls0], [1], [],
62 [ovn-nbctl: ls0: a switch with this name already exists
4ff6642f 63])
ea46a4e9 64AT_CHECK([ovn-nbctl --may-exist ls-add ls0])
4ff6642f 65AT_CHECK([ovn-nbctl show ls0 | ${PERL} $srcdir/uuidfilt.pl], [0],
7a16f569 66 [switch <0> (ls0)
4ff6642f 67])
ea46a4e9
JP
68AT_CHECK([ovn-nbctl --add-duplicate ls-add ls0])
69AT_CHECK([ovn-nbctl --may-exist --add-duplicate ls-add ls0], [1], [],
4ff6642f
BP
70 [ovn-nbctl: --may-exist and --add-duplicate may not be used together
71])
ea46a4e9 72AT_CHECK([ovn-nbctl ls-del ls0], [1], [],
d24d3372
BP
73 [ovn-nbctl: Multiple logical switches named 'ls0'. Use a UUID.
74])
75
ea46a4e9
JP
76AT_CHECK([ovn-nbctl ls-del ls2], [1], [],
77 [ovn-nbctl: ls2: switch name not found
d24d3372 78])
ea46a4e9 79AT_CHECK([ovn-nbctl --if-exists ls-del ls2])
d24d3372 80
ea46a4e9
JP
81AT_CHECK([ovn-nbctl ls-add])
82AT_CHECK([ovn-nbctl ls-add])
83AT_CHECK([ovn-nbctl --add-duplicate ls-add], [1], [],
4ff6642f
BP
84 [ovn-nbctl: --add-duplicate requires specifying a name
85])
ea46a4e9 86AT_CHECK([ovn-nbctl --may-exist ls-add], [1], [],
4ff6642f
BP
87 [ovn-nbctl: --may-exist requires specifying a name
88])
89
f4e38e30
JP
90OVN_NBCTL_TEST_STOP
91AT_CLEANUP
92
93dnl ---------------------------------------------------------------------
94
31ed1192 95AT_SETUP([ovn-nbctl - basic logical switch port commands])
f4e38e30
JP
96OVN_NBCTL_TEST_START
97
ea46a4e9 98AT_CHECK([ovn-nbctl ls-add ls0])
31ed1192
JP
99AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
100AT_CHECK([ovn-nbctl lsp-add ls0 lp0], [1], [],
101 [ovn-nbctl: lp0: a port with this name already exists
d24d3372 102])
31ed1192
JP
103AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp0])
104AT_CHECK([ovn-nbctl lsp-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
f4e38e30
JP
105<0> (lp0)
106])
107
31ed1192
JP
108AT_CHECK([ovn-nbctl lsp-add ls0 lp1])
109AT_CHECK([ovn-nbctl lsp-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
f4e38e30
JP
110<0> (lp0)
111<1> (lp1)
112])
113
ea46a4e9 114AT_CHECK([ovn-nbctl ls-add ls1])
31ed1192
JP
115AT_CHECK([ovn-nbctl lsp-add ls0 lp1], [1], [],
116 [ovn-nbctl: lp1: a port with this name already exists
d24d3372 117])
31ed1192 118AT_CHECK([ovn-nbctl --may-exist lsp-add ls1 lp1], [1], [],
ea46a4e9 119 [ovn-nbctl: lp1: port already exists but in switch ls0
d24d3372 120])
31ed1192
JP
121AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp1 lp0 5], [1], [],
122 [ovn-nbctl: lp1: port already exists but has no parent
d24d3372
BP
123])
124
31ed1192
JP
125AT_CHECK([ovn-nbctl lsp-del lp1])
126AT_CHECK([ovn-nbctl lsp-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
f4e38e30
JP
127<0> (lp0)
128])
129
31ed1192
JP
130AT_CHECK([ovn-nbctl lsp-add ls0 lp2 lp3 5])
131AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp2 lp4 5], [1], [],
132 [ovn-nbctl: lp2: port already exists with different parent lp3
d24d3372 133])
31ed1192 134AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp2 lp3 10], [1], [],
b511690b 135 [ovn-nbctl: lp2: port already exists with different tag_request 5
d24d3372 136])
b511690b 137AT_CHECK([ovn-nbctl clear Logical_Switch_Port lp2 tag_request])
31ed1192 138AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp2 lp3 5], [1], [],
b511690b 139 [ovn-nbctl: lp2: port already exists but has no tag_request
d24d3372
BP
140])
141
f4e38e30
JP
142OVN_NBCTL_TEST_STOP
143AT_CLEANUP
144
145dnl ---------------------------------------------------------------------
146
7127583d 147AT_SETUP([ovn-nbctl - lport addresses])
f4e38e30
JP
148OVN_NBCTL_TEST_START
149
ea46a4e9 150AT_CHECK([ovn-nbctl ls-add ls0])
31ed1192
JP
151AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
152AT_CHECK([ovn-nbctl lsp-get-addresses lp0], [0], [dnl
f4e38e30
JP
153])
154
31ed1192
JP
155AT_CHECK([ovn-nbctl lsp-set-addresses lp0 00:11:22:33:44:55 unknown])
156AT_CHECK([ovn-nbctl lsp-get-addresses lp0], [0], [dnl
f4e38e30
JP
15700:11:22:33:44:55
158unknown
159])
160
31ed1192
JP
161AT_CHECK([ovn-nbctl lsp-set-addresses lp0])
162AT_CHECK([ovn-nbctl lsp-get-addresses lp0], [0], [dnl
f4e38e30
JP
163])
164
165OVN_NBCTL_TEST_STOP
166AT_CLEANUP
167
168dnl ---------------------------------------------------------------------
169
170AT_SETUP([ovn-nbctl - port security])
171OVN_NBCTL_TEST_START
172
ea46a4e9 173AT_CHECK([ovn-nbctl ls-add ls0])
31ed1192
JP
174AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
175AT_CHECK([ovn-nbctl lsp-get-addresses lp0], [0], [dnl
f4e38e30
JP
176])
177
31ed1192
JP
178AT_CHECK([ovn-nbctl lsp-set-port-security lp0 aa:bb:cc:dd:ee:ff 00:11:22:33:44:55])
179AT_CHECK([ovn-nbctl lsp-get-port-security lp0], [0], [dnl
f4e38e30
JP
18000:11:22:33:44:55
181aa:bb:cc:dd:ee:ff
182])
183
31ed1192
JP
184AT_CHECK([ovn-nbctl lsp-set-port-security lp0])
185AT_CHECK([ovn-nbctl lsp-get-port-security lp0], [0], [dnl
f4e38e30
JP
186])
187
188OVN_NBCTL_TEST_STOP
189AT_CLEANUP
8f96455d
JP
190
191dnl ---------------------------------------------------------------------
192
193AT_SETUP([ovn-nbctl - ACLs])
194OVN_NBCTL_TEST_START
195
ea46a4e9 196AT_CHECK([ovn-nbctl ls-add ls0])
70799ae8 197AT_CHECK([ovn-nbctl --log acl-add ls0 from-lport 600 udp drop])
d383eed5 198AT_CHECK([ovn-nbctl --log --name=test --severity=info acl-add ls0 to-lport 500 udp drop])
8f96455d
JP
199AT_CHECK([ovn-nbctl acl-add ls0 from-lport 400 tcp drop])
200AT_CHECK([ovn-nbctl acl-add ls0 to-lport 300 tcp drop])
201AT_CHECK([ovn-nbctl acl-add ls0 from-lport 200 ip drop])
202AT_CHECK([ovn-nbctl acl-add ls0 to-lport 100 ip drop])
fa3cc9b9
HZ
203dnl Add duplicated ACL
204AT_CHECK([ovn-nbctl acl-add ls0 to-lport 100 ip drop], [1], [], [stderr])
205AT_CHECK([grep 'already existed' stderr], [0], [ignore])
206AT_CHECK([ovn-nbctl --may-exist acl-add ls0 to-lport 100 ip drop])
8f96455d
JP
207
208AT_CHECK([ovn-nbctl acl-list ls0], [0], [dnl
d383eed5 209from-lport 600 (udp) drop log()
8f96455d
JP
210from-lport 400 (tcp) drop
211from-lport 200 (ip) drop
d383eed5 212 to-lport 500 (udp) drop log(name=test,severity=info)
8f96455d
JP
213 to-lport 300 (tcp) drop
214 to-lport 100 (ip) drop
215])
216
217dnl Delete in one direction.
218AT_CHECK([ovn-nbctl acl-del ls0 to-lport])
219AT_CHECK([ovn-nbctl acl-list ls0], [0], [dnl
d383eed5 220from-lport 600 (udp) drop log()
8f96455d
JP
221from-lport 400 (tcp) drop
222from-lport 200 (ip) drop
223])
224
225dnl Delete all ACLs.
226AT_CHECK([ovn-nbctl acl-del ls0])
227AT_CHECK([ovn-nbctl acl-list ls0], [0], [dnl
228])
229
230AT_CHECK([ovn-nbctl acl-add ls0 from-lport 600 udp drop])
231AT_CHECK([ovn-nbctl acl-add ls0 from-lport 400 tcp drop])
232AT_CHECK([ovn-nbctl acl-add ls0 from-lport 200 ip drop])
233
234dnl Delete a single flow.
235AT_CHECK([ovn-nbctl acl-del ls0 from-lport 400 tcp])
236AT_CHECK([ovn-nbctl acl-list ls0], [0], [dnl
237from-lport 600 (udp) drop
238from-lport 200 (ip) drop
239])
240
241OVN_NBCTL_TEST_STOP
e2bfcad6 242AT_CLEANUP
243
3722730e 244dnl ---------------------------------------------------------------------
245AT_SETUP([ovn-nbctl - NATs])
246OVN_NBCTL_TEST_START
247AT_CHECK([ovn-nbctl lr-add lr0])
248AT_CHECK([ovn-nbctl lr-nat-add lr0 snatt 30.0.0.2 192.168.1.2], [1], [],
249[ovn-nbctl: snatt: type must be one of "dnat", "snat" and "dnat_and_snat".
250])
251AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2a 192.168.1.2], [1], [],
252[ovn-nbctl: 30.0.0.2a: should be an IPv4 address.
253])
254AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0 192.168.1.2], [1], [],
255[ovn-nbctl: 30.0.0: should be an IPv4 address.
256])
257AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2/24 192.168.1.2], [1], [],
258[ovn-nbctl: 30.0.0.2/24: should be an IPv4 address.
259])
260AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2:80 192.168.1.2], [1], [],
261[ovn-nbctl: 30.0.0.2:80: should be an IPv4 address.
262])
263AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2 192.168.1.2a], [1], [],
264[ovn-nbctl: 192.168.1.2a: should be an IPv4 address or network.
265])
266AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2 192.168.1], [1], [],
267[ovn-nbctl: 192.168.1: should be an IPv4 address or network.
268])
269AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2 192.168.1.2:80], [1], [],
270[ovn-nbctl: 192.168.1.2:80: should be an IPv4 address or network.
271])
272AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2 192.168.1.2/a], [1], [],
273[ovn-nbctl: 192.168.1.2/a: should be an IPv4 address or network.
274])
275AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.2 192.168.1.2a], [1], [],
276[ovn-nbctl: 192.168.1.2a: should be an IPv4 address.
277])
278AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.2 192.168.1], [1], [],
279[ovn-nbctl: 192.168.1: should be an IPv4 address.
280])
281AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.2 192.168.1.2:80], [1], [],
282[ovn-nbctl: 192.168.1.2:80: should be an IPv4 address.
283])
284AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.2 192.168.1.2/24], [1], [],
285[ovn-nbctl: 192.168.1.2/24: should be an IPv4 address.
286])
287AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.2 192.168.1.2/24], [1], [],
288[ovn-nbctl: 192.168.1.2/24: should be an IPv4 address.
289])
6a725785
MS
290AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.2 192.168.1.2 lp0], [1], [],
291[ovn-nbctl: lr-nat-add with logical_port must also specify external_mac.
292])
293AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.2 192.168.1.2 lp0 00:00:00:01:02:03], [1], [],
294[ovn-nbctl: logical_port and external_mac are only valid when type is "dnat_and_snat".
295])
296AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2 192.168.1.2 lp0 00:00:00:01:02:03], [1], [],
297[ovn-nbctl: logical_port and external_mac are only valid when type is "dnat_and_snat".
298])
299AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.2 192.168.1.2 lp0 00:00:00:01:02:03], [1], [],
300[ovn-nbctl: lp0: port name not found
301])
302AT_CHECK([ovn-nbctl ls-add ls0])
303AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
304AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.2 192.168.1.2 lp0 00:00:00:01:02], [1], [],
305[ovn-nbctl: invalid mac address 00:00:00:01:02.
306])
3722730e 307
308dnl Add snat and dnat
309AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.1 192.168.1.0/24])
310AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.1 192.168.1.2])
311AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.1 192.168.1.2])
6a725785 312AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.2 192.168.1.3 lp0 00:00:00:01:02:03])
3722730e 313AT_CHECK([ovn-nbctl lr-nat-list lr0], [0], [dnl
6a725785 314TYPE EXTERNAL_IP LOGICAL_IP EXTERNAL_MAC LOGICAL_PORT
3722730e 315dnat 30.0.0.1 192.168.1.2
316dnat_and_snat 30.0.0.1 192.168.1.2
6a725785 317dnat_and_snat 30.0.0.2 192.168.1.3 00:00:00:01:02:03 lp0
3722730e 318snat 30.0.0.1 192.168.1.0/24
319])
320AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.1 192.168.1.0/24], [1], [],
321[ovn-nbctl: 30.0.0.1, 192.168.1.0/24: a NAT with this external_ip and logical_ip already exists
322])
323AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.1 192.168.1.10/24], [1], [],
324[ovn-nbctl: 30.0.0.1, 192.168.1.0/24: a NAT with this external_ip and logical_ip already exists
325])
326AT_CHECK([ovn-nbctl --may-exist lr-nat-add lr0 snat 30.0.0.1 192.168.1.0/24])
327AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2 192.168.1.0/24], [1], [],
328[ovn-nbctl: a NAT with this type (snat) and logical_ip (192.168.1.0/24) already exists
329])
330AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.1 192.168.1.2], [1], [],
331[ovn-nbctl: 30.0.0.1, 192.168.1.2: a NAT with this external_ip and logical_ip already exists
332])
333AT_CHECK([ovn-nbctl --may-exist lr-nat-add lr0 dnat 30.0.0.1 192.168.1.2])
334AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.1 192.168.1.3], [1], [],
335[ovn-nbctl: a NAT with this type (dnat) and external_ip (30.0.0.1) already exists
336])
337AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.1 192.168.1.2], [1], [],
338[ovn-nbctl: 30.0.0.1, 192.168.1.2: a NAT with this external_ip and logical_ip already exists
339])
340AT_CHECK([ovn-nbctl --may-exist lr-nat-add lr0 dnat_and_snat 30.0.0.1 192.168.1.2])
341AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.1 192.168.1.3], [1], [],
342[ovn-nbctl: a NAT with this type (dnat_and_snat) and external_ip (30.0.0.1) already exists
343])
6a725785
MS
344AT_CHECK([ovn-nbctl --may-exist lr-nat-add lr0 dnat_and_snat 30.0.0.2 192.168.1.3 lp0 00:00:00:04:05:06])
345AT_CHECK([ovn-nbctl lr-nat-list lr0], [0], [dnl
346TYPE EXTERNAL_IP LOGICAL_IP EXTERNAL_MAC LOGICAL_PORT
347dnat 30.0.0.1 192.168.1.2
348dnat_and_snat 30.0.0.1 192.168.1.2
349dnat_and_snat 30.0.0.2 192.168.1.3 00:00:00:04:05:06 lp0
350snat 30.0.0.1 192.168.1.0/24
351])
352AT_CHECK([ovn-nbctl --may-exist lr-nat-add lr0 dnat_and_snat 30.0.0.2 192.168.1.3])
353AT_CHECK([ovn-nbctl lr-nat-list lr0], [0], [dnl
354TYPE EXTERNAL_IP LOGICAL_IP EXTERNAL_MAC LOGICAL_PORT
355dnat 30.0.0.1 192.168.1.2
356dnat_and_snat 30.0.0.1 192.168.1.2
357dnat_and_snat 30.0.0.2 192.168.1.3
358snat 30.0.0.1 192.168.1.0/24
359])
3722730e 360
361dnl Deletes the NATs
6a725785
MS
362AT_CHECK([ovn-nbctl lr-nat-del lr0 dnat_and_snat 30.0.0.3], [1], [],
363[ovn-nbctl: no matching NAT with the type (dnat_and_snat) and external_ip (30.0.0.3)
3722730e 364])
365AT_CHECK([ovn-nbctl lr-nat-del lr0 dnat 30.0.0.2], [1], [],
366[ovn-nbctl: no matching NAT with the type (dnat) and external_ip (30.0.0.2)
367])
368AT_CHECK([ovn-nbctl lr-nat-del lr0 snat 192.168.10.0/24], [1], [],
369[ovn-nbctl: no matching NAT with the type (snat) and logical_ip (192.168.10.0/24)
370])
371AT_CHECK([ovn-nbctl --if-exists lr-nat-del lr0 snat 192.168.10.0/24])
372
373AT_CHECK([ovn-nbctl lr-nat-del lr0 dnat_and_snat 30.0.0.1])
374AT_CHECK([ovn-nbctl lr-nat-list lr0], [0], [dnl
6a725785 375TYPE EXTERNAL_IP LOGICAL_IP EXTERNAL_MAC LOGICAL_PORT
3722730e 376dnat 30.0.0.1 192.168.1.2
6a725785 377dnat_and_snat 30.0.0.2 192.168.1.3
3722730e 378snat 30.0.0.1 192.168.1.0/24
379])
380
381AT_CHECK([ovn-nbctl lr-nat-del lr0 dnat])
382AT_CHECK([ovn-nbctl lr-nat-list lr0], [0], [dnl
6a725785
MS
383TYPE EXTERNAL_IP LOGICAL_IP EXTERNAL_MAC LOGICAL_PORT
384dnat_and_snat 30.0.0.2 192.168.1.3
3722730e 385snat 30.0.0.1 192.168.1.0/24
386])
387
388AT_CHECK([ovn-nbctl lr-nat-del lr0])
389AT_CHECK([ovn-nbctl lr-nat-list lr0], [0], [])
390AT_CHECK([ovn-nbctl lr-nat-del lr0])
391AT_CHECK([ovn-nbctl lr-nat-del lr0 dnat])
392OVN_NBCTL_TEST_STOP
393AT_CLEANUP
394
e2bfcad6 395dnl ---------------------------------------------------------------------
396
397AT_SETUP([ovn-nbctl - LBs])
398OVN_NBCTL_TEST_START
399
400dnl Add two LBs.
401AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10:80a 192.168.10.10:80,192.168.10.20:80 tcp], [1], [],
c19105a0 402[ovn-nbctl: 30.0.0.10:80a: should be an IP address (or an IP address and a port number with : as a separator).
e2bfcad6 403])
404
405AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10:a80 192.168.10.10:80,192.168.10.20:80 tcp], [1], [],
c19105a0 406[ovn-nbctl: 30.0.0.10:a80: should be an IP address (or an IP address and a port number with : as a separator).
e2bfcad6 407])
408
409AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10: 192.168.10.10:80,192.168.10.20:80 tcp], [1], [],
c19105a0 410[ovn-nbctl: 30.0.0.10:: should be an IP address (or an IP address and a port number with : as a separator).
e2bfcad6 411])
412
413AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10:80 192.168.10.10:80,192.168.10.20 tcp], [1], [],
c19105a0 414[ovn-nbctl: 192.168.10.20: should be an IP address and a port number with : as a separator.
e2bfcad6 415])
416
417AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.1a 192.168.10.10:80,192.168.10.20:80], [1], [],
c19105a0 418[ovn-nbctl: 30.0.0.1a: should be an IP address (or an IP address and a port number with : as a separator).
e2bfcad6 419])
420
421AT_CHECK([ovn-nbctl lb-add lb0 30.0.0 192.168.10.10:80,192.168.10.20:80], [1], [],
c19105a0 422[ovn-nbctl: 192.168.10.10:80: should be an IP address.
e2bfcad6 423])
424
425AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10 192.168.10.10,192.168.10.20:80], [1], [],
c19105a0 426[ovn-nbctl: 192.168.10.20:80: should be an IP address.
e2bfcad6 427])
428
429AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10 192.168.10.10:a80], [1], [],
c19105a0 430[ovn-nbctl: 192.168.10.10:a80: should be an IP address.
e2bfcad6 431])
432
433AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10 192.168.10.10:], [1], [],
c19105a0 434[ovn-nbctl: 192.168.10.10:: should be an IP address.
e2bfcad6 435])
436
437AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10 192.168.10.1a], [1], [],
c19105a0 438[ovn-nbctl: 192.168.10.1a: should be an IP address.
e2bfcad6 439])
440
441AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10 192.168.10.10 tcp], [1], [],
442[ovn-nbctl: Protocol is unnecessary when no port of vip is given.
443])
444
445AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10 192.168.10.10:900 tcp], [1], [],
446[ovn-nbctl: Protocol is unnecessary when no port of vip is given.
447])
448
449dnl Add ips to lb
450AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10:80 ,,,192.168.10.10:80,,,,,])
451AT_CHECK([ovn-nbctl lb-add lb1 30.0.0.10:80 ,,,192.168.10.10:80,,,,192.168.10.20:80,,,,])
452AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
c19105a0
MM
453UUID LB PROTO VIP IPs
454<0> lb0 tcp 30.0.0.10:80 192.168.10.10:80
455<1> lb1 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
e2bfcad6 456])
457AT_CHECK([ovn-nbctl lb-del lb0])
458AT_CHECK([ovn-nbctl lb-del lb1])
459
460AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80])
461AT_CHECK([ovn-nbctl lb-add lb1 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 tcp])
462AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
c19105a0
MM
463UUID LB PROTO VIP IPs
464<0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
465<1> lb1 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
e2bfcad6 466])
467
468dnl Update the VIP of the lb1.
469AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080])
470AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
c19105a0
MM
471UUID LB PROTO VIP IPs
472<0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
473<1> lb1 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080
e2bfcad6 474])
475
476AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080 udp])
477AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
c19105a0
MM
478UUID LB PROTO VIP IPs
479<0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
480<1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080
e2bfcad6 481])
482
483dnl Config lb1 with another VIP.
484AT_CHECK([ovn-nbctl lb-add lb1 30.0.0.20:80 192.168.10.10:80 udp])
485AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
c19105a0
MM
486UUID LB PROTO VIP IPs
487<0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
488<1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080
489 udp 30.0.0.20:80 192.168.10.10:80
e2bfcad6 490])
491
492AT_CHECK([ovn-nbctl lb-del lb1 30.0.0.20:80])
493AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
c19105a0
MM
494UUID LB PROTO VIP IPs
495<0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
496<1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080
e2bfcad6 497])
498
499dnl Add LBs whose vip is just an IP address.
500AT_CHECK([ovn-nbctl lb-add lb2 30.0.0.30 192.168.10.10])
501AT_CHECK([ovn-nbctl lb-add lb3 30.0.0.30 192.168.10.10])
502AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
c19105a0
MM
503UUID LB PROTO VIP IPs
504<0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
505<1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080
506<2> lb2 tcp/udp 30.0.0.30 192.168.10.10
507<3> lb3 tcp/udp 30.0.0.30 192.168.10.10
e2bfcad6 508])
509AT_CHECK([ovn-nbctl lb-del lb2 30.0.0.30])
510AT_CHECK([ovn-nbctl lb-del lb3 30.0.0.30])
511
512AT_CHECK([ovn-nbctl lb-add lb2 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80 tcp])
513AT_CHECK([ovn-nbctl --add-duplicate lb-add lb2 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80 tcp])
514AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
c19105a0
MM
515UUID LB PROTO VIP IPs
516<0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
517<1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080
518<2> lb2 tcp 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80
519<3> lb2 tcp 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80
e2bfcad6 520])
521
522dnl If there are multiple load balancers with the same name, use a UUID to update/delete.
523AT_CHECK([ovn-nbctl lb-add lb2 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80 tcp], [1], [],
524[ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
525])
526
527AT_CHECK([ovn-nbctl lb-del lb2], [1], [],
528[ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
529])
530
531AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:80 192.168.10.10:8080,192.168.10.20:8080 udp])
532AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:8080 192.168.10.10:8080,192.168.10.20:8080 udp])
533AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:9090 192.168.10.10:8080,192.168.10.20:8080 udp])
534AT_CHECK([ovn-nbctl lb-del lb0 30.0.0.10:80])
535AT_CHECK([ovn-nbctl lb-del lb1])
536AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
c19105a0
MM
537UUID LB PROTO VIP IPs
538<0> lb2 tcp 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80
539<1> lb2 tcp 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80
e2bfcad6 540])
541
542dnl Add load balancer to logical switch.
543AT_CHECK([ovn-nbctl ls-add ls0])
544AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80])
545AT_CHECK([ovn-nbctl lb-add lb1 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 udp])
546AT_CHECK([ovn-nbctl lb-add lb3 30.0.0.10 192.168.10.10,192.168.10.20])
547AT_CHECK([ovn-nbctl ls-lb-add ls0 lb0])
548AT_CHECK([ovn-nbctl ls-lb-add ls0 lb1])
549AT_CHECK([ovn-nbctl --may-exist ls-lb-add ls0 lb1])
550AT_CHECK([ovn-nbctl ls-lb-add ls0 lb2], [1], [],
551[ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
552])
553AT_CHECK([ovn-nbctl ls-lb-add ls0 lb3])
554
555AT_CHECK([ovn-nbctl ls-lb-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
c19105a0
MM
556UUID LB PROTO VIP IPs
557<0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
558<1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
559<2> lb3 tcp/udp 30.0.0.10 192.168.10.10,192.168.10.20
e2bfcad6 560])
561
562AT_CHECK([ovn-nbctl ls-lb-del ls0 lb0])
563AT_CHECK([ovn-nbctl ls-lb-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
c19105a0
MM
564UUID LB PROTO VIP IPs
565<0> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
566<1> lb3 tcp/udp 30.0.0.10 192.168.10.10,192.168.10.20
e2bfcad6 567])
568
569AT_CHECK([ovn-nbctl ls-lb-del ls0 lb1])
570AT_CHECK([ovn-nbctl ls-lb-del ls0 lb3])
571AT_CHECK([ovn-nbctl ls-lb-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [])
572AT_CHECK([ovn-nbctl --if-exists ls-lb-del ls0 lb1])
573
574dnl Remove all load balancers from logical switch.
575AT_CHECK([ovn-nbctl ls-lb-add ls0 lb0])
576AT_CHECK([ovn-nbctl ls-lb-add ls0 lb1])
577AT_CHECK([ovn-nbctl ls-lb-add ls0 lb3])
578AT_CHECK([ovn-nbctl ls-lb-del ls0])
579AT_CHECK([ovn-nbctl ls-lb-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [])
580
581dnl Add load balancer to logical router.
582AT_CHECK([ovn-nbctl lr-add lr0])
583AT_CHECK([ovn-nbctl lr-lb-add lr0 lb0])
584AT_CHECK([ovn-nbctl lr-lb-add lr0 lb1])
585AT_CHECK([ovn-nbctl --may-exist lr-lb-add lr0 lb1])
586AT_CHECK([ovn-nbctl lr-lb-add lr0 lb2], [1], [],
587[ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
588])
589AT_CHECK([ovn-nbctl lr-lb-add lr0 lb3])
590
591AT_CHECK([ovn-nbctl lr-lb-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
c19105a0
MM
592UUID LB PROTO VIP IPs
593<0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
594<1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
595<2> lb3 tcp/udp 30.0.0.10 192.168.10.10,192.168.10.20
e2bfcad6 596])
597
598AT_CHECK([ovn-nbctl lr-lb-del lr0 lb0])
599AT_CHECK([ovn-nbctl lr-lb-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
c19105a0
MM
600UUID LB PROTO VIP IPs
601<0> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
602<1> lb3 tcp/udp 30.0.0.10 192.168.10.10,192.168.10.20
e2bfcad6 603])
604
605AT_CHECK([ovn-nbctl lr-lb-del lr0 lb1])
606AT_CHECK([ovn-nbctl lr-lb-del lr0 lb3])
607AT_CHECK([ovn-nbctl lr-lb-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [])
608AT_CHECK([ovn-nbctl --if-exists lr-lb-del lr0 lb1])
609
610dnl Remove all load balancers from logical router.
611AT_CHECK([ovn-nbctl lr-lb-add lr0 lb0])
612AT_CHECK([ovn-nbctl lr-lb-add lr0 lb1])
613AT_CHECK([ovn-nbctl lr-lb-add lr0 lb3])
614AT_CHECK([ovn-nbctl lr-lb-del lr0])
615AT_CHECK([ovn-nbctl lr-lb-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [])
616
617OVN_NBCTL_TEST_STOP
8f96455d 618AT_CLEANUP
c19105a0
MM
619dnl
620dnl ---------------------------------------------------------------------
621
622AT_SETUP([ovn-nbctl - LBs IPv6])
623OVN_NBCTL_TEST_START
624
625dnl A bunch of commands that should fail
626AT_CHECK([ovn-nbctl lb-add lb0 [[ae0f::10]]:80a [[fd0f::10]]:80,[[fd0f::20]]:80 tcp], [1], [],
627[ovn-nbctl: [[ae0f::10]]:80a: should be an IP address (or an IP address and a port number with : as a separator).
628])
629
630
631AT_CHECK([ovn-nbctl lb-add lb0 [[ae0f::10]]:a80 [[fd0f::10]]:80,[[fd0f::20]]:80 tcp], [1], [],
632[ovn-nbctl: [[ae0f::10]]:a80: should be an IP address (or an IP address and a port number with : as a separator).
633])
634
635
636AT_CHECK([ovn-nbctl lb-add lb0 [[ae0f::10]]: [[fd0f::10]]:80,[[fd0f::20]]:80 tcp], [1], [],
637[ovn-nbctl: [[ae0f::10]]:: should be an IP address (or an IP address and a port number with : as a separator).
638])
639
640
641AT_CHECK([ovn-nbctl lb-add lb0 [[ae0f::10]]:80 [[fd0f::10]]:80,fd0f::20 tcp], [1], [],
642[ovn-nbctl: fd0f::20: should be an IP address and a port number with : as a separator.
643])
644
645
646AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10fff [[fd0f::10]]:80,fd0f::20 tcp], [1], [],
647[ovn-nbctl: ae0f::10fff: should be an IP address (or an IP address and a port number with : as a separator).
648])
649
650
651AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 [[fd0f::10]]:80,[[fd0f::20]]:80], [1], [],
652[ovn-nbctl: [[fd0f::10]]:80: should be an IP address.
653])
654
655
656AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 fd0f::10,[[fd0f::20]]:80], [1], [],
657[ovn-nbctl: [[fd0f::20]]:80: should be an IP address.
658])
659
660
661AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 [[fd0f::10]]:a80], [1], [],
662[ovn-nbctl: [[fd0f::10]]:a80: should be an IP address.
663])
664
665
666AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 [[fd0f::10]]:], [1], [],
667[ovn-nbctl: [[fd0f::10]]:: should be an IP address.
668])
669
670
671AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 fd0f::1001a], [1], [],
672[ovn-nbctl: fd0f::1001a: should be an IP address.
673])
674
675
676AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 fd0f::10 tcp], [1], [],
677[ovn-nbctl: Protocol is unnecessary when no port of vip is given.
678])
679
680
681AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 [[fd0f::10]]:900 tcp], [1], [],
682[ovn-nbctl: Protocol is unnecessary when no port of vip is given.
683])
684
685AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 192.168.10.10], [1], [],
686[ovn-nbctl: 192.168.10.10: IP address family is different from VIP ae0f::10.
687])
688
689AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 192.168.10.10], [1], [],
690[ovn-nbctl: 192.168.10.10: IP address family is different from VIP ae0f::10.
691])
692
693AT_CHECK([ovn-nbctl lb-add lb0 [[ae0f::10]]:80 192.168.10.10:80], [1], [],
694[ovn-nbctl: 192.168.10.10:80: IP address family is different from VIP [[ae0f::10]]:80.
695])
696
697AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10 ae0f::10], [1], [],
698[ovn-nbctl: ae0f::10: IP address family is different from VIP 30.0.0.10.
699])
700
701AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10:80 [[ae0f::10]]:80], [1], [],
702[ovn-nbctl: [[ae0f::10]]:80: IP address family is different from VIP 30.0.0.10:80.
703])
704
705AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 fd0f::10])
706AT_CHECK([ovn-nbctl lb-add lb0 ae0f:0000:0000:0000:0000:0000:0000:0010 fd0f::20],
707[1], [], [ovn-nbctl: lb0: a load balancer with this vip (ae0f::10) already exists
708])
709
710AT_CHECK([ovn-nbctl lb-del lb0])
711
712dnl Add ips to lb
713AT_CHECK([ovn-nbctl lb-add lb0 [[ae0f::10]]:80 ,,,[[fd0f::10]]:80,,,,,])
714AT_CHECK([ovn-nbctl lb-add lb1 [[ae0f::10]]:80 ,,,[[fd0f::10]]:80,,,,[[fd0f::20]]:80,,,,])
715AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
716UUID LB PROTO VIP IPs
717<0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80
718<1> lb1 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
719])
720AT_CHECK([ovn-nbctl lb-del lb0])
721AT_CHECK([ovn-nbctl lb-del lb1])
722
723
724AT_CHECK([ovn-nbctl lb-add lb0 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80])
725AT_CHECK([ovn-nbctl lb-add lb1 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 tcp])
726AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
727UUID LB PROTO VIP IPs
728<0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
729<1> lb1 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
730])
731
732dnl Update the VIP of the lb1.
733AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080])
734AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
735UUID LB PROTO VIP IPs
736<0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
737<1> lb1 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080
738])
739
740AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080 udp])
741AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
742UUID LB PROTO VIP IPs
743<0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
744<1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080
745])
746
747dnl Config lb1 with another VIP.
748AT_CHECK([ovn-nbctl lb-add lb1 [[ae0f::20]]:80 [[fd0f::10]]:80 udp])
749AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
750UUID LB PROTO VIP IPs
751<0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
752<1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080
753 udp [[ae0f::20]]:80 [[fd0f::10]]:80
754])
755
756AT_CHECK([ovn-nbctl lb-del lb1 [[ae0f::20]]:80])
757AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
758UUID LB PROTO VIP IPs
759<0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
760<1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080
761])
7127583d 762
c19105a0
MM
763dnl Add LBs whose vip is just an IP address.
764AT_CHECK([ovn-nbctl lb-add lb2 ae0f::30 fd0f::10])
765AT_CHECK([ovn-nbctl lb-add lb3 ae0f::30 fd0f::10])
766AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
767UUID LB PROTO VIP IPs
768<0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
769<1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080
770<2> lb2 tcp/udp ae0f::30 fd0f::10
771<3> lb3 tcp/udp ae0f::30 fd0f::10
772])
773AT_CHECK([ovn-nbctl lb-del lb2 ae0f::30])
774AT_CHECK([ovn-nbctl lb-del lb3 ae0f::30])
775
776AT_CHECK([ovn-nbctl lb-add lb2 [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80 tcp])
777AT_CHECK([ovn-nbctl --add-duplicate lb-add lb2 [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80 tcp])
778AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
779UUID LB PROTO VIP IPs
780<0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
781<1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080
782<2> lb2 tcp [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80
783<3> lb2 tcp [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80
784])
785
786dnl If there are multiple load balancers with the same name, use a UUID to update/delete.
787AT_CHECK([ovn-nbctl lb-add lb2 [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80 tcp], [1], [],
788[ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
789])
790
791AT_CHECK([ovn-nbctl lb-del lb2], [1], [],
792[ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
793])
794
795AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:80 [[fd0f::10]]:8080,[[fd0f::20]]:8080 udp])
796AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:8080 [[fd0f::10]]:8080,[[fd0f::20]]:8080 udp])
797AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:9090 [[fd0f::10]]:8080,[[fd0f::20]]:8080 udp])
798AT_CHECK([ovn-nbctl lb-del lb0 [[ae0f::10]]:80])
799AT_CHECK([ovn-nbctl lb-del lb1])
800AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
801UUID LB PROTO VIP IPs
802<0> lb2 tcp [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80
803<1> lb2 tcp [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80
804])
805
806dnl Add load balancer to logical switch.
807AT_CHECK([ovn-nbctl ls-add ls0])
808AT_CHECK([ovn-nbctl lb-add lb0 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80])
809AT_CHECK([ovn-nbctl lb-add lb1 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 udp])
810AT_CHECK([ovn-nbctl lb-add lb3 ae0f::10 fd0f::10,fd0f::20])
811AT_CHECK([ovn-nbctl ls-lb-add ls0 lb0])
812AT_CHECK([ovn-nbctl ls-lb-add ls0 lb1])
813AT_CHECK([ovn-nbctl --may-exist ls-lb-add ls0 lb1])
814AT_CHECK([ovn-nbctl ls-lb-add ls0 lb2], [1], [],
815[ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
816])
817AT_CHECK([ovn-nbctl ls-lb-add ls0 lb3])
818
819AT_CHECK([ovn-nbctl ls-lb-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
820UUID LB PROTO VIP IPs
821<0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
822<1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
823<2> lb3 tcp/udp ae0f::10 fd0f::10,fd0f::20
824])
825
826AT_CHECK([ovn-nbctl ls-lb-del ls0 lb0])
827AT_CHECK([ovn-nbctl ls-lb-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
828UUID LB PROTO VIP IPs
829<0> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
830<1> lb3 tcp/udp ae0f::10 fd0f::10,fd0f::20
831])
832
833AT_CHECK([ovn-nbctl ls-lb-del ls0 lb1])
834AT_CHECK([ovn-nbctl ls-lb-del ls0 lb3])
835AT_CHECK([ovn-nbctl ls-lb-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [])
836AT_CHECK([ovn-nbctl --if-exists ls-lb-del ls0 lb1])
837
838dnl Remove all load balancers from logical switch.
839AT_CHECK([ovn-nbctl ls-lb-add ls0 lb0])
840AT_CHECK([ovn-nbctl ls-lb-add ls0 lb1])
841AT_CHECK([ovn-nbctl ls-lb-add ls0 lb3])
842AT_CHECK([ovn-nbctl ls-lb-del ls0])
843AT_CHECK([ovn-nbctl ls-lb-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [])
844
845dnl Add load balancer to logical router.
846AT_CHECK([ovn-nbctl lr-add lr0])
847AT_CHECK([ovn-nbctl lr-lb-add lr0 lb0])
848AT_CHECK([ovn-nbctl lr-lb-add lr0 lb1])
849AT_CHECK([ovn-nbctl --may-exist lr-lb-add lr0 lb1])
850AT_CHECK([ovn-nbctl lr-lb-add lr0 lb2], [1], [],
851[ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
852])
853AT_CHECK([ovn-nbctl lr-lb-add lr0 lb3])
854
855AT_CHECK([ovn-nbctl lr-lb-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
856UUID LB PROTO VIP IPs
857<0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
858<1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
859<2> lb3 tcp/udp ae0f::10 fd0f::10,fd0f::20
860])
861
862AT_CHECK([ovn-nbctl lr-lb-del lr0 lb0])
863AT_CHECK([ovn-nbctl lr-lb-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
864UUID LB PROTO VIP IPs
865<0> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
866<1> lb3 tcp/udp ae0f::10 fd0f::10,fd0f::20
867])
868
869AT_CHECK([ovn-nbctl lr-lb-del lr0 lb1])
870AT_CHECK([ovn-nbctl lr-lb-del lr0 lb3])
871AT_CHECK([ovn-nbctl lr-lb-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [])
872AT_CHECK([ovn-nbctl --if-exists lr-lb-del lr0 lb1])
873
874dnl Remove all load balancers from logical router.
875AT_CHECK([ovn-nbctl lr-lb-add lr0 lb0])
876AT_CHECK([ovn-nbctl lr-lb-add lr0 lb1])
877AT_CHECK([ovn-nbctl lr-lb-add lr0 lb3])
878AT_CHECK([ovn-nbctl lr-lb-del lr0])
879AT_CHECK([ovn-nbctl lr-lb-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [])
880
881OVN_NBCTL_TEST_STOP
882AT_CLEANUP
7127583d
NG
883dnl ---------------------------------------------------------------------
884
fa2a27b2 885AT_SETUP([ovn-nbctl - basic logical router commands])
7127583d
NG
886OVN_NBCTL_TEST_START
887
fa2a27b2
JP
888AT_CHECK([ovn-nbctl lr-add lr0])
889AT_CHECK([ovn-nbctl lr-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
7127583d
NG
890<0> (lr0)
891])
892
fa2a27b2
JP
893AT_CHECK([ovn-nbctl lr-add lr1])
894AT_CHECK([ovn-nbctl lr-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
7127583d
NG
895<0> (lr0)
896<1> (lr1)
897])
898
fa2a27b2
JP
899AT_CHECK([ovn-nbctl lr-del lr0])
900AT_CHECK([ovn-nbctl lr-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
7127583d
NG
901<0> (lr1)
902])
903
904AT_CHECK([ovn-nbctl show lr0])
fa2a27b2 905AT_CHECK([ovn-nbctl lr-add lr0])
7127583d 906AT_CHECK([ovn-nbctl show lr0 | ${PERL} $srcdir/uuidfilt.pl], [0],
7a16f569 907 [router <0> (lr0)
7127583d 908])
fa2a27b2
JP
909AT_CHECK([ovn-nbctl lr-add lr0], [1], [],
910 [ovn-nbctl: lr0: a router with this name already exists
7127583d 911])
fa2a27b2 912AT_CHECK([ovn-nbctl --may-exist lr-add lr0])
7127583d 913AT_CHECK([ovn-nbctl show lr0 | ${PERL} $srcdir/uuidfilt.pl], [0],
7a16f569 914 [router <0> (lr0)
7127583d 915])
fa2a27b2
JP
916AT_CHECK([ovn-nbctl --add-duplicate lr-add lr0])
917AT_CHECK([ovn-nbctl --may-exist --add-duplicate lr-add lr0], [1], [],
7127583d
NG
918 [ovn-nbctl: --may-exist and --add-duplicate may not be used together
919])
fa2a27b2 920AT_CHECK([ovn-nbctl lr-del lr0], [1], [],
7127583d
NG
921 [ovn-nbctl: Multiple logical routers named 'lr0'. Use a UUID.
922])
923
fa2a27b2
JP
924AT_CHECK([ovn-nbctl lr-del lr2], [1], [],
925 [ovn-nbctl: lr2: router name not found
7127583d 926])
fa2a27b2 927AT_CHECK([ovn-nbctl --if-exists lr-del lr2])
7127583d 928
fa2a27b2
JP
929AT_CHECK([ovn-nbctl lr-add])
930AT_CHECK([ovn-nbctl lr-add])
931AT_CHECK([ovn-nbctl --add-duplicate lr-add], [1], [],
7127583d
NG
932 [ovn-nbctl: --add-duplicate requires specifying a name
933])
fa2a27b2 934AT_CHECK([ovn-nbctl --may-exist lr-add], [1], [],
7127583d
NG
935 [ovn-nbctl: --may-exist requires specifying a name
936])
937
938OVN_NBCTL_TEST_STOP
939AT_CLEANUP
940
941dnl ---------------------------------------------------------------------
942
31114af7 943AT_SETUP([ovn-nbctl - basic logical router port commands])
7127583d
NG
944OVN_NBCTL_TEST_START
945
fa2a27b2 946AT_CHECK([ovn-nbctl lr-add lr0])
10c3fcdf 947AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02 192.168.1.1/24], [1], [],
948 [ovn-nbctl: lrp0: invalid mac address 00:00:00:01:02
949])
950AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03:04 192.168.1.1/24], [1], [],
951 [ovn-nbctl: lrp0: invalid mac address 00:00:00:01:02:03:04
952])
953
31114af7 954AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24])
34a88a45
JP
955
956AT_CHECK([ovn-nbctl show lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
7a16f569
BP
957router <0> (lr0)
958 port lrp0
959 mac: "00:00:00:01:02:03"
960 networks: [["192.168.1.1/24"]]
34a88a45
JP
961])
962
31114af7
JP
963AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24], [1], [],
964 [ovn-nbctl: lrp0: a port with this name already exists
7127583d 965])
31114af7
JP
966AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24])
967AT_CHECK([ovn-nbctl lrp-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
7127583d
NG
968<0> (lrp0)
969])
970
4685e523 971AT_CHECK([ovn-nbctl lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24 peer=lrp1-peer])
31114af7 972AT_CHECK([ovn-nbctl lrp-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
7127583d
NG
973<0> (lrp0)
974<1> (lrp1)
975])
976
fa2a27b2 977AT_CHECK([ovn-nbctl lr-add lr1])
31114af7
JP
978AT_CHECK([ovn-nbctl lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24], [1], [],
979 [ovn-nbctl: lrp1: a port with this name already exists
7127583d
NG
980])
981
31114af7
JP
982AT_CHECK([ovn-nbctl --may-exist lrp-add lr1 lrp1 00:00:00:01:02:03 192.168.1.1/24], [1], [],
983 [ovn-nbctl: lrp1: port already exists but in router lr0
7127583d
NG
984])
985
31114af7
JP
986AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:04:05:06 192.168.1.1/24], [1], [],
987 [ovn-nbctl: lrp1: port already exists with mac 00:00:00:01:02:03
7127583d
NG
988])
989
31114af7
JP
990AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24], [1], [],
991 [ovn-nbctl: lrp1: port already exists with mismatching peer
7127583d
NG
992])
993
4685e523
JP
994AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 10.0.0.1/24 peer=lrp1-peer], [1], [],
995 [ovn-nbctl: lrp1: port already exists with different network
996])
997
998AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24 peer=lrp1-peer])
31114af7
JP
999
1000AT_CHECK([ovn-nbctl lrp-del lrp1])
1001AT_CHECK([ovn-nbctl lrp-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
1002<0> (lrp0)
7127583d
NG
1003])
1004
4685e523
JP
1005AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24 10.0.0.1/24 peer=lrp1-peer])
1006
1007AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24 172.16.0.1/24 peer=lrp1-peer], [1], [],
1008 [ovn-nbctl: lrp1: port already exists with different network
1009])
1010
1011AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 10.0.0.1/24 192.168.1.1/24 peer=lrp1-peer])
36f232bc
VA
1012
1013OVN_NBCTL_TEST_STOP
1014AT_CLEANUP
1015
1016dnl ---------------------------------------------------------------------
1017
1018AT_SETUP([ovn-nbctl - logical router port gateway chassis])
1019OVN_NBCTL_TEST_START
1020AT_CHECK([ovn-nbctl lr-add lr0])
1021AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24])
1022AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [])
1023
1024AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lp0 chassis1], [1], [],
1025[ovn-nbctl: lp0: port name not found
1026])
1027
1028AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lp0], [1], [],
1029[ovn-nbctl: lp0: port name not found
1030])
1031
1032AT_CHECK([ovn-nbctl lrp-del-gateway-chassis lp0 chassis1], [1], [],
1033[ovn-nbctl: lp0: port name not found
1034])
1035
1036AT_CHECK([ovn-nbctl lrp-del-gateway-chassis lrp0 chassis1], [1], [],
1037[ovn-nbctl: chassis chassis1 is not added to logical port lrp0
1038])
1039AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis1])
1040
1041AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl
1042lrp0-chassis1 0
1043])
1044AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis1 10])
1045
1046AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl
1047lrp0-chassis1 10
1048])
1049AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis1 20])
1050
1051AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl
1052lrp0-chassis1 20
1053])
1054AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis2 5])
1055AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl
1056lrp0-chassis1 20
1057lrp0-chassis2 5
1058])
1059
1060AT_CHECK([ovn-nbctl lrp-del-gateway-chassis lrp0 chassis1])
1061AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl
1062lrp0-chassis2 5
1063])
1064
1065AT_CHECK([ovn-nbctl lrp-del-gateway-chassis lrp0 chassis2])
1066AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0])
4685e523 1067
7127583d
NG
1068OVN_NBCTL_TEST_STOP
1069AT_CLEANUP
1070
1071dnl ---------------------------------------------------------------------
1072
31114af7 1073AT_SETUP([ovn-nbctl - logical router port enable and disable])
7127583d
NG
1074OVN_NBCTL_TEST_START
1075
fa2a27b2 1076AT_CHECK([ovn-nbctl lr-add lr0])
31114af7
JP
1077AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24])
1078AT_CHECK([ovn-nbctl lrp-get-enabled lrp0], [0], [enabled
7127583d
NG
1079])
1080
31114af7
JP
1081AT_CHECK([ovn-nbctl lrp-set-enabled lrp0 disabled])
1082AT_CHECK([ovn-nbctl lrp-get-enabled lrp0], [0], [disabled
7127583d
NG
1083])
1084
31114af7
JP
1085AT_CHECK([ovn-nbctl lrp-set-enabled lrp0 enabled])
1086AT_CHECK([ovn-nbctl lrp-get-enabled lrp0], [0], [enabled
7127583d
NG
1087])
1088
31114af7 1089AT_CHECK([ovn-nbctl lrp-set-enabled lrp0 xyzzy], [1], [],
7127583d
NG
1090 [ovn-nbctl: xyzzy: state must be "enabled" or "disabled"
1091])
1092
1093OVN_NBCTL_TEST_STOP
1094AT_CLEANUP
e48ccf3c
JP
1095
1096dnl ---------------------------------------------------------------------
1097
1098AT_SETUP([ovn-nbctl - routes])
1099OVN_NBCTL_TEST_START
1100
1101AT_CHECK([ovn-nbctl lr-add lr0])
1102
1103dnl Check IPv4 routes
1104AT_CHECK([ovn-nbctl lr-route-add lr0 0.0.0.0/0 192.168.0.1])
1105AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.1.0/24 11.0.1.1 lp0])
1106AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.1/24 11.0.0.2])
1107
1108dnl Add overlapping route with 10.0.0.1/24
1109AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24 11.0.0.1], [1], [],
1110 [ovn-nbctl: duplicate prefix: 10.0.0.0/24
1111])
b712dea0 1112AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111a/24 11.0.0.1], [1], [],
1113 [ovn-nbctl: bad prefix argument: 10.0.0.111a/24
1114])
1115AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24a 11.0.0.1], [1], [],
1116 [ovn-nbctl: bad prefix argument: 10.0.0.111/24a
1117])
1118AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24 11.0.0.1a], [1], [],
1119 [ovn-nbctl: bad next hop argument: 11.0.0.1a
1120])
1121AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24 11.0.0.1/24], [1], [],
1122 [ovn-nbctl: bad IPv4 nexthop argument: 11.0.0.1/24
1123])
1124AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:1::/64 2001:0db8:0:f103::1/64], [1], [],
1125 [ovn-nbctl: bad IPv6 nexthop argument: 2001:0db8:0:f103::1/64
1126])
1127
e48ccf3c 1128AT_CHECK([ovn-nbctl --may-exist lr-route-add lr0 10.0.0.111/24 11.0.0.1])
440a9f4b 1129AT_CHECK([ovn-nbctl --policy=src-ip lr-route-add lr0 9.16.1.0/24 11.0.0.1])
e48ccf3c
JP
1130
1131AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1132IPv4 Routes
440a9f4b
GS
1133 10.0.0.0/24 11.0.0.1 dst-ip
1134 10.0.1.0/24 11.0.1.1 dst-ip lp0
1135 9.16.1.0/24 11.0.0.1 src-ip
1136 0.0.0.0/0 192.168.0.1 dst-ip
e48ccf3c
JP
1137])
1138
01a528f3
GS
1139AT_CHECK([ovn-nbctl --may-exist lr-route-add lr0 10.0.0.111/24 11.0.0.1 lp1])
1140AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1141IPv4 Routes
440a9f4b
GS
1142 10.0.0.0/24 11.0.0.1 dst-ip lp1
1143 10.0.1.0/24 11.0.1.1 dst-ip lp0
1144 9.16.1.0/24 11.0.0.1 src-ip
1145 0.0.0.0/0 192.168.0.1 dst-ip
01a528f3
GS
1146])
1147
e48ccf3c
JP
1148dnl Delete non-existent prefix
1149AT_CHECK([ovn-nbctl lr-route-del lr0 10.0.2.1/24], [1], [],
1150 [ovn-nbctl: no matching prefix: 10.0.2.0/24
1151])
1152AT_CHECK([ovn-nbctl --if-exists lr-route-del lr0 10.0.2.1/24])
1153
1154AT_CHECK([ovn-nbctl lr-route-del lr0 10.0.1.1/24])
440a9f4b 1155AT_CHECK([ovn-nbctl lr-route-del lr0 9.16.1.0/24])
e48ccf3c
JP
1156
1157AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1158IPv4 Routes
440a9f4b
GS
1159 10.0.0.0/24 11.0.0.1 dst-ip lp1
1160 0.0.0.0/0 192.168.0.1 dst-ip
e48ccf3c
JP
1161])
1162
1163AT_CHECK([ovn-nbctl lr-route-del lr0])
1164AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1165])
1166
1167dnl Check IPv6 routes
8c7623fe 1168AT_CHECK([ovn-nbctl lr-route-add lr0 0:0:0:0:0:0:0:0/0 2001:0db8:0:f101::1])
e48ccf3c
JP
1169AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:0::/64 2001:0db8:0:f102::1 lp0])
1170AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:1::/64 2001:0db8:0:f103::1])
1171
1172AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1173IPv6 Routes
440a9f4b
GS
1174 2001:db8::/64 2001:db8:0:f102::1 dst-ip lp0
1175 2001:db8:1::/64 2001:db8:0:f103::1 dst-ip
1176 ::/0 2001:db8:0:f101::1 dst-ip
e48ccf3c
JP
1177])
1178
1179AT_CHECK([ovn-nbctl lr-route-del lr0 2001:0db8:0::/64])
1180
1181AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1182IPv6 Routes
440a9f4b
GS
1183 2001:db8:1::/64 2001:db8:0:f103::1 dst-ip
1184 ::/0 2001:db8:0:f101::1 dst-ip
e48ccf3c
JP
1185])
1186
1187AT_CHECK([ovn-nbctl lr-route-del lr0])
1188AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1189])
1190
1191dnl Check IPv4 and IPv6 routes
1192AT_CHECK([ovn-nbctl lr-route-add lr0 0.0.0.0/0 192.168.0.1])
1193AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.1.1/24 11.0.1.1 lp0])
1194AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.1/24 11.0.0.1])
8c7623fe 1195AT_CHECK([ovn-nbctl lr-route-add lr0 0:0:0:0:0:0:0:0/0 2001:0db8:0:f101::1])
e48ccf3c
JP
1196AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:0::/64 2001:0db8:0:f102::1 lp0])
1197AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:1::/64 2001:0db8:0:f103::1])
1198
1199AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1200IPv4 Routes
440a9f4b
GS
1201 10.0.0.0/24 11.0.0.1 dst-ip
1202 10.0.1.0/24 11.0.1.1 dst-ip lp0
1203 0.0.0.0/0 192.168.0.1 dst-ip
e48ccf3c
JP
1204
1205IPv6 Routes
440a9f4b
GS
1206 2001:db8::/64 2001:db8:0:f102::1 dst-ip lp0
1207 2001:db8:1::/64 2001:db8:0:f103::1 dst-ip
1208 ::/0 2001:db8:0:f101::1 dst-ip
e48ccf3c
JP
1209])
1210
1211OVN_NBCTL_TEST_STOP
1212AT_CLEANUP
173acc1c
MM
1213
1214dnl ---------------------------------------------------------------------
1215
1216AT_SETUP([ovn-nbctl - lsp types])
1217OVN_NBCTL_TEST_START
1218
1219AT_CHECK([ovn-nbctl ls-add ls0])
1220AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
1221
1222dnl switchport type defaults to empty
1223AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1224
1225])
1226
1227dnl The following are the valid entries for
1228dnl switchport type
1229AT_CHECK([ovn-nbctl lsp-set-type lp0 l2gateway])
1230AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1231l2gateway
1232])
1233
1234AT_CHECK([ovn-nbctl lsp-set-type lp0 router])
1235AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1236router
1237])
1238
1239AT_CHECK([ovn-nbctl lsp-set-type lp0 localnet])
1240AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1241localnet
1242])
1243
1244AT_CHECK([ovn-nbctl lsp-set-type lp0 localport])
1245AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1246localport
1247])
1248
1249AT_CHECK([ovn-nbctl lsp-set-type lp0 vtep])
1250AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1251vtep
1252])
1253
1254dnl All of these are valid southbound port types but
1255dnl should be rejected for northbound logical switch
1256dnl ports.
1257AT_CHECK([ovn-nbctl lsp-set-type lp0 l3gateway], [1], [], [dnl
1258ovn-nbctl: Logical switch port type 'l3gateway' is unrecognized. Not setting type.
1259])
1260AT_CHECK([ovn-nbctl lsp-set-type lp0 patch], [1], [], [dnl
1261ovn-nbctl: Logical switch port type 'patch' is unrecognized. Not setting type.
1262])
1263AT_CHECK([ovn-nbctl lsp-set-type lp0 chassisredirect], [1], [], [dnl
1264ovn-nbctl: Logical switch port type 'chassisredirect' is unrecognized. Not setting type.
1265])
1266
1267dnl switch port type should still be "vtep" since previous
1268dnl commands failed.
1269AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1270vtep
1271])
1272
1273dnl Attempt a nonsense type
1274AT_CHECK([ovn-nbctl lsp-set-type lp0 eggs], [1], [], [dnl
1275ovn-nbctl: Logical switch port type 'eggs' is unrecognized. Not setting type.
1276])
1277
1278dnl Empty string should work too
1279AT_CHECK([ovn-nbctl lsp-set-type lp0 ""])
1280AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1281
1282])
1283
1284OVN_NBCTL_TEST_STOP
1285AT_CLEANUP