]> git.proxmox.com Git - mirror_ovs.git/blob - tests/ovn-nbctl.at
datapath: Add a new action check_pkt_len
[mirror_ovs.git] / tests / ovn-nbctl.at
1 AT_BANNER([ovn-nbctl])
2
3 OVS_START_SHELL_HELPERS
4 # OVN_NBCTL_TEST_START
5 m4_define([OVN_NBCTL_TEST_START],
6 [AT_KEYWORDS([ovn])
7 AT_CAPTURE_FILE([ovsdb-server.log])
8 ovn_nbctl_test_start $1])
9 ovn_nbctl_test_start() {
10 dnl Create ovn-nb database.
11 AT_CHECK([ovsdb-tool create ovn-nb.db $abs_top_srcdir/ovn/ovn-nb.ovsschema])
12
13 dnl Start ovsdb-server.
14 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/ovnnb_db.sock ovn-nb.db], [0], [], [stderr])
15 on_exit "kill `cat ovsdb-server.pid`"
16 AS_CASE([$1],
17 [daemon],
18 [export OVN_NB_DAEMON=$(ovn-nbctl --pidfile --detach --no-chdir --log-file -vsocket_util:off)
19 on_exit "kill `cat ovn-nbctl.pid`"],
20 [direct], [],
21 [*], [AT_FAIL_IF(:)])
22 AT_CHECK([ovn-nbctl init])
23 AT_CHECK([[sed < stderr '
24 /vlog|INFO|opened log file/d
25 /ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']])
26 }
27
28 # OVN_NBCTL_TEST_STOP
29 m4_define([OVN_NBCTL_TEST_STOP], [ovn_nbctl_test_stop])
30 ovn_nbctl_test_stop() {
31 AT_CHECK([check_logs "$1"])
32 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
33 }
34 OVS_END_SHELL_HELPERS
35
36 # OVN_NBCTL_TEST(NAME, TITLE, COMMANDS)
37 m4_define([OVN_NBCTL_TEST],
38 [OVS_START_SHELL_HELPERS
39 $1() {
40 $3
41 }
42 OVS_END_SHELL_HELPERS
43
44 AT_SETUP([ovn-nbctl - $2 - direct])
45 OVN_NBCTL_TEST_START direct
46 $1
47 OVN_NBCTL_TEST_STOP
48 AT_CLEANUP
49
50 AT_SETUP([ovn-nbctl - $2 - daemon])
51 OVN_NBCTL_TEST_START daemon
52 $1
53 OVN_NBCTL_TEST_STOP
54 AT_CLEANUP])
55
56 OVN_NBCTL_TEST([ovn_nbctl_basic_switch], [basic switch commands], [
57 AT_CHECK([ovn-nbctl ls-add ls0])
58 AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl
59 <0> (ls0)
60 ])
61
62 AT_CHECK([ovn-nbctl ls-add ls1])
63 AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl
64 <0> (ls0)
65 <1> (ls1)
66 ])
67
68 AT_CHECK([ovn-nbctl ls-del ls0])
69 AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl
70 <0> (ls1)
71 ])
72
73 AT_CHECK([ovn-nbctl show ls0])
74 AT_CHECK([ovn-nbctl ls-add ls0])
75 AT_CHECK([ovn-nbctl show ls0 | uuidfilt], [0],
76 [switch <0> (ls0)
77 ])
78 AT_CHECK([ovn-nbctl ls-add ls0], [1], [],
79 [ovn-nbctl: ls0: a switch with this name already exists
80 ])
81 AT_CHECK([ovn-nbctl --may-exist ls-add ls0])
82 AT_CHECK([ovn-nbctl show ls0 | uuidfilt], [0],
83 [switch <0> (ls0)
84 ])
85 AT_CHECK([ovn-nbctl --add-duplicate ls-add ls0])
86 AT_CHECK([ovn-nbctl --may-exist --add-duplicate ls-add ls0], [1], [],
87 [ovn-nbctl: --may-exist and --add-duplicate may not be used together
88 ])
89 AT_CHECK([ovn-nbctl ls-del ls0], [1], [],
90 [ovn-nbctl: Multiple logical switches named 'ls0'. Use a UUID.
91 ])
92
93 AT_CHECK([ovn-nbctl ls-del ls2], [1], [],
94 [ovn-nbctl: ls2: switch name not found
95 ])
96 AT_CHECK([ovn-nbctl --if-exists ls-del ls2])
97
98 AT_CHECK([ovn-nbctl ls-add])
99 AT_CHECK([ovn-nbctl ls-add])
100 AT_CHECK([ovn-nbctl --add-duplicate ls-add], [1], [],
101 [ovn-nbctl: --add-duplicate requires specifying a name
102 ])
103 AT_CHECK([ovn-nbctl --may-exist ls-add], [1], [],
104 [ovn-nbctl: --may-exist requires specifying a name
105 ])])
106
107 dnl ---------------------------------------------------------------------
108
109 OVN_NBCTL_TEST([ovn_nbctl_basic_lsp], [basic logical switch port commands], [
110 AT_CHECK([ovn-nbctl ls-add ls0])
111 AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
112 AT_CHECK([ovn-nbctl lsp-add ls0 lp0], [1], [],
113 [ovn-nbctl: lp0: a port with this name already exists
114 ])
115 AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp0])
116 AT_CHECK([ovn-nbctl lsp-list ls0 | uuidfilt], [0], [dnl
117 <0> (lp0)
118 ])
119
120 AT_CHECK([ovn-nbctl lsp-add ls0 lp1])
121 AT_CHECK([ovn-nbctl lsp-list ls0 | uuidfilt], [0], [dnl
122 <0> (lp0)
123 <1> (lp1)
124 ])
125
126 AT_CHECK([ovn-nbctl ls-add ls1])
127 AT_CHECK([ovn-nbctl lsp-add ls0 lp1], [1], [],
128 [ovn-nbctl: lp1: a port with this name already exists
129 ])
130 AT_CHECK([ovn-nbctl --may-exist lsp-add ls1 lp1], [1], [],
131 [ovn-nbctl: lp1: port already exists but in switch ls0
132 ])
133 AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp1 lp0 5], [1], [],
134 [ovn-nbctl: lp1: port already exists but has no parent
135 ])
136
137 AT_CHECK([ovn-nbctl lsp-del lp1])
138 AT_CHECK([ovn-nbctl lsp-list ls0 | uuidfilt], [0], [dnl
139 <0> (lp0)
140 ])
141
142 AT_CHECK([ovn-nbctl lsp-add ls0 lp2 lp3 5])
143 AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp2 lp4 5], [1], [],
144 [ovn-nbctl: lp2: port already exists with different parent lp3
145 ])
146 AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp2 lp3 10], [1], [],
147 [ovn-nbctl: lp2: port already exists with different tag_request 5
148 ])
149 AT_CHECK([ovn-nbctl clear Logical_Switch_Port lp2 tag_request])
150 AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp2 lp3 5], [1], [],
151 [ovn-nbctl: lp2: port already exists but has no tag_request
152 ])])
153
154 dnl ---------------------------------------------------------------------
155
156 OVN_NBCTL_TEST([ovn_nbctl_lsp_get_ls], [lsp get ls], [
157 AT_CHECK([ovn-nbctl ls-add ls0])
158 AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
159
160 AT_CHECK([ovn-nbctl lsp-get-ls lp0 | uuidfilt], [0], [dnl
161 <0> (ls0)
162 ])
163
164 AT_CHECK([ovn-nbctl lsp-get-ls lp1], [1], [],
165 [ovn-nbctl: lp1: port name not found
166 ])])
167
168 dnl ---------------------------------------------------------------------
169
170 OVN_NBCTL_TEST([ovn_nbctl_lport_addresses], [lport addresses], [
171 AT_CHECK([ovn-nbctl ls-add ls0])
172 AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
173 AT_CHECK([ovn-nbctl lsp-get-addresses lp0], [0], [dnl
174 ])
175
176 AT_CHECK([ovn-nbctl lsp-set-addresses lp0 00:11:22:33:44:55 unknown])
177 AT_CHECK([ovn-nbctl lsp-get-addresses lp0], [0], [dnl
178 00:11:22:33:44:55
179 unknown
180 ])
181
182 AT_CHECK([ovn-nbctl lsp-set-addresses lp0])
183 AT_CHECK([ovn-nbctl lsp-get-addresses lp0], [0], [dnl
184 ])])
185
186 dnl ---------------------------------------------------------------------
187
188 OVN_NBCTL_TEST([ovn_nbctl_port_security], [port security], [
189 AT_CHECK([ovn-nbctl ls-add ls0])
190 AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
191 AT_CHECK([ovn-nbctl lsp-get-addresses lp0], [0], [dnl
192 ])
193
194 AT_CHECK([ovn-nbctl lsp-set-port-security lp0 aa:bb:cc:dd:ee:ff 00:11:22:33:44:55])
195 AT_CHECK([ovn-nbctl lsp-get-port-security lp0], [0], [dnl
196 00:11:22:33:44:55
197 aa:bb:cc:dd:ee:ff
198 ])
199
200 AT_CHECK([ovn-nbctl lsp-set-port-security lp0])
201 AT_CHECK([ovn-nbctl lsp-get-port-security lp0], [0], [dnl
202 ])])
203
204 dnl ---------------------------------------------------------------------
205
206 OVN_NBCTL_TEST([ovn_nbctl_acls], [ACLs], [
207 ovn_nbctl_test_acl() {
208 AT_CHECK([ovn-nbctl $2 --log acl-add $1 from-lport 600 udp drop])
209 AT_CHECK([ovn-nbctl $2 --log --name=test --severity=info acl-add $1 to-lport 500 udp drop])
210 AT_CHECK([ovn-nbctl $2 acl-add $1 from-lport 400 tcp drop])
211 AT_CHECK([ovn-nbctl $2 acl-add $1 to-lport 300 tcp drop])
212 AT_CHECK([ovn-nbctl $2 acl-add $1 from-lport 200 ip drop])
213 AT_CHECK([ovn-nbctl $2 acl-add $1 to-lport 100 ip drop])
214 dnl Add duplicated ACL
215 AT_CHECK([ovn-nbctl $2 acl-add $1 to-lport 100 ip drop], [1], [], [stderr])
216 AT_CHECK([grep 'already existed' stderr], [0], [ignore])
217 AT_CHECK([ovn-nbctl $2 --may-exist acl-add $1 to-lport 100 ip drop])
218
219 AT_CHECK([ovn-nbctl $2 acl-list $1], [0], [dnl
220 from-lport 600 (udp) drop log()
221 from-lport 400 (tcp) drop
222 from-lport 200 (ip) drop
223 to-lport 500 (udp) drop log(name=test,severity=info)
224 to-lport 300 (tcp) drop
225 to-lport 100 (ip) drop
226 ])
227
228 dnl Delete in one direction.
229 AT_CHECK([ovn-nbctl $2 acl-del $1 to-lport])
230 AT_CHECK([ovn-nbctl $2 acl-list $1], [0], [dnl
231 from-lport 600 (udp) drop log()
232 from-lport 400 (tcp) drop
233 from-lport 200 (ip) drop
234 ])
235
236 dnl Delete all ACLs.
237 AT_CHECK([ovn-nbctl $2 acl-del $1])
238 AT_CHECK([ovn-nbctl $2 acl-list $1], [0], [dnl
239 ])
240
241 AT_CHECK([ovn-nbctl $2 acl-add $1 from-lport 600 udp drop])
242 AT_CHECK([ovn-nbctl $2 acl-add $1 from-lport 400 tcp drop])
243 AT_CHECK([ovn-nbctl $2 acl-add $1 from-lport 200 ip drop])
244
245 dnl Delete a single flow.
246 AT_CHECK([ovn-nbctl $2 acl-del $1 from-lport 400 tcp])
247 AT_CHECK([ovn-nbctl $2 acl-list $1], [0], [dnl
248 from-lport 600 (udp) drop
249 from-lport 200 (ip) drop
250 ])
251 }
252
253 AT_CHECK([ovn-nbctl ls-add ls0])
254 ovn_nbctl_test_acl ls0
255 AT_CHECK([ovn-nbctl ls-add ls1])
256 ovn_nbctl_test_acl ls1 --type=switch
257 AT_CHECK([ovn-nbctl create port_group name=pg0], [0], [ignore])
258 ovn_nbctl_test_acl pg0 --type=port-group
259
260 dnl Test when port group doesn't exist
261 AT_CHECK([ovn-nbctl --type=port-group acl-add pg1 to-lport 100 ip drop], [1], [], [dnl
262 ovn-nbctl: pg1: port group name not found
263 ])
264
265 dnl Test when same name exists in logical switches and portgroups
266 AT_CHECK([ovn-nbctl create port_group name=ls0], [0], [ignore])
267 AT_CHECK([ovn-nbctl acl-add ls0 to-lport 100 ip drop], [1], [], [stderr])
268 AT_CHECK([grep 'exists in both' stderr], [0], [ignore])
269 AT_CHECK([ovn-nbctl --type=port-group acl-add ls0 to-lport 100 ip drop], [0], [ignore])])
270
271 dnl ---------------------------------------------------------------------
272
273 OVN_NBCTL_TEST([ovn_nbctl_qos], [QoS], [
274 AT_CHECK([ovn-nbctl ls-add ls0])
275 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 600 tcp dscp=63])
276 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 500 udp rate=100 burst=1000])
277 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 400 tcp dscp=0 rate=300 burst=3000])
278 AT_CHECK([ovn-nbctl qos-add ls0 to-lport 300 tcp dscp=48])
279 AT_CHECK([ovn-nbctl qos-add ls0 to-lport 200 ip rate=101])
280 AT_CHECK([ovn-nbctl qos-add ls0 to-lport 100 ip4 dscp=13 rate=301 burst=30000])
281
282 dnl Add duplicated qos
283 AT_CHECK([ovn-nbctl qos-add ls0 to-lport 100 ip4 dscp=11 rate=302 burst=30002], [1], [], [stderr])
284 AT_CHECK([grep 'already existed' stderr], [0], [ignore])
285 AT_CHECK([ovn-nbctl --may-exist qos-add ls0 to-lport 100 ip4 dscp=11 rate=302 burst=30002])
286
287 AT_CHECK([ovn-nbctl qos-list ls0], [0], [dnl
288 from-lport 600 (tcp) dscp=63
289 from-lport 500 (udp) rate=100 burst=1000
290 from-lport 400 (tcp) rate=300 burst=3000 dscp=0
291 to-lport 300 (tcp) dscp=48
292 to-lport 200 (ip) rate=101
293 to-lport 100 (ip4) rate=301 burst=30000 dscp=13
294 ])
295
296 dnl Delete in one direction.
297 AT_CHECK([ovn-nbctl qos-del ls0 to-lport])
298 AT_CHECK([ovn-nbctl qos-list ls0], [0], [dnl
299 from-lport 600 (tcp) dscp=63
300 from-lport 500 (udp) rate=100 burst=1000
301 from-lport 400 (tcp) rate=300 burst=3000 dscp=0
302 ])
303
304 dnl Delete all qos_rules.
305 AT_CHECK([ovn-nbctl qos-del ls0])
306 AT_CHECK([ovn-nbctl qos-list ls0], [0], [dnl
307 ])
308
309 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 600 ip rate=1000101])
310 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 400 tcp dscp=44])
311 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 200 ip burst=1000102 rate=301 dscp=19])
312
313 dnl Delete a single flow.
314 AT_CHECK([ovn-nbctl qos-del ls0 from-lport 400 tcp])
315 AT_CHECK([ovn-nbctl qos-list ls0], [0], [dnl
316 from-lport 600 (ip) rate=1000101
317 from-lport 200 (ip) rate=301 burst=1000102 dscp=19
318 ])
319
320 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 600 ip rate=100010111111], [1], [],
321 [ovn-nbctl: 100010111111: rate must be in the range 1...4294967295
322 ])
323
324 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 600 ip burst=100010111112 rate=100010], [1], [],
325 [ovn-nbctl: 100010111112: burst must be in the range 1...4294967295
326 ])
327
328 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 600 ip dscp=-1], [1], [],
329 [ovn-nbctl: -1: dscp must be in the range 0...63
330 ])
331
332 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 600 ip dscpa=-1], [1], [],
333 [ovn-nbctl: dscpa=-1: supported arguments are "dscp=", "rate=", and "burst="
334 ])
335
336 AT_CHECK([ovn-nbctl qos-add ls0 from-lport 600 ip burst=123], [1], [],
337 [ovn-nbctl: Either "rate" and/or "dscp" must be specified
338 ])])
339
340 dnl ---------------------------------------------------------------------
341
342 OVN_NBCTL_TEST([ovn_nbctl_meters], [meters], [
343 AT_CHECK([ovn-nbctl meter-add meter1 drop 10 kbps])
344 AT_CHECK([ovn-nbctl meter-add meter2 drop 3 kbps 2])
345 AT_CHECK([ovn-nbctl meter-add meter3 drop 100 kbps 200])
346 AT_CHECK([ovn-nbctl meter-add meter4 drop 10 pktps 30])
347
348 dnl Add duplicate meter name
349 AT_CHECK([ovn-nbctl meter-add meter1 drop 10 kbps], [1], [], [stderr])
350 AT_CHECK([grep 'already exists' stderr], [0], [ignore])
351
352 dnl Add reserved meter name
353 AT_CHECK([ovn-nbctl meter-add __meter1 drop 10 kbps], [1], [], [stderr])
354 AT_CHECK([grep 'reserved' stderr], [0], [ignore])
355
356 dnl Add meter with invalid rates
357 AT_CHECK([ovn-nbctl meter-add meter5 drop 100010111111 kbps], [1], [],
358 [ovn-nbctl: rate must be in the range 1...4294967295
359 ])
360
361 dnl Add meter with invalid rates
362 AT_CHECK([ovn-nbctl meter-add meter5 drop 100010111111 foo], [1], [],
363 [ovn-nbctl: rate must be in the range 1...4294967295
364 ])
365
366 AT_CHECK([ovn-nbctl meter-add meter5 drop 0 kbps], [1], [],
367 [ovn-nbctl: rate must be in the range 1...4294967295
368 ])
369
370 dnl Add meter with invalid burst
371 AT_CHECK([ovn-nbctl meter-add meter5 drop 10 100010111111 kbps], [1], [],
372 [ovn-nbctl: unit must be "kbps" or "pktps"
373 ])
374
375 AT_CHECK([ovn-nbctl meter-list], [0], [dnl
376 meter1: bands:
377 drop: 10 kbps
378 meter2: bands:
379 drop: 3 kbps, 2 kb burst
380 meter3: bands:
381 drop: 100 kbps, 200 kb burst
382 meter4: bands:
383 drop: 10 pktps, 30 packet burst
384 ])
385
386 dnl Delete a single meter.
387 AT_CHECK([ovn-nbctl meter-del meter2])
388 AT_CHECK([ovn-nbctl meter-list], [0], [dnl
389 meter1: bands:
390 drop: 10 kbps
391 meter3: bands:
392 drop: 100 kbps, 200 kb burst
393 meter4: bands:
394 drop: 10 pktps, 30 packet burst
395 ])
396
397 dnl Delete all meters.
398 AT_CHECK([ovn-nbctl meter-del])
399 AT_CHECK([ovn-nbctl meter-list], [0], [dnl
400 ])])
401
402 dnl ---------------------------------------------------------------------
403
404 OVN_NBCTL_TEST([ovn_nbctl_nats], [NATs], [
405 AT_CHECK([ovn-nbctl lr-add lr0])
406 AT_CHECK([ovn-nbctl lr-nat-add lr0 snatt 30.0.0.2 192.168.1.2], [1], [],
407 [ovn-nbctl: snatt: type must be one of "dnat", "snat" and "dnat_and_snat".
408 ])
409 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2a 192.168.1.2], [1], [],
410 [ovn-nbctl: 30.0.0.2a: should be an IPv4 address.
411 ])
412 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0 192.168.1.2], [1], [],
413 [ovn-nbctl: 30.0.0: should be an IPv4 address.
414 ])
415 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2/24 192.168.1.2], [1], [],
416 [ovn-nbctl: 30.0.0.2/24: should be an IPv4 address.
417 ])
418 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2:80 192.168.1.2], [1], [],
419 [ovn-nbctl: 30.0.0.2:80: should be an IPv4 address.
420 ])
421 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2 192.168.1.2a], [1], [],
422 [ovn-nbctl: 192.168.1.2a: should be an IPv4 address or network.
423 ])
424 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2 192.168.1], [1], [],
425 [ovn-nbctl: 192.168.1: should be an IPv4 address or network.
426 ])
427 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2 192.168.1.2:80], [1], [],
428 [ovn-nbctl: 192.168.1.2:80: should be an IPv4 address or network.
429 ])
430 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2 192.168.1.2/a], [1], [],
431 [ovn-nbctl: 192.168.1.2/a: should be an IPv4 address or network.
432 ])
433 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.2 192.168.1.2a], [1], [],
434 [ovn-nbctl: 192.168.1.2a: should be an IPv4 address.
435 ])
436 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.2 192.168.1], [1], [],
437 [ovn-nbctl: 192.168.1: should be an IPv4 address.
438 ])
439 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.2 192.168.1.2:80], [1], [],
440 [ovn-nbctl: 192.168.1.2:80: should be an IPv4 address.
441 ])
442 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.2 192.168.1.2/24], [1], [],
443 [ovn-nbctl: 192.168.1.2/24: should be an IPv4 address.
444 ])
445 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.2 192.168.1.2/24], [1], [],
446 [ovn-nbctl: 192.168.1.2/24: should be an IPv4 address.
447 ])
448 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.2 192.168.1.2 lp0], [1], [],
449 [ovn-nbctl: lr-nat-add with logical_port must also specify external_mac.
450 ])
451 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.2 192.168.1.2 lp0 00:00:00:01:02:03], [1], [],
452 [ovn-nbctl: logical_port and external_mac are only valid when type is "dnat_and_snat".
453 ])
454 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2 192.168.1.2 lp0 00:00:00:01:02:03], [1], [],
455 [ovn-nbctl: logical_port and external_mac are only valid when type is "dnat_and_snat".
456 ])
457 AT_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], [],
458 [ovn-nbctl: lp0: port name not found
459 ])
460 AT_CHECK([ovn-nbctl ls-add ls0])
461 AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
462 AT_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], [],
463 [ovn-nbctl: invalid mac address 00:00:00:01:02.
464 ])
465
466 dnl Add snat and dnat
467 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.1 192.168.1.0/24])
468 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.1 192.168.1.2])
469 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.1 192.168.1.2])
470 AT_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])
471 AT_CHECK([ovn-nbctl lr-nat-list lr0], [0], [dnl
472 TYPE EXTERNAL_IP LOGICAL_IP EXTERNAL_MAC LOGICAL_PORT
473 dnat 30.0.0.1 192.168.1.2
474 dnat_and_snat 30.0.0.1 192.168.1.2
475 dnat_and_snat 30.0.0.2 192.168.1.3 00:00:00:01:02:03 lp0
476 snat 30.0.0.1 192.168.1.0/24
477 ])
478 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.1 192.168.1.0/24], [1], [],
479 [ovn-nbctl: 30.0.0.1, 192.168.1.0/24: a NAT with this external_ip and logical_ip already exists
480 ])
481 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.1 192.168.1.10/24], [1], [],
482 [ovn-nbctl: 30.0.0.1, 192.168.1.0/24: a NAT with this external_ip and logical_ip already exists
483 ])
484 AT_CHECK([ovn-nbctl --may-exist lr-nat-add lr0 snat 30.0.0.1 192.168.1.0/24])
485 AT_CHECK([ovn-nbctl lr-nat-add lr0 snat 30.0.0.2 192.168.1.0/24], [1], [],
486 [ovn-nbctl: a NAT with this type (snat) and logical_ip (192.168.1.0/24) already exists
487 ])
488 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.1 192.168.1.2], [1], [],
489 [ovn-nbctl: 30.0.0.1, 192.168.1.2: a NAT with this external_ip and logical_ip already exists
490 ])
491 AT_CHECK([ovn-nbctl --may-exist lr-nat-add lr0 dnat 30.0.0.1 192.168.1.2])
492 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat 30.0.0.1 192.168.1.3], [1], [],
493 [ovn-nbctl: a NAT with this type (dnat) and external_ip (30.0.0.1) already exists
494 ])
495 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.1 192.168.1.2], [1], [],
496 [ovn-nbctl: 30.0.0.1, 192.168.1.2: a NAT with this external_ip and logical_ip already exists
497 ])
498 AT_CHECK([ovn-nbctl --may-exist lr-nat-add lr0 dnat_and_snat 30.0.0.1 192.168.1.2])
499 AT_CHECK([ovn-nbctl lr-nat-add lr0 dnat_and_snat 30.0.0.1 192.168.1.3], [1], [],
500 [ovn-nbctl: a NAT with this type (dnat_and_snat) and external_ip (30.0.0.1) already exists
501 ])
502 AT_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])
503 AT_CHECK([ovn-nbctl lr-nat-list lr0], [0], [dnl
504 TYPE EXTERNAL_IP LOGICAL_IP EXTERNAL_MAC LOGICAL_PORT
505 dnat 30.0.0.1 192.168.1.2
506 dnat_and_snat 30.0.0.1 192.168.1.2
507 dnat_and_snat 30.0.0.2 192.168.1.3 00:00:00:04:05:06 lp0
508 snat 30.0.0.1 192.168.1.0/24
509 ])
510 AT_CHECK([ovn-nbctl --may-exist lr-nat-add lr0 dnat_and_snat 30.0.0.2 192.168.1.3])
511 AT_CHECK([ovn-nbctl lr-nat-list lr0], [0], [dnl
512 TYPE EXTERNAL_IP LOGICAL_IP EXTERNAL_MAC LOGICAL_PORT
513 dnat 30.0.0.1 192.168.1.2
514 dnat_and_snat 30.0.0.1 192.168.1.2
515 dnat_and_snat 30.0.0.2 192.168.1.3
516 snat 30.0.0.1 192.168.1.0/24
517 ])
518
519 dnl Deletes the NATs
520 AT_CHECK([ovn-nbctl lr-nat-del lr0 dnat_and_snat 30.0.0.3], [1], [],
521 [ovn-nbctl: no matching NAT with the type (dnat_and_snat) and external_ip (30.0.0.3)
522 ])
523 AT_CHECK([ovn-nbctl lr-nat-del lr0 dnat 30.0.0.2], [1], [],
524 [ovn-nbctl: no matching NAT with the type (dnat) and external_ip (30.0.0.2)
525 ])
526 AT_CHECK([ovn-nbctl lr-nat-del lr0 snat 192.168.10.0/24], [1], [],
527 [ovn-nbctl: no matching NAT with the type (snat) and logical_ip (192.168.10.0/24)
528 ])
529 AT_CHECK([ovn-nbctl --if-exists lr-nat-del lr0 snat 192.168.10.0/24])
530
531 AT_CHECK([ovn-nbctl lr-nat-del lr0 dnat_and_snat 30.0.0.1])
532 AT_CHECK([ovn-nbctl lr-nat-list lr0], [0], [dnl
533 TYPE EXTERNAL_IP LOGICAL_IP EXTERNAL_MAC LOGICAL_PORT
534 dnat 30.0.0.1 192.168.1.2
535 dnat_and_snat 30.0.0.2 192.168.1.3
536 snat 30.0.0.1 192.168.1.0/24
537 ])
538
539 AT_CHECK([ovn-nbctl lr-nat-del lr0 dnat])
540 AT_CHECK([ovn-nbctl lr-nat-list lr0], [0], [dnl
541 TYPE EXTERNAL_IP LOGICAL_IP EXTERNAL_MAC LOGICAL_PORT
542 dnat_and_snat 30.0.0.2 192.168.1.3
543 snat 30.0.0.1 192.168.1.0/24
544 ])
545
546 AT_CHECK([ovn-nbctl lr-nat-del lr0])
547 AT_CHECK([ovn-nbctl lr-nat-list lr0], [0], [])
548 AT_CHECK([ovn-nbctl lr-nat-del lr0])
549 AT_CHECK([ovn-nbctl lr-nat-del lr0 dnat])])
550
551 dnl ---------------------------------------------------------------------
552
553 OVN_NBCTL_TEST([ovn_nbctl_lbs], [LBs], [
554 dnl Add two LBs.
555 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0.10:80a 192.168.10.10:80,192.168.10.20:80 tcp], [1], [],
556 [ovn-nbctl: 30.0.0.10:80a: should be an IP address (or an IP address and a port number with : as a separator).
557 ])
558
559 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0.10:a80 192.168.10.10:80,192.168.10.20:80 tcp], [1], [],
560 [ovn-nbctl: 30.0.0.10:a80: should be an IP address (or an IP address and a port number with : as a separator).
561 ])
562
563 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0.10:80 192.168.10.10:80,192.168.10.20 tcp], [1], [],
564 [ovn-nbctl: 192.168.10.20: should be an IP address and a port number with : as a separator.
565 ])
566
567 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0.1a 192.168.10.10:80,192.168.10.20:80], [1], [],
568 [ovn-nbctl: 30.0.0.1a: should be an IP address (or an IP address and a port number with : as a separator).
569 ])
570
571 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0 192.168.10.10:80,192.168.10.20:80], [1], [],
572 [ovn-nbctl: 30.0.0: should be an IP address (or an IP address and a port number with : as a separator).
573 ])
574
575 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0.10 192.168.10.10,192.168.10.20:80], [1], [],
576 [ovn-nbctl: 192.168.10.20:80: should be an IP address.
577 ])
578
579 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0.10 192.168.10.10:a80], [1], [],
580 [ovn-nbctl: 192.168.10.10:a80: should be an IP address.
581 ])
582
583 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0.10 192.168.10.10:], [1], [],
584 [ovn-nbctl: 192.168.10.10:: should be an IP address.
585 ])
586
587 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 30.0.0.10 192.168.10.1a], [1], [],
588 [ovn-nbctl: 192.168.10.1a: should be an IP address.
589 ])
590
591 AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10: 192.168.10.10:80,192.168.10.20:80 tcp], [1], [],
592 [ovn-nbctl: Protocol is unnecessary when no port of vip is given.
593 ])
594
595 AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10 192.168.10.10 tcp], [1], [],
596 [ovn-nbctl: Protocol is unnecessary when no port of vip is given.
597 ])
598
599 AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10 192.168.10.10:900 tcp], [1], [],
600 [ovn-nbctl: Protocol is unnecessary when no port of vip is given.
601 ])
602
603 dnl Add ips to lb
604 AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10:80 ,,,192.168.10.10:80,,,,,])
605 AT_CHECK([ovn-nbctl lb-add lb1 30.0.0.10:80 ,,,192.168.10.10:80,,,,192.168.10.20:80,,,,])
606 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
607 UUID LB PROTO VIP IPs
608 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80
609 <1> lb1 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
610 ])
611 AT_CHECK([ovn-nbctl lb-del lb0])
612 AT_CHECK([ovn-nbctl lb-del lb1])
613
614 AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80])
615 AT_CHECK([ovn-nbctl lb-add lb1 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 tcp])
616 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
617 UUID LB PROTO VIP IPs
618 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
619 <1> lb1 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
620 ])
621
622 dnl Update the VIP of the lb1.
623 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080])
624 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
625 UUID LB PROTO VIP IPs
626 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
627 <1> lb1 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080
628 ])
629
630 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080 udp])
631 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
632 UUID LB PROTO VIP IPs
633 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
634 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080
635 ])
636
637 dnl Config lb1 with another VIP.
638 AT_CHECK([ovn-nbctl lb-add lb1 30.0.0.20:80 192.168.10.10:80 udp])
639 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
640 UUID LB PROTO VIP IPs
641 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
642 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080
643 udp 30.0.0.20:80 192.168.10.10:80
644 ])
645
646 AT_CHECK([ovn-nbctl lb-del lb1 30.0.0.20:80])
647 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
648 UUID LB PROTO VIP IPs
649 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
650 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080
651 ])
652
653 dnl Add LBs whose vip is just an IP address.
654 AT_CHECK([ovn-nbctl lb-add lb2 30.0.0.30 192.168.10.10])
655 AT_CHECK([ovn-nbctl lb-add lb3 30.0.0.30 192.168.10.10])
656 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
657 UUID LB PROTO VIP IPs
658 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
659 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080
660 <2> lb2 tcp/udp 30.0.0.30 192.168.10.10
661 <3> lb3 tcp/udp 30.0.0.30 192.168.10.10
662 ])
663 AT_CHECK([ovn-nbctl lb-del lb2 30.0.0.30])
664 AT_CHECK([ovn-nbctl lb-del lb3 30.0.0.30])
665
666 AT_CHECK([ovn-nbctl lb-add lb2 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80 tcp])
667 AT_CHECK([ovn-nbctl --add-duplicate lb-add lb2 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80 tcp])
668 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
669 UUID LB PROTO VIP IPs
670 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
671 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080
672 <2> lb2 tcp 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80
673 <3> lb2 tcp 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80
674 ])
675
676 dnl If there are multiple load balancers with the same name, use a UUID to update/delete.
677 AT_CHECK([ovn-nbctl lb-add lb2 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80 tcp], [1], [],
678 [ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
679 ])
680
681 AT_CHECK([ovn-nbctl lb-del lb2], [1], [],
682 [ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
683 ])
684
685 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:80 192.168.10.10:8080,192.168.10.20:8080 udp])
686 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:8080 192.168.10.10:8080,192.168.10.20:8080 udp])
687 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:9090 192.168.10.10:8080,192.168.10.20:8080 udp])
688 AT_CHECK([ovn-nbctl lb-del lb0 30.0.0.10:80])
689 AT_CHECK([ovn-nbctl lb-del lb1])
690 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
691 UUID LB PROTO VIP IPs
692 <0> lb2 tcp 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80
693 <1> lb2 tcp 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80
694 ])
695
696 dnl Add load balancer to logical switch.
697 AT_CHECK([ovn-nbctl ls-add ls0])
698 AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80])
699 AT_CHECK([ovn-nbctl lb-add lb1 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 udp])
700 AT_CHECK([ovn-nbctl lb-add lb3 30.0.0.10 192.168.10.10,192.168.10.20])
701 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb0])
702 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb1])
703 AT_CHECK([ovn-nbctl --may-exist ls-lb-add ls0 lb1])
704 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb2], [1], [],
705 [ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
706 ])
707 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb3])
708
709 AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [dnl
710 UUID LB PROTO VIP IPs
711 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
712 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
713 <2> lb3 tcp/udp 30.0.0.10 192.168.10.10,192.168.10.20
714 ])
715
716 AT_CHECK([ovn-nbctl ls-lb-del ls0 lb0])
717 AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [dnl
718 UUID LB PROTO VIP IPs
719 <0> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
720 <1> lb3 tcp/udp 30.0.0.10 192.168.10.10,192.168.10.20
721 ])
722
723 AT_CHECK([ovn-nbctl ls-lb-del ls0 lb1])
724 AT_CHECK([ovn-nbctl ls-lb-del ls0 lb3])
725 AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [])
726 AT_CHECK([ovn-nbctl --if-exists ls-lb-del ls0 lb1])
727
728 dnl Remove all load balancers from logical switch.
729 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb0])
730 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb1])
731 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb3])
732 AT_CHECK([ovn-nbctl ls-lb-del ls0])
733 AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [])
734
735 dnl Add load balancer to logical router.
736 AT_CHECK([ovn-nbctl lr-add lr0])
737 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb0])
738 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb1])
739 AT_CHECK([ovn-nbctl --may-exist lr-lb-add lr0 lb1])
740 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb2], [1], [],
741 [ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
742 ])
743 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb3])
744
745 AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [dnl
746 UUID LB PROTO VIP IPs
747 <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
748 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
749 <2> lb3 tcp/udp 30.0.0.10 192.168.10.10,192.168.10.20
750 ])
751
752 AT_CHECK([ovn-nbctl lr-lb-del lr0 lb0])
753 AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [dnl
754 UUID LB PROTO VIP IPs
755 <0> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80
756 <1> lb3 tcp/udp 30.0.0.10 192.168.10.10,192.168.10.20
757 ])
758
759 AT_CHECK([ovn-nbctl lr-lb-del lr0 lb1])
760 AT_CHECK([ovn-nbctl lr-lb-del lr0 lb3])
761 AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [])
762 AT_CHECK([ovn-nbctl --if-exists lr-lb-del lr0 lb1])
763
764 dnl Remove all load balancers from logical router.
765 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb0])
766 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb1])
767 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb3])
768 AT_CHECK([ovn-nbctl lr-lb-del lr0])
769 AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [])
770
771 dnl Remove load balancers after adding them to a logical router/switch.
772 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb0])
773 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb1])
774 AT_CHECK([ovn-nbctl lb-del lb0])
775 AT_CHECK([ovn-nbctl lb-del lb1])
776 AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [])
777 AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [])])
778
779 dnl ---------------------------------------------------------------------
780
781 OVN_NBCTL_TEST([ovn_nbctl_lbs_ipv6], [LBs IPv6], [
782 dnl A bunch of commands that should fail
783 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 [[ae0f::10]]:80a [[fd0f::10]]:80,[[fd0f::20]]:80 tcp], [1], [],
784 [ovn-nbctl: [[ae0f::10]]:80a: should be an IP address (or an IP address and a port number with : as a separator).
785 ])
786
787
788 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 [[ae0f::10]]:a80 [[fd0f::10]]:80,[[fd0f::20]]:80 tcp], [1], [],
789 [ovn-nbctl: [[ae0f::10]]:a80: should be an IP address (or an IP address and a port number with : as a separator).
790 ])
791
792
793 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 [[ae0f::10]]:80 [[fd0f::10]]:80,fd0f::20 tcp], [1], [],
794 [ovn-nbctl: fd0f::20: should be an IP address and a port number with : as a separator.
795 ])
796
797
798 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 ae0f::10fff [[fd0f::10]]:80,fd0f::20 tcp], [1], [],
799 [ovn-nbctl: ae0f::10fff: should be an IP address (or an IP address and a port number with : as a separator).
800 ])
801
802
803 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 ae0f::10 [[fd0f::10]]:80,[[fd0f::20]]:80], [1], [],
804 [ovn-nbctl: [[fd0f::10]]:80: should be an IP address.
805 ])
806
807
808 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 ae0f::10 fd0f::10,[[fd0f::20]]:80], [1], [],
809 [ovn-nbctl: [[fd0f::20]]:80: should be an IP address.
810 ])
811
812
813 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 ae0f::10 [[fd0f::10]]:a80], [1], [],
814 [ovn-nbctl: [[fd0f::10]]:a80: should be an IP address.
815 ])
816
817
818 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 ae0f::10 [[fd0f::10]]:], [1], [],
819 [ovn-nbctl: [[fd0f::10]]:: should be an IP address.
820 ])
821
822
823 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 ae0f::10 fd0f::1001a], [1], [],
824 [ovn-nbctl: fd0f::1001a: should be an IP address.
825 ])
826
827
828 AT_CHECK([ovn-nbctl -vsocket_util:off lb-add lb0 [[ae0f::10]]: [[fd0f::10]]:80,[[fd0f::20]]:80 tcp], [1], [],
829 [ovn-nbctl: Protocol is unnecessary when no port of vip is given.
830 ])
831
832
833 AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 fd0f::10 tcp], [1], [],
834 [ovn-nbctl: Protocol is unnecessary when no port of vip is given.
835 ])
836
837
838 AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 [[fd0f::10]]:900 tcp], [1], [],
839 [ovn-nbctl: Protocol is unnecessary when no port of vip is given.
840 ])
841
842 AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 192.168.10.10], [1], [],
843 [ovn-nbctl: 192.168.10.10: IP address family is different from VIP ae0f::10.
844 ])
845
846 AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 192.168.10.10], [1], [],
847 [ovn-nbctl: 192.168.10.10: IP address family is different from VIP ae0f::10.
848 ])
849
850 AT_CHECK([ovn-nbctl lb-add lb0 [[ae0f::10]]:80 192.168.10.10:80], [1], [],
851 [ovn-nbctl: 192.168.10.10:80: IP address family is different from VIP [[ae0f::10]]:80.
852 ])
853
854 AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10 ae0f::10], [1], [],
855 [ovn-nbctl: ae0f::10: IP address family is different from VIP 30.0.0.10.
856 ])
857
858 AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10:80 [[ae0f::10]]:80], [1], [],
859 [ovn-nbctl: [[ae0f::10]]:80: IP address family is different from VIP 30.0.0.10:80.
860 ])
861
862 AT_CHECK([ovn-nbctl lb-add lb0 ae0f::10 fd0f::10])
863 AT_CHECK([ovn-nbctl lb-add lb0 ae0f:0000:0000:0000:0000:0000:0000:0010 fd0f::20],
864 [1], [], [ovn-nbctl: lb0: a load balancer with this vip (ae0f::10) already exists
865 ])
866
867 AT_CHECK([ovn-nbctl lb-del lb0])
868
869 dnl Add ips to lb
870 AT_CHECK([ovn-nbctl lb-add lb0 [[ae0f::10]]:80 ,,,[[fd0f::10]]:80,,,,,])
871 AT_CHECK([ovn-nbctl lb-add lb1 [[ae0f::10]]:80 ,,,[[fd0f::10]]:80,,,,[[fd0f::20]]:80,,,,])
872 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
873 UUID LB PROTO VIP IPs
874 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80
875 <1> lb1 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
876 ])
877 AT_CHECK([ovn-nbctl lb-del lb0])
878 AT_CHECK([ovn-nbctl lb-del lb1])
879
880
881 AT_CHECK([ovn-nbctl lb-add lb0 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80])
882 AT_CHECK([ovn-nbctl lb-add lb1 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 tcp])
883 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
884 UUID LB PROTO VIP IPs
885 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
886 <1> lb1 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
887 ])
888
889 dnl Update the VIP of the lb1.
890 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080])
891 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
892 UUID LB PROTO VIP IPs
893 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
894 <1> lb1 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080
895 ])
896
897 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080 udp])
898 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
899 UUID LB PROTO VIP IPs
900 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
901 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080
902 ])
903
904 dnl Config lb1 with another VIP.
905 AT_CHECK([ovn-nbctl lb-add lb1 [[ae0f::20]]:80 [[fd0f::10]]:80 udp])
906 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
907 UUID LB PROTO VIP IPs
908 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
909 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080
910 udp [[ae0f::20]]:80 [[fd0f::10]]:80
911 ])
912
913 AT_CHECK([ovn-nbctl lb-del lb1 [[ae0f::20]]:80])
914 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
915 UUID LB PROTO VIP IPs
916 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
917 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080
918 ])
919
920 dnl Add LBs whose vip is just an IP address.
921 AT_CHECK([ovn-nbctl lb-add lb2 ae0f::30 fd0f::10])
922 AT_CHECK([ovn-nbctl lb-add lb3 ae0f::30 fd0f::10])
923 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
924 UUID LB PROTO VIP IPs
925 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
926 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080
927 <2> lb2 tcp/udp ae0f::30 fd0f::10
928 <3> lb3 tcp/udp ae0f::30 fd0f::10
929 ])
930 AT_CHECK([ovn-nbctl lb-del lb2 ae0f::30])
931 AT_CHECK([ovn-nbctl lb-del lb3 ae0f::30])
932
933 AT_CHECK([ovn-nbctl lb-add lb2 [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80 tcp])
934 AT_CHECK([ovn-nbctl --add-duplicate lb-add lb2 [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80 tcp])
935 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
936 UUID LB PROTO VIP IPs
937 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
938 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080
939 <2> lb2 tcp [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80
940 <3> lb2 tcp [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80
941 ])
942
943 dnl If there are multiple load balancers with the same name, use a UUID to update/delete.
944 AT_CHECK([ovn-nbctl lb-add lb2 [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80 tcp], [1], [],
945 [ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
946 ])
947
948 AT_CHECK([ovn-nbctl lb-del lb2], [1], [],
949 [ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
950 ])
951
952 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:80 [[fd0f::10]]:8080,[[fd0f::20]]:8080 udp])
953 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:8080 [[fd0f::10]]:8080,[[fd0f::20]]:8080 udp])
954 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:9090 [[fd0f::10]]:8080,[[fd0f::20]]:8080 udp])
955 AT_CHECK([ovn-nbctl lb-del lb0 [[ae0f::10]]:80])
956 AT_CHECK([ovn-nbctl lb-del lb1])
957 AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl
958 UUID LB PROTO VIP IPs
959 <0> lb2 tcp [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80
960 <1> lb2 tcp [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80
961 ])
962
963 dnl Add load balancer to logical switch.
964 AT_CHECK([ovn-nbctl ls-add ls0])
965 AT_CHECK([ovn-nbctl lb-add lb0 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80])
966 AT_CHECK([ovn-nbctl lb-add lb1 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 udp])
967 AT_CHECK([ovn-nbctl lb-add lb3 ae0f::10 fd0f::10,fd0f::20])
968 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb0])
969 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb1])
970 AT_CHECK([ovn-nbctl --may-exist ls-lb-add ls0 lb1])
971 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb2], [1], [],
972 [ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
973 ])
974 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb3])
975
976 AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [dnl
977 UUID LB PROTO VIP IPs
978 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
979 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
980 <2> lb3 tcp/udp ae0f::10 fd0f::10,fd0f::20
981 ])
982
983 AT_CHECK([ovn-nbctl ls-lb-del ls0 lb0])
984 AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [dnl
985 UUID LB PROTO VIP IPs
986 <0> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
987 <1> lb3 tcp/udp ae0f::10 fd0f::10,fd0f::20
988 ])
989
990 AT_CHECK([ovn-nbctl ls-lb-del ls0 lb1])
991 AT_CHECK([ovn-nbctl ls-lb-del ls0 lb3])
992 AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [])
993 AT_CHECK([ovn-nbctl --if-exists ls-lb-del ls0 lb1])
994
995 dnl Remove all load balancers from logical switch.
996 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb0])
997 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb1])
998 AT_CHECK([ovn-nbctl ls-lb-add ls0 lb3])
999 AT_CHECK([ovn-nbctl ls-lb-del ls0])
1000 AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [])
1001
1002 dnl Add load balancer to logical router.
1003 AT_CHECK([ovn-nbctl lr-add lr0])
1004 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb0])
1005 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb1])
1006 AT_CHECK([ovn-nbctl --may-exist lr-lb-add lr0 lb1])
1007 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb2], [1], [],
1008 [ovn-nbctl: Multiple load balancers named 'lb2'. Use a UUID.
1009 ])
1010 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb3])
1011
1012 AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [dnl
1013 UUID LB PROTO VIP IPs
1014 <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
1015 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
1016 <2> lb3 tcp/udp ae0f::10 fd0f::10,fd0f::20
1017 ])
1018
1019 AT_CHECK([ovn-nbctl lr-lb-del lr0 lb0])
1020 AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [dnl
1021 UUID LB PROTO VIP IPs
1022 <0> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80
1023 <1> lb3 tcp/udp ae0f::10 fd0f::10,fd0f::20
1024 ])
1025
1026 AT_CHECK([ovn-nbctl lr-lb-del lr0 lb1])
1027 AT_CHECK([ovn-nbctl lr-lb-del lr0 lb3])
1028 AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [])
1029 AT_CHECK([ovn-nbctl --if-exists lr-lb-del lr0 lb1])
1030
1031 dnl Remove all load balancers from logical router.
1032 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb0])
1033 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb1])
1034 AT_CHECK([ovn-nbctl lr-lb-add lr0 lb3])
1035 AT_CHECK([ovn-nbctl lr-lb-del lr0])
1036 AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [])])
1037
1038 dnl ---------------------------------------------------------------------
1039
1040 OVN_NBCTL_TEST([ovn_nbctl_basic_lr], [basic logical router commands], [
1041 AT_CHECK([ovn-nbctl lr-add lr0])
1042 AT_CHECK([ovn-nbctl lr-list | uuidfilt], [0], [dnl
1043 <0> (lr0)
1044 ])
1045
1046 AT_CHECK([ovn-nbctl lr-add lr1])
1047 AT_CHECK([ovn-nbctl lr-list | uuidfilt], [0], [dnl
1048 <0> (lr0)
1049 <1> (lr1)
1050 ])
1051
1052 AT_CHECK([ovn-nbctl lr-del lr0])
1053 AT_CHECK([ovn-nbctl lr-list | uuidfilt], [0], [dnl
1054 <0> (lr1)
1055 ])
1056
1057 AT_CHECK([ovn-nbctl show lr0])
1058 AT_CHECK([ovn-nbctl lr-add lr0])
1059 AT_CHECK([ovn-nbctl show lr0 | uuidfilt], [0],
1060 [router <0> (lr0)
1061 ])
1062 AT_CHECK([ovn-nbctl lr-add lr0], [1], [],
1063 [ovn-nbctl: lr0: a router with this name already exists
1064 ])
1065 AT_CHECK([ovn-nbctl --may-exist lr-add lr0])
1066 AT_CHECK([ovn-nbctl show lr0 | uuidfilt], [0],
1067 [router <0> (lr0)
1068 ])
1069 AT_CHECK([ovn-nbctl --add-duplicate lr-add lr0])
1070 AT_CHECK([ovn-nbctl --may-exist --add-duplicate lr-add lr0], [1], [],
1071 [ovn-nbctl: --may-exist and --add-duplicate may not be used together
1072 ])
1073 AT_CHECK([ovn-nbctl lr-del lr0], [1], [],
1074 [ovn-nbctl: Multiple logical routers named 'lr0'. Use a UUID.
1075 ])
1076
1077 AT_CHECK([ovn-nbctl lr-del lr2], [1], [],
1078 [ovn-nbctl: lr2: router name not found
1079 ])
1080 AT_CHECK([ovn-nbctl --if-exists lr-del lr2])
1081
1082 AT_CHECK([ovn-nbctl lr-add])
1083 AT_CHECK([ovn-nbctl lr-add])
1084 AT_CHECK([ovn-nbctl --add-duplicate lr-add], [1], [],
1085 [ovn-nbctl: --add-duplicate requires specifying a name
1086 ])
1087 AT_CHECK([ovn-nbctl --may-exist lr-add], [1], [],
1088 [ovn-nbctl: --may-exist requires specifying a name
1089 ])])
1090
1091 dnl ---------------------------------------------------------------------
1092
1093 OVN_NBCTL_TEST([ovn_nbctl_basic_lrp], [basic logical router port commands], [
1094 AT_CHECK([ovn-nbctl lr-add lr0])
1095 AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02 192.168.1.1/24], [1], [],
1096 [ovn-nbctl: lrp0: invalid mac address 00:00:00:01:02
1097 ])
1098 AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03:04 192.168.1.1/24], [1], [],
1099 [ovn-nbctl: lrp0: invalid mac address 00:00:00:01:02:03:04
1100 ])
1101
1102 AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24])
1103
1104 AT_CHECK([ovn-nbctl show lr0 | uuidfilt], [0], [dnl
1105 router <0> (lr0)
1106 port lrp0
1107 mac: "00:00:00:01:02:03"
1108 networks: [["192.168.1.1/24"]]
1109 ])
1110
1111 AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24], [1], [],
1112 [ovn-nbctl: lrp0: a port with this name already exists
1113 ])
1114 AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24])
1115 AT_CHECK([ovn-nbctl lrp-list lr0 | uuidfilt], [0], [dnl
1116 <0> (lrp0)
1117 ])
1118
1119 AT_CHECK([ovn-nbctl lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24 peer=lrp1-peer])
1120 AT_CHECK([ovn-nbctl lrp-list lr0 | uuidfilt], [0], [dnl
1121 <0> (lrp0)
1122 <1> (lrp1)
1123 ])
1124
1125 AT_CHECK([ovn-nbctl lr-add lr1])
1126 AT_CHECK([ovn-nbctl lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24], [1], [],
1127 [ovn-nbctl: lrp1: a port with this name already exists
1128 ])
1129
1130 AT_CHECK([ovn-nbctl --may-exist lrp-add lr1 lrp1 00:00:00:01:02:03 192.168.1.1/24], [1], [],
1131 [ovn-nbctl: lrp1: port already exists but in router lr0
1132 ])
1133
1134 AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:04:05:06 192.168.1.1/24], [1], [],
1135 [ovn-nbctl: lrp1: port already exists with mac 00:00:00:01:02:03
1136 ])
1137
1138 AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24], [1], [],
1139 [ovn-nbctl: lrp1: port already exists with mismatching peer
1140 ])
1141
1142 AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 10.0.0.1/24 peer=lrp1-peer], [1], [],
1143 [ovn-nbctl: lrp1: port already exists with different network
1144 ])
1145
1146 AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24 peer=lrp1-peer])
1147
1148 AT_CHECK([ovn-nbctl lrp-del lrp1])
1149 AT_CHECK([ovn-nbctl lrp-list lr0 | uuidfilt], [0], [dnl
1150 <0> (lrp0)
1151 ])
1152
1153 AT_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])
1154
1155 AT_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], [],
1156 [ovn-nbctl: lrp1: port already exists with different network
1157 ])
1158
1159 AT_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])])
1160
1161 dnl ---------------------------------------------------------------------
1162
1163 OVN_NBCTL_TEST([ovn_nbctl_lrp_gw_chassi], [logical router port gateway chassis], [
1164 AT_CHECK([ovn-nbctl lr-add lr0])
1165 AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24])
1166 AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [])
1167
1168 AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lp0 chassis1], [1], [],
1169 [ovn-nbctl: lp0: port name not found
1170 ])
1171
1172 AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lp0], [1], [],
1173 [ovn-nbctl: lp0: port name not found
1174 ])
1175
1176 AT_CHECK([ovn-nbctl lrp-del-gateway-chassis lp0 chassis1], [1], [],
1177 [ovn-nbctl: lp0: port name not found
1178 ])
1179
1180 AT_CHECK([ovn-nbctl lrp-del-gateway-chassis lrp0 chassis1], [1], [],
1181 [ovn-nbctl: chassis chassis1 is not added to logical port lrp0
1182 ])
1183 AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis1])
1184
1185 AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl
1186 lrp0-chassis1 0
1187 ])
1188 AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis1 10])
1189
1190 AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl
1191 lrp0-chassis1 10
1192 ])
1193 AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis1 20])
1194
1195 AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl
1196 lrp0-chassis1 20
1197 ])
1198 AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis2 5])
1199 AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl
1200 lrp0-chassis1 20
1201 lrp0-chassis2 5
1202 ])
1203
1204 AT_CHECK([ovn-nbctl lrp-del-gateway-chassis lrp0 chassis1])
1205 AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl
1206 lrp0-chassis2 5
1207 ])
1208
1209 AT_CHECK([ovn-nbctl lrp-del-gateway-chassis lrp0 chassis2])
1210 AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0])
1211
1212 AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis1 1])
1213 AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis2 10])
1214 AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis3 5])
1215 AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl
1216 lrp0-chassis2 10
1217 lrp0-chassis3 5
1218 lrp0-chassis1 1
1219 ])])
1220
1221 dnl ---------------------------------------------------------------------
1222
1223 OVN_NBCTL_TEST([ovn_nbctl_lrp_enable], [logical router port enable and disable], [
1224 AT_CHECK([ovn-nbctl lr-add lr0])
1225 AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24])
1226 AT_CHECK([ovn-nbctl lrp-get-enabled lrp0], [0], [enabled
1227 ])
1228
1229 AT_CHECK([ovn-nbctl lrp-set-enabled lrp0 disabled])
1230 AT_CHECK([ovn-nbctl lrp-get-enabled lrp0], [0], [disabled
1231 ])
1232
1233 AT_CHECK([ovn-nbctl lrp-set-enabled lrp0 enabled])
1234 AT_CHECK([ovn-nbctl lrp-get-enabled lrp0], [0], [enabled
1235 ])
1236
1237 AT_CHECK([ovn-nbctl lrp-set-enabled lrp0 xyzzy], [1], [],
1238 [ovn-nbctl: xyzzy: state must be "enabled" or "disabled"
1239 ])])
1240
1241 dnl ---------------------------------------------------------------------
1242
1243 OVN_NBCTL_TEST([ovn_nbctl_routes], [routes], [
1244 AT_CHECK([ovn-nbctl lr-add lr0])
1245
1246 dnl Check IPv4 routes
1247 AT_CHECK([ovn-nbctl lr-route-add lr0 0.0.0.0/0 192.168.0.1])
1248 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.1.0/24 11.0.1.1 lp0])
1249 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.1/24 11.0.0.2])
1250
1251 dnl Add overlapping route with 10.0.0.1/24
1252 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24 11.0.0.1], [1], [],
1253 [ovn-nbctl: duplicate prefix: 10.0.0.0/24
1254 ])
1255 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111a/24 11.0.0.1], [1], [],
1256 [ovn-nbctl: bad prefix argument: 10.0.0.111a/24
1257 ])
1258 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24a 11.0.0.1], [1], [],
1259 [ovn-nbctl: bad prefix argument: 10.0.0.111/24a
1260 ])
1261 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24 11.0.0.1a], [1], [],
1262 [ovn-nbctl: bad next hop argument: 11.0.0.1a
1263 ])
1264 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24 11.0.0.1/24], [1], [],
1265 [ovn-nbctl: bad IPv4 nexthop argument: 11.0.0.1/24
1266 ])
1267 AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:1::/64 2001:0db8:0:f103::1/64], [1], [],
1268 [ovn-nbctl: bad IPv6 nexthop argument: 2001:0db8:0:f103::1/64
1269 ])
1270
1271 AT_CHECK([ovn-nbctl --may-exist lr-route-add lr0 10.0.0.111/24 11.0.0.1])
1272 AT_CHECK([ovn-nbctl --policy=src-ip lr-route-add lr0 9.16.1.0/24 11.0.0.1])
1273
1274 AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1275 IPv4 Routes
1276 10.0.0.0/24 11.0.0.1 dst-ip
1277 10.0.1.0/24 11.0.1.1 dst-ip lp0
1278 9.16.1.0/24 11.0.0.1 src-ip
1279 0.0.0.0/0 192.168.0.1 dst-ip
1280 ])
1281
1282 AT_CHECK([ovn-nbctl --may-exist lr-route-add lr0 10.0.0.111/24 11.0.0.1 lp1])
1283 AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1284 IPv4 Routes
1285 10.0.0.0/24 11.0.0.1 dst-ip lp1
1286 10.0.1.0/24 11.0.1.1 dst-ip lp0
1287 9.16.1.0/24 11.0.0.1 src-ip
1288 0.0.0.0/0 192.168.0.1 dst-ip
1289 ])
1290
1291 dnl Delete non-existent prefix
1292 AT_CHECK([ovn-nbctl lr-route-del lr0 10.0.2.1/24], [1], [],
1293 [ovn-nbctl: no matching prefix: 10.0.2.0/24
1294 ])
1295 AT_CHECK([ovn-nbctl --if-exists lr-route-del lr0 10.0.2.1/24])
1296
1297 AT_CHECK([ovn-nbctl lr-route-del lr0 10.0.1.1/24])
1298 AT_CHECK([ovn-nbctl lr-route-del lr0 9.16.1.0/24])
1299
1300 AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1301 IPv4 Routes
1302 10.0.0.0/24 11.0.0.1 dst-ip lp1
1303 0.0.0.0/0 192.168.0.1 dst-ip
1304 ])
1305
1306 AT_CHECK([ovn-nbctl lr-route-del lr0])
1307 AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1308 ])
1309
1310 dnl Check IPv6 routes
1311 AT_CHECK([ovn-nbctl lr-route-add lr0 0:0:0:0:0:0:0:0/0 2001:0db8:0:f101::1])
1312 AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:0::/64 2001:0db8:0:f102::1 lp0])
1313 AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:1::/64 2001:0db8:0:f103::1])
1314
1315 AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1316 IPv6 Routes
1317 2001:db8::/64 2001:db8:0:f102::1 dst-ip lp0
1318 2001:db8:1::/64 2001:db8:0:f103::1 dst-ip
1319 ::/0 2001:db8:0:f101::1 dst-ip
1320 ])
1321
1322 AT_CHECK([ovn-nbctl lr-route-del lr0 2001:0db8:0::/64])
1323
1324 AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1325 IPv6 Routes
1326 2001:db8:1::/64 2001:db8:0:f103::1 dst-ip
1327 ::/0 2001:db8:0:f101::1 dst-ip
1328 ])
1329
1330 AT_CHECK([ovn-nbctl lr-route-del lr0])
1331 AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1332 ])
1333
1334 dnl Check IPv4 and IPv6 routes
1335 AT_CHECK([ovn-nbctl lr-route-add lr0 0.0.0.0/0 192.168.0.1])
1336 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.1.1/24 11.0.1.1 lp0])
1337 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.1/24 11.0.0.1])
1338 AT_CHECK([ovn-nbctl lr-route-add lr0 0:0:0:0:0:0:0:0/0 2001:0db8:0:f101::1])
1339 AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:0::/64 2001:0db8:0:f102::1 lp0])
1340 AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:1::/64 2001:0db8:0:f103::1])
1341
1342 AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl
1343 IPv4 Routes
1344 10.0.0.0/24 11.0.0.1 dst-ip
1345 10.0.1.0/24 11.0.1.1 dst-ip lp0
1346 0.0.0.0/0 192.168.0.1 dst-ip
1347
1348 IPv6 Routes
1349 2001:db8::/64 2001:db8:0:f102::1 dst-ip lp0
1350 2001:db8:1::/64 2001:db8:0:f103::1 dst-ip
1351 ::/0 2001:db8:0:f101::1 dst-ip
1352 ])])
1353
1354 dnl ---------------------------------------------------------------------
1355
1356 OVN_NBCTL_TEST([ovn_nbctl_policies], [policies], [
1357 AT_CHECK([ovn-nbctl lr-add lr0])
1358
1359 dnl Add policies with allow and drop actions
1360 AT_CHECK([ovn-nbctl lr-policy-add lr0 100 "ip4.src == 1.1.1.0/24" drop])
1361 AT_CHECK([ovn-nbctl lr-policy-add lr0 100 "ip4.src == 1.1.2.0/24" allow])
1362 AT_CHECK([ovn-nbctl lr-policy-add lr0 101 "ip4.src == 2.1.1.0/24" allow])
1363 AT_CHECK([ovn-nbctl lr-policy-add lr0 101 "ip4.src == 2.1.2.0/24" drop])
1364 AT_CHECK([ovn-nbctl lr-policy-add lr0 101 "ip6.src == 2002::/64" drop])
1365
1366 dnl Add duplicated policy
1367 AT_CHECK([ovn-nbctl lr-policy-add lr0 100 "ip4.src == 1.1.1.0/24" drop], [1], [],
1368 [ovn-nbctl: Same routing policy already existed on the logical router lr0.
1369 ])
1370
1371 dnl Add duplicated policy
1372 AT_CHECK([ovn-nbctl lr-policy-add lr0 103 "ip4.src == 1.1.1.0/24" deny], [1], [],
1373 [ovn-nbctl: deny: action must be one of "allow", "drop", and "reroute"
1374 ])
1375
1376 dnl Delete by priority and match string
1377 AT_CHECK([ovn-nbctl lr-policy-del lr0 100 "ip4.src == 1.1.1.0/24"])
1378 AT_CHECK([ovn-nbctl lr-policy-list lr0], [0], [dnl
1379 Routing Policies
1380 101 ip4.src == 2.1.1.0/24 allow
1381 101 ip4.src == 2.1.2.0/24 drop
1382 101 ip6.src == 2002::/64 drop
1383 100 ip4.src == 1.1.2.0/24 allow
1384 ])
1385
1386 dnl Delete all policies for given priority
1387 AT_CHECK([ovn-nbctl lr-policy-del lr0 101])
1388 AT_CHECK([ovn-nbctl lr-policy-list lr0], [0], [dnl
1389 Routing Policies
1390 100 ip4.src == 1.1.2.0/24 allow
1391 ])
1392
1393 dnl Add policy with reroute action
1394 AT_CHECK([ovn-nbctl lr-policy-add lr0 102 "ip4.src == 3.1.2.0/24" reroute 3.3.3.3])
1395
1396 dnl Add policy with invalid reroute ip
1397 AT_CHECK([ovn-nbctl lr-policy-add lr0 103 "ip4.src == 3.1.2.0/24" reroute 3.3.3.x], [1], [],
1398 [ovn-nbctl: bad next hop argument: 3.3.3.x
1399 ])
1400
1401 dnl Add policy with reroute action
1402 AT_CHECK([ovn-nbctl lr-policy-add lr0 104 "ip6.src == 2001::/64" reroute 2002::5])
1403
1404 dnl Add policy with invalid reroute ip
1405 AT_CHECK([ovn-nbctl lr-policy-add lr0 105 "ip6.src == 2001::/64" reroute 2002::x], [1], [],
1406 [ovn-nbctl: bad next hop argument: 2002::x
1407 ])
1408
1409 ])
1410
1411 dnl ---------------------------------------------------------------------
1412
1413 OVN_NBCTL_TEST([ovn_nbctl_lsp_types], [lsp types], [
1414 AT_CHECK([ovn-nbctl ls-add ls0])
1415 AT_CHECK([ovn-nbctl lsp-add ls0 lp0])
1416
1417 dnl switchport type defaults to empty
1418 AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1419
1420 ])
1421
1422 dnl The following are the valid entries for
1423 dnl switchport type
1424 AT_CHECK([ovn-nbctl lsp-set-type lp0 l2gateway])
1425 AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1426 l2gateway
1427 ])
1428
1429 AT_CHECK([ovn-nbctl lsp-set-type lp0 router])
1430 AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1431 router
1432 ])
1433
1434 AT_CHECK([ovn-nbctl lsp-set-type lp0 localnet])
1435 AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1436 localnet
1437 ])
1438
1439 AT_CHECK([ovn-nbctl lsp-set-type lp0 localport])
1440 AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1441 localport
1442 ])
1443
1444 AT_CHECK([ovn-nbctl lsp-set-type lp0 vtep])
1445 AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1446 vtep
1447 ])
1448
1449 dnl All of these are valid southbound port types but
1450 dnl should be rejected for northbound logical switch
1451 dnl ports.
1452 AT_CHECK([ovn-nbctl lsp-set-type lp0 l3gateway], [1], [], [dnl
1453 ovn-nbctl: Logical switch port type 'l3gateway' is unrecognized. Not setting type.
1454 ])
1455 AT_CHECK([ovn-nbctl lsp-set-type lp0 patch], [1], [], [dnl
1456 ovn-nbctl: Logical switch port type 'patch' is unrecognized. Not setting type.
1457 ])
1458 AT_CHECK([ovn-nbctl lsp-set-type lp0 chassisredirect], [1], [], [dnl
1459 ovn-nbctl: Logical switch port type 'chassisredirect' is unrecognized. Not setting type.
1460 ])
1461
1462 dnl switch port type should still be "vtep" since previous
1463 dnl commands failed.
1464 AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1465 vtep
1466 ])
1467
1468 dnl Attempt a nonsense type
1469 AT_CHECK([ovn-nbctl lsp-set-type lp0 eggs], [1], [], [dnl
1470 ovn-nbctl: Logical switch port type 'eggs' is unrecognized. Not setting type.
1471 ])
1472
1473 dnl Empty string should work too
1474 AT_CHECK([ovn-nbctl lsp-set-type lp0 ""])
1475 AT_CHECK([ovn-nbctl lsp-get-type lp0], [0], [dnl
1476
1477 ])])
1478
1479 dnl ---------------------------------------------------------------------
1480
1481 OVN_NBCTL_TEST([ovn_nbctl_connection], [connection], [
1482 AT_CHECK([ovn-nbctl --inactivity-probe=30000 set-connection ptcp:6641:127.0.0.1 punix:$OVS_RUNDIR/ovnnb_db.sock])
1483 AT_CHECK([ovn-nbctl list connection | grep inactivity_probe], [0], [dnl
1484 inactivity_probe : 30000
1485 inactivity_probe : 30000
1486 ])])
1487
1488 dnl ---------------------------------------------------------------------
1489
1490 OVN_NBCTL_TEST([ovn_nbctl_dry_run_mode], [dry run mode], [
1491 dnl Check that dry run has no permanent effect.
1492 AT_CHECK([ovn-nbctl --dry-run ls-add ls0 -- ls-list | uuidfilt], [0], [dnl
1493 <0> (ls0)
1494 ])
1495 AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl
1496 ])
1497
1498 dnl Check that dry-run mode is not sticky.
1499 AT_CHECK([ovn-nbctl ls-add ls0])
1500 AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl
1501 <0> (ls0)
1502 ])])
1503
1504 dnl ---------------------------------------------------------------------
1505
1506 OVN_NBCTL_TEST([ovn_nbctl_oneline_output], [oneline output], [
1507 AT_CHECK([ovn-nbctl ls-add ls0 -- ls-add ls1])
1508
1509 dnl Expect one line for one command.
1510 AT_CHECK([ovn-nbctl --oneline ls-list | uuidfilt], [0], [dnl
1511 <0> (ls0)\n<1> (ls1)
1512 ])
1513
1514 dnl Expect lines for two commands.
1515 AT_CHECK([ovn-nbctl --oneline ls-list -- ls-list | uuidfilt], [0], [dnl
1516 <0> (ls0)\n<1> (ls1)
1517 <0> (ls0)\n<1> (ls1)
1518 ])])
1519
1520 dnl ---------------------------------------------------------------------
1521
1522 OVN_NBCTL_TEST([ovn_nbctl_error_paths], [commands parser error paths], [
1523 dnl FIXME: Duplicate options are allowed when passed with global options.
1524 dnl For example: ovn-nbctl --if-exists --if-exists list Logical_Switch
1525
1526 dnl Duplicate option
1527 AT_CHECK([ovn-nbctl -- --if-exists --if-exists list Logical_Switch], [1], [], [stderr])
1528 AT_CHECK([grep 'option specified multiple times' stderr], [0], [ignore])
1529
1530 dnl Missing command
1531 AT_CHECK([ovn-nbctl], [1], [], [stderr])
1532 AT_CHECK([grep 'missing command name' stderr], [0], [ignore])
1533
1534 AT_CHECK([ovn-nbctl --if-exists], [1], [], [stderr])
1535 AT_CHECK([grep 'missing command name' stderr], [0], [ignore])
1536
1537 AT_CHECK([ovn-nbctl --], [1], [], [stderr])
1538 AT_CHECK([grep 'missing command name' stderr], [0], [ignore])
1539
1540 AT_CHECK([ovn-nbctl -- --if-exists], [1], [], [stderr])
1541 AT_CHECK([grep 'missing command name' stderr], [0], [ignore])
1542
1543 dnl Unknown command
1544 AT_CHECK([ovn-nbctl foo], [1], [], [stderr])
1545 AT_CHECK([grep 'unknown command' stderr], [0], [ignore])
1546
1547 AT_CHECK([ovn-nbctl -- foo], [1], [], [stderr])
1548 AT_CHECK([grep 'unknown command' stderr], [0], [ignore])
1549
1550 dnl Unknown option
1551 AT_CHECK([ovn-nbctl --foo list Logical_Switch], [1], [], [stderr])
1552 AT_CHECK([grep 'unrecognized option' stderr], [0], [ignore])
1553
1554 AT_CHECK([ovn-nbctl -- --foo list Logical_Switch], [1], [], [stderr])
1555 AT_CHECK([grep 'command has no .* option' stderr], [0], [ignore])
1556
1557 dnl Missing option argument
1558 AT_CHECK([ovn-nbctl --columns], [1], [], [stderr])
1559 AT_CHECK([grep 'option .* requires an argument' stderr], [0], [ignore])
1560
1561 AT_CHECK([ovn-nbctl -- --columns list Logical_Switch], [1], [], [stderr])
1562 AT_CHECK([grep 'missing argument to .* option' stderr], [0], [ignore])
1563
1564 dnl Unexpected option argument
1565 AT_CHECK([ovn-nbctl --if-exists=foo list Logical_Switch], [1], [], [stderr])
1566 AT_CHECK([egrep 'option .* doesn'\''t allow an argument|option .* requires an argument' stderr], [0], [ignore])
1567
1568 AT_CHECK([ovn-nbctl -- --if-exists=foo list Logical_Switch], [1], [], [stderr])
1569 AT_CHECK([grep 'option on .* does not accept an argument' stderr], [0], [ignore])
1570
1571 dnl Not enough arguments
1572 AT_CHECK([ovn-nbctl list], [1], [], [stderr])
1573 AT_CHECK([grep 'command requires at least .* arguments' stderr], [0], [ignore])
1574
1575 AT_CHECK([ovn-nbctl -- list], [1], [], [stderr])
1576 AT_CHECK([grep 'command requires at least .* arguments' stderr], [0], [ignore])
1577
1578 dnl Too many arguments
1579 AT_CHECK([ovn-nbctl show foo bar], [1], [], [stderr])
1580 AT_CHECK([grep 'command takes at most .* arguments' stderr], [0], [ignore])
1581
1582 AT_CHECK([ovn-nbctl -- show foo bar], [1], [], [stderr])
1583 AT_CHECK([grep 'command takes at most .* arguments' stderr], [0], [ignore])
1584
1585 AT_CHECK([ovn-nbctl show foo --bar], [1], [], [stderr])
1586 AT_CHECK([grep 'command takes at most .* arguments' stderr], [0], [ignore])
1587
1588 AT_CHECK([ovn-nbctl -- show foo --bar], [1], [], [stderr])
1589 AT_CHECK([grep 'command takes at most .* arguments' stderr], [0], [ignore])])
1590
1591 dnl ---------------------------------------------------------------------
1592
1593 OVN_NBCTL_TEST([ovn_nbctl_port_groups], [port groups], [
1594 dnl Check that port group can be looked up by name
1595 AT_CHECK([ovn-nbctl create Port_Group name=pg0], [0], [ignore])
1596 AT_CHECK([ovn-nbctl get Port_Group pg0 name], [0], [dnl
1597 "pg0"
1598 ])])
1599
1600 OVN_NBCTL_TEST([ovn_nbctl_extra_newlines], [extra newlines], [
1601 dnl This test addresses a specific issue seen when running ovn-nbctl in
1602 dnl daemon mode. All we have to do is ensure that each time we list database
1603 dnl information, there is not an extra newline at the beginning of the output.
1604 AT_CHECK([ovn-nbctl ls-add sw1], [0], [ignore])
1605 AT_CHECK([ovn-nbctl --columns=name list logical_switch sw1], [0], [dnl
1606 name : "sw1"
1607 ])
1608 AT_CHECK([ovn-nbctl --columns=name list logical_switch sw1], [0], [dnl
1609 name : "sw1"
1610 ])])
1611
1612 OVN_NBCTL_TEST([ovn_nbctl_table_formatting], [table formatting], [
1613 dnl This test addresses a specific issue seen when running ovn-nbctl in
1614 dnl daemon mode. We need to ensure that table formatting options are honored
1615 dnl when listing database information.
1616 AT_CHECK([ovn-nbctl ls-add sw1], [0], [ignore])
1617 AT_CHECK([ovn-nbctl --bare --columns=name list logical_switch sw1], [0], [dnl
1618 sw1
1619 ])])
1620 dnl ---------------------------------------------------------------------
1621
1622 OVN_NBCTL_TEST([ovn_nbctl_port_group_commands], [port group commands], [
1623 AT_CHECK([ovn-nbctl pg-add pg1], [0], [ignore])
1624 AT_CHECK([ovn-nbctl --bare --columns=name list port_group pg1], [0],
1625 [pg1
1626 ])
1627
1628 AT_CHECK([ovn-nbctl pg-del pg1], [0], [ignore])
1629 AT_CHECK([ovn-nbctl list port_group], [0], [])
1630
1631 AT_CHECK([ovn-nbctl ls-add sw1], [0], [ignore])
1632 AT_CHECK([ovn-nbctl lsp-add sw1 sw1-p1], [0], [ignore])
1633 SW1P1=$(ovn-nbctl --bare --columns=_uuid list logical_switch_port sw1-p1)
1634 AT_CHECK([ovn-nbctl lsp-add sw1 sw1-p2], [0], [ignore])
1635 SW1P2=$(ovn-nbctl --bare --columns=_uuid list logical_switch_port sw1-p2)
1636
1637 AT_CHECK([ovn-nbctl pg-add pg1 sw1-p1], [0], [ignore])
1638 AT_CHECK([ovn-nbctl --bare --columns=name list port_group pg1], [0],[dnl
1639 pg1
1640 ])
1641 AT_CHECK_UNQUOTED([ovn-nbctl --bare --columns=ports list port_group pg1], [0], [dnl
1642 $SW1P1
1643 ])
1644
1645 AT_CHECK([ovn-nbctl pg-set-ports pg1 sw1-p2], [0], [ignore])
1646 AT_CHECK_UNQUOTED([ovn-nbctl --bare --columns=ports list port_group pg1], [0], [dnl
1647 $SW1P2
1648 ])
1649
1650 AT_CHECK([ovn-nbctl pg-del pg1], [0], [ignore])
1651 AT_CHECK([ovn-nbctl list port_group], [0], [])
1652 ])
1653
1654 AT_SETUP([ovn-nbctl - daemon retry connection])
1655 OVN_NBCTL_TEST_START daemon
1656 AT_CHECK([kill `cat ovsdb-server.pid`])
1657 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/ovnnb_db.sock ovn-nb.db], [0], [], [stderr])
1658 AT_CHECK([ovn-nbctl show], [0], [ignore])
1659 OVN_NBCTL_TEST_STOP /Terminated/d
1660 AT_CLEANUP