3 dnl Creates an empty database in the current directory and then starts
4 dnl an ovsdb-server on it for ovs-vsctl to connect to.
5 m4_define([OVS_VSCTL_SETUP],
7 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db >/dev/null 2>&1], [0], [ignore], [ignore])
8 on_exit 'kill `cat ovsdb-server.pid`'])
12 dnl Kills off the database server.
13 m4_define([OVS_VSCTL_CLEANUP], [OVS_APP_EXIT_AND_WAIT_BY_TARGET([ovsdb-server], [ovsdb-server.pid])])
15 dnl RUN_OVS_VSCTL(COMMAND, ...)
17 dnl Executes each ovs-vsctl COMMAND.
18 m4_define([RUN_OVS_VSCTL],
19 [m4_foreach([command], [$@], [ovs-vsctl --no-wait -vreconnect:emer --db=unix:socket command
21 m4_define([RUN_OVS_VSCTL_ONELINE],
22 [m4_foreach([command], [$@], [ovs-vsctl --no-wait -vreconnect:emer --db=unix:socket --oneline -- command
25 dnl RUN_OVS_VSCTL_TOGETHER(COMMAND, ...)
27 dnl Executes each ovs-vsctl COMMAND in a single run of ovs-vsctl.
28 m4_define([RUN_OVS_VSCTL_TOGETHER],
29 [ovs-vsctl --no-wait -vreconnect:emer --db=unix:socket --oneline dnl
30 m4_foreach([command], [$@], [ -- command])])
32 dnl CHECK_BRIDGES([BRIDGE, PARENT, VLAN], ...)
34 dnl Verifies that "ovs-vsctl list-br" prints the specified list of bridges,
35 dnl which must be in alphabetical order. Also checks that each BRIDGE has the
36 dnl specified PARENT and is on the given VLAN.
37 m4_define([_CHECK_BRIDGE],
38 [AT_CHECK([RUN_OVS_VSCTL([br-to-parent $1])], [0], [$2
39 ], [], [OVS_VSCTL_CLEANUP])
41 # Check br-to-vlan, without --oneline.
42 AT_CHECK([RUN_OVS_VSCTL([br-to-vlan $1])], [0], [$3
43 ], [], [OVS_VSCTL_CLEANUP])
44 # Check br-to-vlan, with --oneline.
45 # (This particular test is interesting with --oneline because it returns
46 # an integer instead of a string and that can cause type mismatches inside
47 # python if not done carefully.)
48 AT_CHECK([RUN_OVS_VSCTL_ONELINE([br-to-vlan $1])], [0], [$3
49 ], [], [OVS_VSCTL_CLEANUP])
51 # Check multiple queries in a single run.
52 AT_CHECK([RUN_OVS_VSCTL_TOGETHER([br-to-parent $1], [br-to-vlan $1])], [0],
55 ], [], [OVS_VSCTL_CLEANUP])])
56 m4_define([CHECK_BRIDGES],
57 [dnl Check that the bridges appear on list-br, without --oneline.
59 [RUN_OVS_VSCTL([list-br])],
61 [m4_foreach([brinfo], [$@], [m4_car(brinfo)
66 dnl Check that the bridges appear on list-br, with --oneline.
68 [RUN_OVS_VSCTL_ONELINE([list-br])],
70 [m4_join([\n], m4_foreach([brinfo], [$@], [m4_car(brinfo),]))
75 dnl Check that each bridge exists according to br-exists and that
76 dnl a bridge that should not exist does not.
77 m4_foreach([brinfo], [$@],
78 [AT_CHECK([RUN_OVS_VSCTL([br-exists m4_car(brinfo)])], [0], [],
79 [], [OVS_VSCTL_CLEANUP])])
80 AT_CHECK([RUN_OVS_VSCTL([br-exists nonexistent])], [2], [], [],
83 dnl Check that each bridge has the expected parent and VLAN.
84 m4_map([_CHECK_BRIDGE], [$@])])
86 dnl CHECK_PORTS(BRIDGE, PORT[, PORT...])
88 dnl Verifies that "ovs-vsctl list-ports BRIDGE" prints the specified
89 dnl list of ports, which must be in alphabetical order. Also checks
90 dnl that "ovs-vsctl port-to-br" reports that each port is
92 m4_define([CHECK_PORTS],
93 [dnl Check ports without --oneline.
95 [RUN_OVS_VSCTL([list-ports $1])],
97 [m4_foreach([port], m4_cdr($@), [port
102 dnl Check ports with --oneline.
104 [RUN_OVS_VSCTL_ONELINE([list-ports $1])],
106 [m4_join([\n], m4_shift($@))
110 AT_CHECK([RUN_OVS_VSCTL([port-to-br $1])], [1], [],
111 [ovs-vsctl: no port named $1
116 [AT_CHECK([RUN_OVS_VSCTL([[port-to-br] port])], [0], [$1
117 ], [], [OVS_VSCTL_CLEANUP])])])
119 dnl CHECK_IFACES(BRIDGE, IFACE[, IFACE...])
121 dnl Verifies that "ovs-vsctl list-ifaces BRIDGE" prints the specified
122 dnl list of ifaces, which must be in alphabetical order. Also checks
123 dnl that "ovs-vsctl iface-to-br" reports that each interface is
125 m4_define([CHECK_IFACES],
127 [RUN_OVS_VSCTL([list-ifaces $1])],
129 [m4_foreach([iface], m4_cdr($@), [iface
133 AT_CHECK([RUN_OVS_VSCTL([iface-to-br $1])], [1], [],
134 [ovs-vsctl: no interface named $1
139 [AT_CHECK([RUN_OVS_VSCTL([[iface-to-br] iface])], [0], [$1
141 [], [OVS_VSCTL_CLEANUP])])])
143 dnl ----------------------------------------------------------------------
144 AT_BANNER([ovs-vsctl unit tests])
146 AT_SETUP([ovs-vsctl connection retry])
147 dnl Without --retry, there should be no retry for active connections.
148 AT_CHECK([ovs-vsctl --db=unix:foo --timeout=10 -vreconnect:emer -- init],
150 AT_CHECK([[sed 's/([^()]*)/(...reason...)/' stderr]], [0],
151 [ovs-vsctl: unix:foo: database connection failed (...reason...)
154 dnl With --retry, we should retry for active connections.
156 [ovs-vsctl --db=unix:foo --timeout=1 --retry -vreconnect:emer -vPATTERN:console:'%c|%p|%m' -- init
159 AT_CHECK([grep -c 'terminating with signal' stderr], [0], [1
161 if test "$IS_WIN32" = "yes"; then
162 AT_CHECK([cat status], [0], [3
166 AT_CHECK([cat status], [0], [142
170 dnl Without --retry, we should retry for passive connections.
172 [ovs-vsctl --db=punix:foo --timeout=1 -vreconnect:emer -vPATTERN:console:'%c|%p|%m' -- init
175 AT_CHECK([grep -c 'terminating with signal' stderr], [0], [1
177 if test "$IS_WIN32" = "yes"; then
178 AT_CHECK([cat status], [0], [3
182 AT_CHECK([cat status], [0], [142
187 dnl ----------------------------------------------------------------------
188 AT_BANNER([ovs-vsctl unit tests -- real bridges])
191 AT_KEYWORDS([ovs-vsctl])
193 AT_CHECK([RUN_OVS_VSCTL([add-br a])], [0], [], [], [OVS_VSCTL_CLEANUP])
194 CHECK_BRIDGES([a, a, 0])
200 AT_SETUP([add-br a, add-br a])
201 AT_KEYWORDS([ovs-vsctl])
203 AT_CHECK([RUN_OVS_VSCTL([add-br a])], [0], [], [], [OVS_VSCTL_CLEANUP])
204 AT_CHECK([RUN_OVS_VSCTL([add-br a])], [1], [],
205 [ovs-vsctl: cannot create a bridge named a because a bridge named a already exists
206 ], [OVS_VSCTL_CLEANUP])
207 AT_CHECK([RUN_OVS_VSCTL([add-br ''])], [1], [],
208 [ovs-vsctl: bridge name must not be empty string
209 ], [OVS_VSCTL_CLEANUP])
213 AT_SETUP([add-br a, add-br b])
214 AT_KEYWORDS([ovs-vsctl])
216 AT_CHECK([RUN_OVS_VSCTL([add-br a], [add-br b])], [0], [], [],
218 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br a b 9])], [1], [],
219 [ovs-vsctl: "--may-exist add-br a b 9" but a is not a VLAN bridge
222 CHECK_BRIDGES([a, a, 0], [b, b, 0])
230 AT_SETUP([add-br a, add-br b, del-br a])
231 AT_KEYWORDS([ovs-vsctl])
233 AT_CHECK([RUN_OVS_VSCTL([add-br a], [add-br b], [del-br a])], [0], [], [],
235 CHECK_BRIDGES([b, b, 0])
241 AT_SETUP([add-br a, del-br a, add-br a])
242 AT_KEYWORDS([ovs-vsctl])
244 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
248 [set Interface a other_config:key=value],
249 [get Interface a other_config:key])], [0], [
254 ], [], [OVS_VSCTL_CLEANUP])
255 CHECK_BRIDGES([a, a, 0])
261 AT_SETUP([add-br a, add-port a a1, add-port a a2])
262 AT_KEYWORDS([ovs-vsctl])
264 AT_CHECK([RUN_OVS_VSCTL(
266 [--if-exists del-br b],
268 [add-port a a2])], [0], [], [], [OVS_VSCTL_CLEANUP])
269 CHECK_BRIDGES([a, a, 0])
270 CHECK_PORTS([a], [a1], [a2])
271 CHECK_IFACES([a], [a1], [a2])
275 AT_SETUP([add-br a, add-port a a1, add-port a a1])
276 AT_KEYWORDS([ovs-vsctl])
278 AT_CHECK([RUN_OVS_VSCTL(
280 [add-port a a1])], [0], [], [], [OVS_VSCTL_CLEANUP])
281 AT_CHECK([RUN_OVS_VSCTL([add-port a a1])], [1], [],
282 [ovs-vsctl: cannot create a port named a1 because a port named a1 already exists on bridge a
283 ], [OVS_VSCTL_CLEANUP])
284 AT_CHECK([RUN_OVS_VSCTL([add-port a ''])], [1], [],
285 [ovs-vsctl: port name must not be empty string
286 ], [OVS_VSCTL_CLEANUP])
290 AT_SETUP([add-br a b, add-port a a1, add-port b b1, del-br a])
291 AT_KEYWORDS([ovs-vsctl])
293 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
298 [--if-exists del-port b b2],
305 ], [], [OVS_VSCTL_CLEANUP])
306 CHECK_BRIDGES([b, b, 0])
307 CHECK_PORTS([b], [b1])
308 CHECK_IFACES([b], [b1])
312 AT_SETUP([add-br a, add-bond a bond0 a1 a2 a3])
313 AT_KEYWORDS([ovs-vsctl])
315 AT_CHECK([RUN_OVS_VSCTL(
317 [add-bond a bond0 a1 a2 a3])], [0], [], [], [OVS_VSCTL_CLEANUP])
318 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-bond a bond0 a3 a1 a2])], [0], [], [],
320 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-bond a bond0 a2 a1])], [1], [],
321 [ovs-vsctl: "--may-exist add-bond a bond0 a2 a1" but bond0 actually has interface(s) a1, a2, a3
324 AT_CHECK([RUN_OVS_VSCTL([add-bond a '' x y z])], [1], [],
325 [ovs-vsctl: port name must not be empty string
326 ], [OVS_VSCTL_CLEANUP])
327 AT_CHECK([RUN_OVS_VSCTL([add-bond a x '' y z])], [1], [],
328 [ovs-vsctl: interface name must not be empty string
329 ], [OVS_VSCTL_CLEANUP])
330 CHECK_BRIDGES([a, a, 0])
331 CHECK_PORTS([a], [bond0])
332 CHECK_IFACES([a], [a1], [a2], [a3])
336 AT_SETUP([add-br a b, add-port a a1, add-port b b1, del-port a a1])
337 AT_KEYWORDS([ovs-vsctl])
339 AT_CHECK([RUN_OVS_VSCTL(
342 [add-port a a1 tag=9],
344 [--may-exist add-port b b1],
345 [del-port a a1])], [0], [9
346 ], [], [OVS_VSCTL_CLEANUP])
347 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-port b b1])], [0], [], [],
349 AT_CHECK([RUN_OVS_VSCTL([del-port a])], [1], [],
350 [ovs-vsctl: cannot delete port a because it is the local port for bridge a (deleting this port requires deleting the entire bridge)
353 AT_CHECK([RUN_OVS_VSCTL([--if-exists del-port a])], [0], [], [],
355 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-port a b1])], [1], [],
356 [ovs-vsctl: "--may-exist add-port a b1" but b1 is actually attached to bridge b
359 CHECK_BRIDGES([a, a, 0], [b, b, 0])
362 CHECK_PORTS([b], [b1])
363 CHECK_IFACES([b], [b1])
367 AT_SETUP([add-br a, add-bond a bond0 a1 a2 a3, del-port bond0])
368 AT_KEYWORDS([ovs-vsctl])
370 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
372 [add-bond a bond0 a1 a2 a3 tag=9],
373 [get Port bond0 tag],
374 [del-port bond0])], [0], [
378 ], [], [OVS_VSCTL_CLEANUP])
379 CHECK_BRIDGES([a, a, 0])
384 AT_SETUP([external IDs])
385 AT_KEYWORDS([ovs-vsctl])
387 AT_CHECK([RUN_OVS_VSCTL_ONELINE(
390 [add-bond a bond0 a2 a3],
391 [br-set-external-id a key0 value0],
392 [set port a1 external-ids:key1=value1],
393 [set interface a2 external-ids:key2=value2],
394 [set interface a2 external-ids:key3=value3],
395 [set interface a3 external-ids:key4=value4],
396 [br-get-external-id a],
397 [br-get-external-id a key0],
398 [br-get-external-id a key1],
399 [br-set-external-id a key0 othervalue],
400 [br-get-external-id a],
401 [br-set-external-id a key0],
402 [br-get-external-id a],
403 [get port a1 external-ids],
404 [get interface a2 external-ids],
405 [get interface a3 external-ids])], [0], [
421 {"key2"="value2", "key3"="value3"}
423 ], [], [OVS_VSCTL_CLEANUP])
424 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
425 [br-get-external-id a],
426 [get port a1 external-ids],
427 [get interface a2 external-ids],
428 [get interface a3 external-ids])], [0],
431 {"key2"="value2", "key3"="value3"}
433 ], [], [OVS_VSCTL_CLEANUP])
434 CHECK_BRIDGES([a, a, 0])
435 CHECK_PORTS([a], [a1], [bond0])
436 CHECK_IFACES([a], [a1], [a2], [a3])
440 AT_SETUP([controllers])
441 AT_KEYWORDS([controller ovs-vsctl])
443 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
446 [get-controller br0],
447 [set-controller br0 tcp:4.5.6.7],
448 [get-controller br0],
450 [del-controller br0],
451 [get-controller br0],
453 [set-controller br0 tcp:8.9.10.11 tcp:5.4.3.2],
454 [get-controller br0])], [0], [
461 tcp:5.4.3.2\ntcp:8.9.10.11
462 ], [], [OVS_VSCTL_CLEANUP])
466 dnl ----------------------------------------------------------------------
467 dnl OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([VLAN])
468 m4_define([OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF],
472 [--may-exist add-br xenbr0],
473 [add-port xenbr0 eth0],
474 [--may-exist add-port xenbr0 eth0],
475 [add-br xapi1 xenbr0 $1],
476 [--may-exist add-br xapi1 xenbr0 $1],
477 [add-port xapi1 eth0.$1])],
478 [0], [], [], [OVS_VSCTL_CLEANUP])])
480 dnl OVS_VSCTL_FAKE_BRIDGE_TESTS([VLAN])
481 m4_define([OVS_VSCTL_FAKE_BRIDGE_TESTS], [
482 AT_BANNER([ovs-vsctl unit tests -- fake bridges (VLAN $1)])
484 AT_SETUP([simple fake bridge (VLAN $1)])
485 AT_KEYWORDS([ovs-vsctl fake-bridge])
487 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
488 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1])], [1], [],
489 [ovs-vsctl: "--may-exist add-br xapi1" but xapi1 is a VLAN bridge for VLAN $1
490 ], [OVS_VSCTL_CLEANUP])
491 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1 xxx $1])], [1], [],
492 [ovs-vsctl: "--may-exist add-br xapi1 xxx $1" but xapi1 has the wrong parent xenbr0
493 ], [OVS_VSCTL_CLEANUP])
494 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1 xenbr0 10])], [1], [],
495 [ovs-vsctl: "--may-exist add-br xapi1 xenbr0 10" but xapi1 is a VLAN bridge for the wrong VLAN $1
496 ], [OVS_VSCTL_CLEANUP])
497 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br dup xenbr0 $1])], [1], [],
498 [ovs-vsctl: bridge xenbr0 already has a child VLAN bridge xapi1 on VLAN $1
499 ], [OVS_VSCTL_CLEANUP])
500 CHECK_BRIDGES([xapi1, xenbr0, $1], [xenbr0, xenbr0, 0])
501 CHECK_PORTS([xenbr0], [eth0])
502 CHECK_IFACES([xenbr0], [eth0])
503 CHECK_PORTS([xapi1], [eth0.$1])
504 CHECK_IFACES([xapi1], [eth0.$1])
508 AT_SETUP([list bridges -- real and fake (VLAN $1)])
509 AT_KEYWORDS([ovs-vsctl fake-bridge])
511 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
512 AT_CHECK([RUN_OVS_VSCTL_ONELINE([-- list-br])], [0],
514 ], [], [OVS_VSCTL_CLEANUP])
515 AT_CHECK([RUN_OVS_VSCTL_ONELINE([-- --real list-br])], [0],
517 ], [], [OVS_VSCTL_CLEANUP])
518 AT_CHECK([RUN_OVS_VSCTL_ONELINE([-- --fake list-br])], [0],
520 ], [], [OVS_VSCTL_CLEANUP])
524 AT_SETUP([simple fake bridge + del-br fake bridge (VLAN $1)])
525 AT_KEYWORDS([ovs-vsctl fake-bridge])
527 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
528 AT_CHECK([RUN_OVS_VSCTL([del-br xapi1])], [0], [], [], [OVS_VSCTL_CLEANUP])
529 CHECK_BRIDGES([xenbr0, xenbr0, 0])
530 CHECK_PORTS([xenbr0], [eth0])
531 CHECK_IFACES([xenbr0], [eth0])
535 AT_SETUP([simple fake bridge + del-br real bridge (VLAN $1)])
536 AT_KEYWORDS([ovs-vsctl fake-bridge])
538 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
539 AT_CHECK([RUN_OVS_VSCTL([del-br xenbr0])], [0], [], [], [OVS_VSCTL_CLEANUP])
544 AT_SETUP([simple fake bridge + external IDs (VLAN $1)])
545 AT_KEYWORDS([ovs-vsctl fake-bridge])
547 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
548 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
549 [br-set-external-id xenbr0 key0 value0],
550 [br-set-external-id xapi1 key1 value1],
551 [br-get-external-id xenbr0],
552 [br-get-external-id xenbr0 key0],
553 [br-get-external-id xapi1],
554 [br-get-external-id xapi1 key1])], [0], [
560 ], [], [OVS_VSCTL_CLEANUP])
561 CHECK_BRIDGES([xapi1, xenbr0, $1], [xenbr0, xenbr0, 0])
562 CHECK_PORTS([xenbr0], [eth0])
563 CHECK_IFACES([xenbr0], [eth0])
564 CHECK_PORTS([xapi1], [eth0.$1])
565 CHECK_IFACES([xapi1], [eth0.$1])
568 ]) # OVS_VSCTL_FAKE_BRIDGE_TESTS
570 OVS_VSCTL_FAKE_BRIDGE_TESTS([9])
571 OVS_VSCTL_FAKE_BRIDGE_TESTS([0])
573 dnl OVS_VSCTL_SETUP_BOND_FAKE_CONF([VLAN])
574 m4_define([OVS_VSCTL_SETUP_BOND_FAKE_CONF],
578 [add-bond xapi1 bond0 eth0 eth1],
579 [add-br xapi2 xapi1 $1],
580 [add-port xapi2 bond0.$1])],
581 [0], [], [], [OVS_VSCTL_CLEANUP])])
583 AT_SETUP([fake bridge on bond])
584 AT_KEYWORDS([ovs-vsctl fake-bridge])
586 OVS_VSCTL_SETUP_BOND_FAKE_CONF([11])
587 CHECK_BRIDGES([xapi1, xapi1, 0], [xapi2, xapi1, 11])
588 CHECK_PORTS([xapi1], [bond0])
589 CHECK_IFACES([xapi1], [eth0], [eth1])
590 CHECK_PORTS([xapi2], [bond0.11])
591 CHECK_IFACES([xapi2], [bond0.11])
595 AT_SETUP([fake bridge on bond + del-br fake bridge])
596 AT_KEYWORDS([ovs-vsctl fake-bridge])
598 OVS_VSCTL_SETUP_BOND_FAKE_CONF([11])
599 AT_CHECK([RUN_OVS_VSCTL_ONELINE([del-br xapi2])], [0], [
600 ], [], [OVS_VSCTL_CLEANUP])
601 CHECK_BRIDGES([xapi1, xapi1, 0])
602 CHECK_PORTS([xapi1], [bond0])
603 CHECK_IFACES([xapi1], [eth0], [eth1])
607 AT_SETUP([fake bridge on bond + del-br real bridge])
608 AT_KEYWORDS([ovs-vsctl fake-bridge])
610 OVS_VSCTL_SETUP_BOND_FAKE_CONF([11])
611 AT_CHECK([RUN_OVS_VSCTL([del-br xapi1])])
616 dnl ----------------------------------------------------------------------
617 AT_BANNER([ovs-vsctl unit tests -- manager commands])
620 AT_KEYWORDS([manager ovs-vsctl])
622 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
625 [set-manager tcp:4.5.6.7],
627 [set-manager tcp:8.9.10.11 tcp:5.4.3.2],
630 [get-manager])], [0], [
635 tcp:5.4.3.2\ntcp:8.9.10.11
638 ], [], [OVS_VSCTL_CLEANUP])
642 dnl ----------------------------------------------------------------------
643 AT_BANNER([ovs-vsctl unit tests -- database commands])
645 AT_SETUP([database commands -- positive checks])
646 AT_KEYWORDS([ovs-vsctl])
649 [RUN_OVS_VSCTL_TOGETHER([--id=@br0 create bridge name=br123],
650 [set b br123 name=br0],
651 [set o . bridges=@br0])],
652 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
654 AT_CHECK([RUN_OVS_VSCTL([list bridge], [get bridge br0 _uuid])],
655 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
657 AT_CHECK([${PERL} $srcdir/uuidfilt.pl out1 out2], [0],
666 datapath_version : ""
672 mcast_snooping_enable: false
687 [RUN_OVS_VSCTL([--columns=fail_mode,name,datapath_type list bridge])],
694 [RUN_OVS_VSCTL([--columns=fail_mode,name,datapath_type find bridge])],
701 RUN_OVS_VSCTL_TOGETHER([--id=@br1 create bridge name=br1 datapath_type="foo"],
702 [--id=@br2 create bridge name=br2 external-ids:bar=quux],
703 [add o . bridges @br1 @br2])],
704 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
706 [RUN_OVS_VSCTL([--columns=name find bridge datapath_type!=foo])], [0], [stdout],
708 AT_CHECK([sed -n '/./p' stdout | sort], [0],
715 'other_config:datapath_id="0123456789ab"' \
716 'other_config:hwaddr="00:11:22:33:44:55"' \
717 'external-ids={"uuids"="9c45f225-a7cf-439d-976d-83db6271fda1"}' -- \
718 add bridge br0 external_ids '"roles"="local; remote; cloud"'])],
719 [0], [], [], [OVS_VSCTL_CLEANUP])
720 AT_CHECK([RUN_OVS_VSCTL_ONELINE([get bridge br0 other_config external-ids])],
721 [0], [{datapath_id="0123456789ab", hwaddr="00:11:22:33:44:55"}\n{roles="local; remote; cloud", uuids="9c45f225-a7cf-439d-976d-83db6271fda1"}
722 ], [], [OVS_VSCTL_CLEANUP])
723 AT_CHECK([RUN_OVS_VSCTL([get bridge br0 other_config:hwaddr -- --if-exists get bridge br0 other-config:nonexistent])],
724 [0], ["00:11:22:33:44:55"
726 ], [], [OVS_VSCTL_CLEANUP])
727 AT_CHECK([RUN_OVS_VSCTL([remove bridge br0 other_config hwaddr 'datapath_id=""' -- get bridge br0 other_config])],
728 [0], [{datapath_id="0123456789ab"}
729 ], [], [OVS_VSCTL_CLEANUP])
730 AT_CHECK([RUN_OVS_VSCTL([remove bridge br0 other_config 'datapath_id="0123456789ab"' -- get bridge br0 other_config])],
732 ], [], [OVS_VSCTL_CLEANUP])
733 AT_CHECK([RUN_OVS_VSCTL([clear bridge br0 external-ids -- get bridge br0 external_ids])],
735 ], [], [OVS_VSCTL_CLEANUP])
736 AT_CHECK([RUN_OVS_VSCTL_TOGETHER([destroy bridge br0],
737 [destroy bridge br1],
738 [destroy bridge br2],
739 [clear o . bridges])],
740 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
741 AT_CHECK([RUN_OVS_VSCTL([list bridge])],
742 [0], [], [], [OVS_VSCTL_CLEANUP])
743 AT_CHECK([RUN_OVS_VSCTL([--if-exists get bridge x datapath_id])],
744 [0], [], [], [OVS_VSCTL_CLEANUP])
745 AT_CHECK([RUN_OVS_VSCTL([--if-exists list bridge x])],
746 [0], [], [], [OVS_VSCTL_CLEANUP])
747 AT_CHECK([RUN_OVS_VSCTL([--if-exists set controller x connection_mode=standalone])],
748 [0], [], [], [OVS_VSCTL_CLEANUP])
750 [RUN_OVS_VSCTL([--if-exists remove netflow x targets '"1.2.3.4:567"'])],
751 [0], [], [], [OVS_VSCTL_CLEANUP])
753 [RUN_OVS_VSCTL([--if-exists clear netflow x targets])],
754 [0], [], [], [OVS_VSCTL_CLEANUP])
758 AT_SETUP([database commands -- negative checks])
759 AT_KEYWORDS([ovs-vsctl])
762 AT_CHECK([ovs-vsctl --may-exist],
763 [1], [ignore], [ovs-vsctl: missing command name (use --help for help)
764 ], [OVS_VSCTL_CLEANUP])
765 AT_CHECK([ovs-vsctl --may-exist --],
766 [1], [ignore], [ovs-vsctl: missing command name (use --help for help)
767 ], [OVS_VSCTL_CLEANUP])
768 AT_CHECK([ovs-vsctl -- --may-exist],
769 [1], [ignore], [ovs-vsctl: missing command name (use --help for help)
770 ], [OVS_VSCTL_CLEANUP])
772 AT_CHECK([RUN_OVS_VSCTL([add-br br0])],
773 [0], [ignore], [], [OVS_VSCTL_CLEANUP])
774 AT_CHECK([RUN_OVS_VSCTL([add-br br1])],
775 [0], [ignore], [], [OVS_VSCTL_CLEANUP])
776 AT_CHECK([RUN_OVS_VSCTL([set-controller br1 tcp:127.0.0.1])],
777 [0], [ignore], [], [OVS_VSCTL_CLEANUP])
778 AT_CHECK([RUN_OVS_VSCTL([list netflow br0])], [1], [],
779 [ovs-vsctl: no row "br0" in table NetFlow
780 ], [OVS_VSCTL_CLEANUP])
782 RUN_OVS_VSCTL_TOGETHER([--id=@n create netflow targets='"1.2.3.4:567"'],
783 [set bridge br0 netflow=@n])],
784 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
785 cp stdout netflow-uuid
786 AT_CHECK([RUN_OVS_VSCTL([list netflow `cat netflow-uuid`])],
787 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
788 AT_CHECK([${PERL} $srcdir/uuidfilt.pl netflow-uuid stdout], [0],
793 add_id_to_interface : false
797 targets : ["1.2.3.4:567"]
799 AT_CHECK([RUN_OVS_VSCTL([list interx x])],
800 [1], [], [ovs-vsctl: unknown table "interx"
801 ], [OVS_VSCTL_CLEANUP])
802 AT_CHECK([RUN_OVS_VSCTL([list bridge x])],
803 [1], [], [ovs-vsctl: no row "x" in table Bridge
804 ], [OVS_VSCTL_CLEANUP])
805 AT_CHECK([RUN_OVS_VSCTL([get bridge x datapath_id])],
806 [1], [], [ovs-vsctl: no row "x" in table Bridge
807 ], [OVS_VSCTL_CLEANUP])
808 AT_CHECK([RUN_OVS_VSCTL([get bridge br0 d])],
809 [1], [], [ovs-vsctl: Bridge contains more than one column whose name matches "d"
810 ], [OVS_VSCTL_CLEANUP])
811 AT_CHECK([RUN_OVS_VSCTL([get bridge br0 x])],
812 [1], [], [ovs-vsctl: Bridge does not contain a column whose name matches "x"
813 ], [OVS_VSCTL_CLEANUP])
814 AT_CHECK([RUN_OVS_VSCTL([get bridge br0 :y=z])],
815 [1], [], [ovs-vsctl: :y=z: missing column name
816 ], [OVS_VSCTL_CLEANUP])
817 AT_CHECK([RUN_OVS_VSCTL([get bridge br0 datapath_id:y=z])],
818 [1], [], [ovs-vsctl: datapath_id:y=z: trailing garbage "=z" in argument
819 ], [OVS_VSCTL_CLEANUP])
820 AT_CHECK([RUN_OVS_VSCTL([set bridge br0 'datapath_id:y>=z'])],
821 [1], [], [ovs-vsctl: datapath_id:y>=z: argument does not end in "=" followed by a value.
822 ], [OVS_VSCTL_CLEANUP])
823 AT_CHECK([RUN_OVS_VSCTL([set controller x connection_mode=standalone])],
824 [1], [], [ovs-vsctl: no row "x" in table Controller
825 ], [OVS_VSCTL_CLEANUP])
826 AT_CHECK([RUN_OVS_VSCTL([wait-until bridge br0 datapath_id:y,z])],
827 [1], [], [ovs-vsctl: datapath_id:y,z: argument does not end in "=", "!=", "<", ">", "<=", ">=", "{=}", "{!=}", "{<}", "{>}", "{<=}", or "{>=}" followed by a value.
828 ], [OVS_VSCTL_CLEANUP])
829 AT_CHECK([RUN_OVS_VSCTL([get bridge br0 datapath_id::])],
830 [1], [], [ovs-vsctl: datapath_id::: trailing garbage ":" in argument
831 ], [OVS_VSCTL_CLEANUP])
832 AT_CHECK([RUN_OVS_VSCTL([get bridge br0 datapath_id:x])],
833 [1], [], [ovs-vsctl: cannot specify key to get for non-map column datapath_id
834 ], [OVS_VSCTL_CLEANUP])
835 AT_CHECK([RUN_OVS_VSCTL([get bridge br0 external_ids:x])],
836 [1], [], [ovs-vsctl: no key "x" in Bridge record "br0" column external_ids
837 ], [OVS_VSCTL_CLEANUP])
838 AT_CHECK([RUN_OVS_VSCTL([set bridge br0 flood_vlans=-1])],
839 [1], [], [ovs-vsctl: constraint violation: -1 is not in the valid range 0 to 4095 (inclusive)
840 ], [OVS_VSCTL_CLEANUP])
841 AT_CHECK([RUN_OVS_VSCTL([set bridge br0 flood_vlans=4096])],
842 [1], [], [ovs-vsctl: constraint violation: 4096 is not in the valid range 0 to 4095 (inclusive)
843 ], [OVS_VSCTL_CLEANUP])
844 AT_CHECK([RUN_OVS_VSCTL([set c br1 'connection-mode=xyz'])],
845 [1], [], [[ovs-vsctl: constraint violation: xyz is not one of the allowed values ([in-band, out-of-band])
846 ]], [OVS_VSCTL_CLEANUP])
847 AT_CHECK([RUN_OVS_VSCTL([set c br1 connection-mode:x=y])],
848 [1], [], [ovs-vsctl: cannot specify key to set for non-map column connection_mode
849 ], [OVS_VSCTL_CLEANUP])
850 AT_CHECK([RUN_OVS_VSCTL([add bridge br1 datapath_id x y])],
851 [1], [], [ovs-vsctl: "add" operation would put 2 values in column datapath_id of table Bridge but the maximum number is 1
852 ], [OVS_VSCTL_CLEANUP])
853 AT_CHECK([RUN_OVS_VSCTL([remove netflow `cat netflow-uuid` targets '"1.2.3.4:567"'])],
854 [1], [], [ovs-vsctl: "remove" operation would put 0 values in column targets of table NetFlow but the minimum number is 1
855 ], [OVS_VSCTL_CLEANUP])
856 AT_CHECK([RUN_OVS_VSCTL([remove netflow x targets '"1.2.3.4:567"'])],
857 [1], [], [ovs-vsctl: no row "x" in table NetFlow
858 ], [OVS_VSCTL_CLEANUP])
859 AT_CHECK([RUN_OVS_VSCTL([clear netflow x targets])],
860 [1], [], [ovs-vsctl: no row "x" in table NetFlow
861 ], [OVS_VSCTL_CLEANUP])
862 AT_CHECK([RUN_OVS_VSCTL([clear netflow `cat netflow-uuid` targets])],
863 [1], [], [ovs-vsctl: "clear" operation cannot be applied to column targets of table NetFlow, which is not allowed to be empty
864 ], [OVS_VSCTL_CLEANUP])
865 AT_CHECK([RUN_OVS_VSCTL([destroy bridge br2])],
866 [1], [], [ovs-vsctl: no row "br2" in table Bridge
867 ], [OVS_VSCTL_CLEANUP])
868 AT_CHECK([RUN_OVS_VSCTL([add in br1 name x])],
869 [1], [], [ovs-vsctl: cannot modify read-only column name in table Interface
870 ], [OVS_VSCTL_CLEANUP])
871 AT_CHECK([RUN_OVS_VSCTL([set port br0 name=br2])],
872 [1], [], [ovs-vsctl: cannot modify read-only column name in table Port
873 ], [OVS_VSCTL_CLEANUP])
874 AT_CHECK([RUN_OVS_VSCTL([remove bridge br0 name br1])],
875 [1], [], [ovs-vsctl: cannot modify read-only column name in table Bridge
876 ], [OVS_VSCTL_CLEANUP])
877 AT_CHECK([RUN_OVS_VSCTL([remove bridge br1 flood-vlans true])],
878 [1], [], [ovs-vsctl: "true" is not a valid integer or range
879 ], [OVS_VSCTL_CLEANUP])
880 AT_CHECK([RUN_OVS_VSCTL([clear bridge br1 name])],
881 [1], [], [ovs-vsctl: cannot modify read-only column name in table Bridge
882 ], [OVS_VSCTL_CLEANUP])
886 AT_SETUP([database commands -- conditions])
887 AT_KEYWORDS([ovs-vsctl])
890 [RUN_OVS_VSCTL_TOGETHER(
892 [add-br br1], [set bridge br1 flood_vlans=0 other-config:x='""'],
893 [add-br br2], [set bridge br2 flood_vlans=1 other-config:x=y],
894 [add-br br3], [set bridge br3 flood_vlans=0,1 other-config:x=z],
895 [add-br br4], [set bridge br4 flood_vlans=2],
896 [add-br br5], [set bridge br5 flood_vlans=0,2],
897 [add-br br6], [set bridge br6 flood_vlans=1,2],
898 [add-br br7], [set bridge br7 flood_vlans=0,1,2])], [0], [
914 m4_define([VSCTL_CHECK_FIND],
915 [AT_CHECK([echo `ovs-vsctl --bare --no-wait -vreconnect:emer --db=unix:socket -- --columns=name find bridge '$1' | sort`], [0], [$2
918 # Arithmetic relational operators without keys.
919 VSCTL_CHECK_FIND([flood_vlans=0], [br1])
920 VSCTL_CHECK_FIND([flood_vlans=1], [br2])
921 VSCTL_CHECK_FIND([flood_vlans=0,2], [br5])
922 VSCTL_CHECK_FIND([flood_vlans=0,1,2], [br7])
923 VSCTL_CHECK_FIND([flood_vlans=3], [])
925 VSCTL_CHECK_FIND([flood_vlans!=0], [br0 br2 br3 br4 br5 br6 br7])
926 VSCTL_CHECK_FIND([flood_vlans!=1], [br0 br1 br3 br4 br5 br6 br7])
927 VSCTL_CHECK_FIND([flood_vlans!=0,2], [br0 br1 br2 br3 br4 br6 br7])
928 VSCTL_CHECK_FIND([flood_vlans!=0,1,2], [br0 br1 br2 br3 br4 br5 br6])
929 VSCTL_CHECK_FIND([flood_vlans!=3], [br0 br1 br2 br3 br4 br5 br6 br7])
931 VSCTL_CHECK_FIND([flood_vlans<2], [br0 br1 br2])
932 VSCTL_CHECK_FIND([flood_vlans<0,2], [br0 br1 br2 br3 br4])
933 VSCTL_CHECK_FIND([flood_vlans>1], [br3 br4 br5 br6 br7])
934 VSCTL_CHECK_FIND([flood_vlans>0,1], [br5 br6 br7])
935 VSCTL_CHECK_FIND([flood_vlans<=2], [br0 br1 br2 br4])
936 VSCTL_CHECK_FIND([flood_vlans<=0,2], [br0 br1 br2 br3 br4 br5])
937 VSCTL_CHECK_FIND([flood_vlans>=1], [br2 br3 br4 br5 br6 br7])
938 VSCTL_CHECK_FIND([flood_vlans>=0,1], [br3 br5 br6 br7])
940 # Set relational operators without keys.
941 VSCTL_CHECK_FIND([flood_vlans{=}0], [br1])
942 VSCTL_CHECK_FIND([flood_vlans{=}1], [br2])
943 VSCTL_CHECK_FIND([flood_vlans{=}0,2], [br5])
944 VSCTL_CHECK_FIND([flood_vlans{=}0,1,2], [br7])
945 VSCTL_CHECK_FIND([flood_vlans{=}3], [])
947 VSCTL_CHECK_FIND([flood_vlans{!=}0], [br0 br2 br3 br4 br5 br6 br7])
948 VSCTL_CHECK_FIND([flood_vlans{!=}1], [br0 br1 br3 br4 br5 br6 br7])
949 VSCTL_CHECK_FIND([flood_vlans{!=}0,2], [br0 br1 br2 br3 br4 br6 br7])
950 VSCTL_CHECK_FIND([flood_vlans{!=}0,1,2], [br0 br1 br2 br3 br4 br5 br6])
951 VSCTL_CHECK_FIND([flood_vlans{!=}3], [br0 br1 br2 br3 br4 br5 br6 br7])
953 VSCTL_CHECK_FIND([flood_vlans{<}[[]]], [])
954 VSCTL_CHECK_FIND([flood_vlans{<=}[[]]], [br0])
955 VSCTL_CHECK_FIND([flood_vlans{<}0], [br0])
956 VSCTL_CHECK_FIND([flood_vlans{<=}0], [br0 br1])
957 VSCTL_CHECK_FIND([flood_vlans{<}1,2], [br0 br2 br4])
958 VSCTL_CHECK_FIND([flood_vlans{<=}1,2], [br0 br2 br4 br6])
960 VSCTL_CHECK_FIND([flood_vlans{>}[[]]], [br1 br2 br3 br4 br5 br6 br7])
961 VSCTL_CHECK_FIND([flood_vlans{>=}[[]]], [br0 br1 br2 br3 br4 br5 br6 br7])
962 VSCTL_CHECK_FIND([flood_vlans{>}0], [br3 br5 br7])
963 VSCTL_CHECK_FIND([flood_vlans{>=}0], [br1 br3 br5 br7])
964 VSCTL_CHECK_FIND([flood_vlans{>}0,2], [br7])
965 VSCTL_CHECK_FIND([flood_vlans{>=}1,2], [br6 br7])
966 VSCTL_CHECK_FIND([flood_vlans{>=}0,2], [br5 br7])
968 # Arithmetic relational operators with keys.
969 VSCTL_CHECK_FIND([other-config:x=""], [br1])
970 VSCTL_CHECK_FIND([other-config:x=y], [br2])
971 VSCTL_CHECK_FIND([other-config:x=z], [br3])
973 VSCTL_CHECK_FIND([other-config:x!=""], [br2 br3])
974 VSCTL_CHECK_FIND([other-config:x!=y], [br1 br3])
975 VSCTL_CHECK_FIND([other-config:x!=z], [br1 br2])
977 VSCTL_CHECK_FIND([other-config:x>y], [br3])
978 VSCTL_CHECK_FIND([other-config:x>=y], [br2 br3])
979 VSCTL_CHECK_FIND([other-config:x<y], [br1])
980 VSCTL_CHECK_FIND([other-config:x<=y], [br1 br2])
982 # Set relational operators with keys.
983 VSCTL_CHECK_FIND([other-config:x{=}[[]]], [br0 br4 br5 br6 br7])
984 VSCTL_CHECK_FIND([other-config:x{=}""], [br1])
985 VSCTL_CHECK_FIND([other-config:x{=}y], [br2])
986 VSCTL_CHECK_FIND([other-config:x{=}z], [br3])
988 VSCTL_CHECK_FIND([other-config:x{!=}[[]]], [br1 br2 br3])
989 VSCTL_CHECK_FIND([other-config:x{!=}""], [br0 br2 br3 br4 br5 br6 br7])
990 VSCTL_CHECK_FIND([other-config:x{!=}y], [br0 br1 br3 br4 br5 br6 br7])
991 VSCTL_CHECK_FIND([other-config:x{!=}z], [br0 br1 br2 br4 br5 br6 br7])
993 VSCTL_CHECK_FIND([other-config:x{<=}[[]]], [br0 br4 br5 br6 br7])
994 VSCTL_CHECK_FIND([other-config:x{<=}x], [br0 br4 br5 br6 br7])
995 VSCTL_CHECK_FIND([other-config:x{<=}""], [br0 br1 br4 br5 br6 br7])
996 VSCTL_CHECK_FIND([other-config:x{<=}y], [br0 br2 br4 br5 br6 br7])
997 VSCTL_CHECK_FIND([other-config:x{<=}z], [br0 br3 br4 br5 br6 br7])
998 VSCTL_CHECK_FIND([other-config:x{<=}x,y,z], [br0 br2 br3 br4 br5 br6 br7])
1000 VSCTL_CHECK_FIND([other-config:x{<}[[]]], [])
1001 VSCTL_CHECK_FIND([other-config:x{<}x], [br0 br4 br5 br6 br7])
1002 VSCTL_CHECK_FIND([other-config:x{<}""], [br0 br4 br5 br6 br7])
1003 VSCTL_CHECK_FIND([other-config:x{<}y], [br0 br4 br5 br6 br7])
1004 VSCTL_CHECK_FIND([other-config:x{<}z], [br0 br4 br5 br6 br7])
1006 VSCTL_CHECK_FIND([other-config:x{>=}[[]]], [br0 br1 br2 br3 br4 br5 br6 br7])
1007 VSCTL_CHECK_FIND([other-config:x{>=}x], [])
1008 VSCTL_CHECK_FIND([other-config:x{>=}""], [br1])
1009 VSCTL_CHECK_FIND([other-config:x{>=}y], [br2])
1010 VSCTL_CHECK_FIND([other-config:x{>=}z], [br3])
1012 VSCTL_CHECK_FIND([other-config:x{>}[[]]], [br1 br2 br3])
1013 VSCTL_CHECK_FIND([other-config:x{>}x], [])
1014 VSCTL_CHECK_FIND([other-config:x{>}""], [])
1015 VSCTL_CHECK_FIND([other-config:x{>}y], [])
1016 VSCTL_CHECK_FIND([other-config:x{>}z], [])
1020 AT_SETUP([database commands -- wait-until immediately true])
1021 AT_KEYWORDS([ovs-vsctl])
1023 AT_CHECK([RUN_OVS_VSCTL(
1025 [add-bond br0 bond0 eth0 eth1],
1026 [set port bond0 bond_updelay=500 other-config:abc=def])],
1027 [0], [], [], [OVS_VSCTL_CLEANUP])
1028 AT_CHECK([RUN_OVS_VSCTL([[wait-until Open_vSwitch . manager_options=[]]])],
1029 [0], [], [], [OVS_VSCTL_CLEANUP])
1030 AT_CHECK([RUN_OVS_VSCTL([[wait-until Open_vSwitch . bridges!=[]]])],
1031 [0], [], [], [OVS_VSCTL_CLEANUP])
1032 AT_CHECK([RUN_OVS_VSCTL([[wait-until Port bond0 other-config:abc=def]])],
1033 [0], [], [], [OVS_VSCTL_CLEANUP])
1034 AT_CHECK([RUN_OVS_VSCTL([[wait-until port bond0 'bond_updelay>50' 'other-config:abc>d' 'other-config:abc<e']])],
1035 [0], [], [], [OVS_VSCTL_CLEANUP])
1039 AT_SETUP([database commands -- wait-until must wait])
1040 AT_KEYWORDS([ovs-vsctl])
1044 # Start ovs-vsctls in background.
1045 (RUN_OVS_VSCTL([[wait-until o . bridges!=[] -- get bridge br10 other-config:abc]])) > stdout1 &
1046 (RUN_OVS_VSCTL([[wait-until bridge br1 -- get bridge br1 other-config:abc]])) > stdout2 &
1047 (RUN_OVS_VSCTL([[wait-until bridge br1 other-config={abc=def} -- get bridge br1 other-config]])) > stdout3 &
1048 (RUN_OVS_VSCTL([[wait-until port bond0 'bond_updelay>50' -- get port bond0 bond-updelay]])) > stdout4 &
1050 # Give the ovs-vsctls a chance to read the database
1053 AT_CHECK([RUN_OVS_VSCTL([add-br br10 -- set bridge br10 other-config:abc=quux])
1054 RUN_OVS_VSCTL([add-br br1 -- set bridge br1 other-config:abc=def -- add-bond br1 bond0 eth0 eth1 -- set port bond0 bond_updelay=500])],
1055 [0], [], [], [OVS_VSCTL_CLEANUP])
1057 # Wait for the ovs-vsctls to finish.
1061 AT_CHECK([cat stdout1], [0], [quux
1062 ], [], [OVS_VSCTL_CLEANUP])
1063 AT_CHECK([cat stdout2], [0], [def
1064 ], [], [OVS_VSCTL_CLEANUP])
1065 AT_CHECK([cat stdout3], [0], [{abc=def}
1066 ], [], [OVS_VSCTL_CLEANUP])
1067 AT_CHECK([cat stdout4], [0], [500
1068 ], [], [OVS_VSCTL_CLEANUP])
1073 AT_SETUP([--id option on create, get commands])
1074 AT_KEYWORDS([ovs-vsctl])
1076 AT_CHECK([RUN_OVS_VSCTL([add-br br0],
1077 [add-port br0 eth0],
1078 [add-port br0 eth1])])
1080 [RUN_OVS_VSCTL_TOGETHER(
1081 [set bridge br0 mirrors=@m],
1082 [--id=@eth0 get port eth0],
1083 [--id=@eth1 get port eth1],
1084 [--id=@m create mirror name=mymirror select-dst-port=@eth0 select-src-port=@eth0 output-port=@eth1])],
1085 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
1087 [${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
1093 [], [OVS_VSCTL_CLEANUP])
1096 [list port eth0 eth1],
1098 [list bridge br0])],
1099 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
1101 [sed -n -e '/uuid/p' -e '/name/p' -e '/mirrors/p' -e '/select/p' -e '/output/p' < stdout | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
1111 select_dst_port : [<0>]
1112 select_src_port : [<0>]
1118 [], [OVS_VSCTL_CLEANUP])
1122 AT_SETUP([unreferenced record warnings])
1123 AT_KEYWORDS([ovs-vsctl])
1126 [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer --db=unix:socket \
1127 -- create Bridge name=br0 | ${PERL} $srcdir/uuidfilt.pl],
1129 ], [db_ctl_base|WARN|applying "create" command to table Bridge without --id option will have no effect
1130 ], [OVS_VSCTL_CLEANUP])
1132 [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer --db=unix:socket \
1133 -- --id=@br0 create Bridge name=br0 | ${PERL} $srcdir/uuidfilt.pl],
1135 ], [vsctl|WARN|row id "@br0" was created but no reference to it was inserted, so it will not actually appear in the database
1136 ], [OVS_VSCTL_CLEANUP])
1138 [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer --db=unix:socket \
1139 -- --id=@eth0_iface create Interface name=eth0 \
1140 -- --id=@eth0 create Port name=eth0 interfaces=@eth0_iface \
1141 -- --id=@m0 create Mirror name=m0 output_port=@eth0 \
1142 -- --id=@br0 create Bridge name=br0 mirrors=@m0 \
1143 -- set Open_vSwitch . bridges=@br0 | ${PERL} $srcdir/uuidfilt.pl],
1148 ], [vsctl|WARN|row id "@eth0" was created but only a weak reference to it was inserted, so it will not actually appear in the database
1149 ], [OVS_VSCTL_CLEANUP])
1153 dnl This test really shows a bug -- "create" followed by "list" in
1154 dnl the same execution shows the wrong UUID on the "list" command.
1155 dnl The bug is documented in ovs-vsctl.8.
1156 AT_SETUP([created row UUID is wrong in same execution])
1157 AT_KEYWORDS([ovs-vsctl])
1159 AT_CHECK([RUN_OVS_VSCTL([--id=@br0 create Bridge name=br0 -- add Open_vSwitch . bridges @br0 -- list bridge])],
1160 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
1161 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0],
1168 datapath_version : ""
1174 mcast_snooping_enable: false
1190 dnl This test will create a linux-htb QoS record that
1191 dnl points to a few queues and use it on a1 and a2 port.
1192 dnl It also destroys all records from Qos and Queue table.
1193 AT_SETUP([--all option on destroy command])
1194 AT_KEYWORDS([ovs-vsctl])
1196 AT_CHECK([RUN_OVS_VSCTL(
1199 [add-port a a2])], [0], [], [], [OVS_VSCTL_CLEANUP])
1200 CHECK_BRIDGES([a, a, 0])
1201 CHECK_PORTS([a], [a1], [a2])
1202 CHECK_IFACES([a], [a1], [a2])
1203 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
1204 [set Port a1 qos=@newqos],
1205 [set Port a2 qos=@newqos],
1206 [--id=@newqos create QoS type=linux-htb other-config:max-rate=1000000000 queues=0=@q0,1=@q1],
1207 [--id=@q0 create Queue other-config:min-rate=100000000 other-config:max-rate=100000000],
1208 [--id=@q1 create Queue other-config:min-rate=500000000])], [0], [ignore], [], [OVS_VSCTL_CLEANUP])
1209 AT_CHECK([RUN_OVS_VSCTL(
1210 [--columns=other_config,type list Qos])], [0],
1211 [other_config : {max-rate="1000000000"}
1213 ], [], [OVS_VSCTL_CLEANUP])
1214 AT_CHECK([RUN_OVS_VSCTL(
1215 [--columns=other_config list Queue | sort | sed '/^$/d'])], [0],
1216 [other_config : {max-rate="100000000", min-rate="100000000"}
1217 other_config : {min-rate="500000000"}
1218 ], [], [OVS_VSCTL_CLEANUP])
1219 AT_CHECK([RUN_OVS_VSCTL(
1220 [clear Port a1 qos],
1221 [clear Port a2 qos])], [0], [], [], [OVS_VSCTL_CLEANUP])
1222 AT_CHECK([RUN_OVS_VSCTL(
1223 [--columns=qos list Port a1 a2])], [0],
1227 ]], [], [OVS_VSCTL_CLEANUP])
1228 AT_CHECK([RUN_OVS_VSCTL(
1229 [--all destroy Qos])], [0], [], [], [OVS_VSCTL_CLEANUP])
1230 AT_CHECK([RUN_OVS_VSCTL(
1231 [-- list Qos])], [0], [], [], [OVS_VSCTL_CLEANUP])
1232 AT_CHECK([RUN_OVS_VSCTL(
1233 [--all destroy Queue])], [0], [], [], [OVS_VSCTL_CLEANUP])
1234 AT_CHECK([RUN_OVS_VSCTL(
1235 [-- list Queue])], [0], [], [], [OVS_VSCTL_CLEANUP])
1239 dnl ----------------------------------------------------------------------
1240 AT_BANNER([ovs-vsctl add-port -- reserved port names])
1242 AT_SETUP([add-port -- reserved names 1])
1245 # Test creating all reserved port names
1255 # Try creating the port
1257 ovs-vsctl: Error detected while setting up 'reserved_name'. See ovs-vswitchd log for details.
1258 ovs-vsctl: The default log directory is "$OVS_RUNDIR".
1260 AT_CHECK([ovs-vsctl add-port br0 reserved_name], [0], [], [experr])
1262 OVS_WAIT_UNTIL([test `grep -- "|WARN|" ovs-vswitchd.log | wc -l` -ge 1])
1263 # Detect the warning log message
1264 AT_CHECK([sed -n "s/^.*\(|bridge|WARN|.*\)$/\1/p" ovs-vswitchd.log], [0], [dnl
1265 |bridge|WARN|could not create interface reserved_name, name is reserved
1267 # Delete the warning log message
1268 AT_CHECK([sed "/|bridge|WARN|/d" ovs-vswitchd.log > ovs-vswitchd.log], [0], [], [])
1270 AT_CHECK([ovs-vsctl del-port br0 reserved_name], [0], [], [])])
1274 AT_SETUP([add-port -- reserved names 2])
1275 # Creates all type of tunnel ports
1276 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
1277 options:remote_ip=1.1.1.1 ofport_request=1\
1278 -- add-port br0 p3 -- set Interface p3 type=lisp \
1279 options:remote_ip=2.2.2.2 ofport_request=3 \
1280 -- add-port br0 p4 -- set Interface p4 type=vxlan \
1281 options:remote_ip=2.2.2.2 ofport_request=4 \
1282 -- add-port br0 p5 -- set Interface p5 type=geneve \
1283 options:remote_ip=2.2.2.2 ofport_request=5])
1285 # Test creating all reserved tunnel port names
1293 # Try creating the port
1295 ovs-vsctl: Error detected while setting up 'reserved_name'. See ovs-vswitchd log for details.
1296 ovs-vsctl: The default log directory is "$OVS_RUNDIR".
1298 AT_CHECK([ovs-vsctl add-port br0 reserved_name], [0], [], [experr])
1300 OVS_WAIT_UNTIL([test `grep -- "|WARN|" ovs-vswitchd.log | wc -l` -ge 1])
1301 # Detect the warning log message
1302 AT_CHECK([sed -n "s/^.*\(|bridge|WARN|.*\)$/\1/p" ovs-vswitchd.log], [0], [dnl
1303 |bridge|WARN|could not create interface reserved_name, name is reserved
1305 # Delete the warning log message
1306 AT_CHECK([sed "/|bridge|WARN|/d" ovs-vswitchd.log > ovs-vswitchd.log], [0], [], [])
1308 AT_CHECK([ovs-vsctl del-port br0 reserved_name], [0], [], [])])
1312 AT_SETUP([naming in db commands])
1313 AT_KEYWORDS([ovs-vsctl])
1316 dnl First check that the database commands can refer to row by database UUID.
1317 AT_CHECK([RUN_OVS_VSCTL([add-br br0])])
1318 uuid=`[]RUN_OVS_VSCTL(get port br0 _uuid)`
1319 AT_CHECK([RUN_OVS_VSCTL([get port $uuid name])], [0], ["br0"
1322 dnl Next check that, if a database row is given a name that has the same form
1323 dnl as the database UUIDs, the name can still be used to refer to rows.
1324 AT_CHECK([RUN_OVS_VSCTL([add-br 0fcd11a1-2ba8-4b38-a358-4bccf2bf3057])])
1325 AT_CHECK([RUN_OVS_VSCTL([get interface 0fcd11a1-2ba8-4b38-a358-4bccf2bf3057 type])], [0], [internal
1331 AT_SETUP([bootstrap ca cert])
1332 AT_KEYWORDS([ovs-vsctl ssl])
1333 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
1335 OVS_PKI="sh $abs_top_srcdir/utilities/ovs-pki.in --dir=$PKIDIR/pki --log=$PKIDIR/ovs-pki.log"
1336 AT_CHECK([$OVS_PKI -B 1024 init && $OVS_PKI -B 1024 req+sign vsctl switch && $OVS_PKI -B 1024 req ovsdbserver && $OVS_PKI self-sign ovsdbserver], [0], [ignore], [ignore])
1338 dnl Create database.
1339 OVSDB_INIT([conf.db])
1340 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --private-key=$PKIDIR/ovsdbserver-privkey.pem --certificate=$PKIDIR/ovsdbserver-cert.pem --ca-cert=$PKIDIR/pki/switchca/cacert.pem --remote=pssl:0:127.0.0.1 --log-file="`pwd`"/ovsdb-server.log conf.db], [0], [ignore], [ignore])
1341 on_exit "kill `cat ovsdb-server.pid`"
1342 PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT])
1344 # During bootstrap, the connection gets torn down. So the o/p of ovs-vsctl is error.
1345 AT_CHECK([ovs-vsctl -t 5 --db=ssl:127.0.0.1:$SSL_PORT --private-key=$PKIDIR/vsctl-privkey.pem --certificate=$PKIDIR/vsctl-cert.pem --bootstrap-ca-cert=$PKIDIR/cacert.pem show], [1], [ignore], [ignore])
1347 # If the bootstrap was successful, the following file should exist.
1348 OVS_WAIT_UNTIL([test -e $PKIDIR/cacert.pem])
1350 # After bootstrap, the connection should be successful.
1351 AT_CHECK([ovs-vsctl -t 5 --no-wait --db=ssl:127.0.0.1:$SSL_PORT --private-key=$PKIDIR/vsctl-privkey.pem --certificate=$PKIDIR/vsctl-cert.pem --bootstrap-ca-cert=$PKIDIR/cacert.pem add-br br0], [0])
1352 AT_CHECK([ovs-vsctl -t 5 --no-wait --db=ssl:127.0.0.1:$SSL_PORT --private-key=$PKIDIR/vsctl-privkey.pem --certificate=$PKIDIR/vsctl-cert.pem --bootstrap-ca-cert=$PKIDIR/cacert.pem list-br], [0], [br0
1358 AT_SETUP([peer ca cert])
1359 AT_KEYWORDS([ovs-vsctl ssl])
1360 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
1362 OVS_PKI="sh $abs_top_srcdir/utilities/ovs-pki.in --dir=$PKIDIR/pki --log=$PKIDIR/ovs-pki.log"
1363 AT_CHECK([$OVS_PKI -B 1024 init && $OVS_PKI -B 1024 req+sign vsctl switch && $OVS_PKI -B 1024 req+sign ovsdbserver controller], [0], [ignore], [ignore])
1365 dnl Create database.
1366 OVSDB_INIT([conf.db])
1367 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --private-key=$PKIDIR/ovsdbserver-privkey.pem --certificate=$PKIDIR/ovsdbserver-cert.pem --ca-cert=$PKIDIR/pki/switchca/cacert.pem --peer-ca-cert=$PKIDIR/pki/controllerca/cacert.pem --remote=pssl:0:127.0.0.1 --log-file="`pwd`"/ovsdb-server.log conf.db], [0], [ignore], [ignore])
1368 on_exit "kill `cat ovsdb-server.pid`"
1369 PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT])
1371 # During bootstrap, the connection gets torn down. So the o/p of ovs-vsctl is error.
1372 AT_CHECK([ovs-vsctl -t 5 --db=ssl:127.0.0.1:$SSL_PORT --private-key=$PKIDIR/vsctl-privkey.pem --certificate=$PKIDIR/vsctl-cert.pem --bootstrap-ca-cert=$PKIDIR/cacert.pem show], [1], [ignore], [ignore])
1374 # If the bootstrap was successful, the following file should exist.
1375 OVS_WAIT_UNTIL([test -e $PKIDIR/cacert.pem])
1377 # After bootstrap, the connection should be successful.
1378 AT_CHECK([ovs-vsctl -t 5 --no-wait --db=ssl:127.0.0.1:$SSL_PORT --private-key=$PKIDIR/vsctl-privkey.pem --certificate=$PKIDIR/vsctl-cert.pem --bootstrap-ca-cert=$PKIDIR/cacert.pem add-br br0], [0])
1379 AT_CHECK([ovs-vsctl -t 5 --no-wait --db=ssl:127.0.0.1:$SSL_PORT --private-key=$PKIDIR/vsctl-privkey.pem --certificate=$PKIDIR/vsctl-cert.pem --bootstrap-ca-cert=$PKIDIR/cacert.pem list-br], [0], [br0