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 --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db >/dev/null 2>&1], [0], [ignore], [ignore])])
11 dnl Kills off the database server.
12 m4_define([OVS_VSCTL_CLEANUP], [OVSDB_SERVER_SHUTDOWN])
14 dnl RUN_OVS_VSCTL(COMMAND, ...)
16 dnl Executes each ovs-vsctl COMMAND.
17 m4_define([RUN_OVS_VSCTL],
18 [m4_foreach([command], [$@], [ovs-vsctl --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket -- command
20 m4_define([RUN_OVS_VSCTL_ONELINE],
21 [m4_foreach([command], [$@], [ovs-vsctl --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket --oneline -- command
24 dnl RUN_OVS_VSCTL_TOGETHER(COMMAND, ...)
26 dnl Executes each ovs-vsctl COMMAND in a single run of ovs-vsctl.
27 m4_define([RUN_OVS_VSCTL_TOGETHER],
28 [ovs-vsctl --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket --oneline dnl
29 m4_foreach([command], [$@], [ -- command])])
31 dnl CHECK_BRIDGES([BRIDGE, PARENT, VLAN], ...)
33 dnl Verifies that "ovs-vsctl list-br" prints the specified list of bridges,
34 dnl which must be in alphabetical order. Also checks that each BRIDGE has the
35 dnl specified PARENT and is on the given VLAN.
36 m4_define([_CHECK_BRIDGE],
37 [AT_CHECK([RUN_OVS_VSCTL([br-to-parent $1])], [0], [$2
38 ], [], [OVS_VSCTL_CLEANUP])
40 # Check br-to-vlan, without --oneline.
41 AT_CHECK([RUN_OVS_VSCTL([br-to-vlan $1])], [0], [$3
42 ], [], [OVS_VSCTL_CLEANUP])
43 # Check br-to-vlan, with --oneline.
44 # (This particular test is interesting with --oneline because it returns
45 # an integer instead of a string and that can cause type mismatches inside
46 # python if not done carefully.)
47 AT_CHECK([RUN_OVS_VSCTL_ONELINE([br-to-vlan $1])], [0], [$3
48 ], [], [OVS_VSCTL_CLEANUP])
50 # Check multiple queries in a single run.
51 AT_CHECK([RUN_OVS_VSCTL_TOGETHER([br-to-parent $1], [br-to-vlan $1])], [0],
54 ], [], [OVS_VSCTL_CLEANUP])])
55 m4_define([CHECK_BRIDGES],
56 [dnl Check that the bridges appear on list-br, without --oneline.
58 [RUN_OVS_VSCTL([list-br])],
60 [m4_foreach([brinfo], [$@], [m4_car(brinfo)
65 dnl Check that the bridges appear on list-br, with --oneline.
67 [RUN_OVS_VSCTL_ONELINE([list-br])],
69 [m4_join([\n], m4_foreach([brinfo], [$@], [m4_car(brinfo),]))
74 dnl Check that each bridge exists according to br-exists and that
75 dnl a bridge that should not exist does not.
76 m4_foreach([brinfo], [$@],
77 [AT_CHECK([RUN_OVS_VSCTL([br-exists m4_car(brinfo)])], [0], [],
78 [], [OVS_VSCTL_CLEANUP])])
79 AT_CHECK([RUN_OVS_VSCTL([br-exists nonexistent])], [2], [], [],
82 dnl Check that each bridge has the expected parent and VLAN.
83 m4_map([_CHECK_BRIDGE], [$@])])
85 dnl CHECK_PORTS(BRIDGE, PORT[, PORT...])
87 dnl Verifies that "ovs-vsctl list-ports BRIDGE" prints the specified
88 dnl list of ports, which must be in alphabetical order. Also checks
89 dnl that "ovs-vsctl port-to-br" reports that each port is
91 m4_define([CHECK_PORTS],
92 [dnl Check ports without --oneline.
94 [RUN_OVS_VSCTL([list-ports $1])],
96 [m4_foreach([port], m4_cdr($@), [port
101 dnl Check ports with --oneline.
103 [RUN_OVS_VSCTL_ONELINE([list-ports $1])],
105 [m4_join([\n], m4_shift($@))
109 AT_CHECK([RUN_OVS_VSCTL([port-to-br $1])], [1], [],
110 [ovs-vsctl: no port named $1
115 [AT_CHECK([RUN_OVS_VSCTL([[port-to-br] port])], [0], [$1
116 ], [], [OVS_VSCTL_CLEANUP])])])
118 dnl CHECK_IFACES(BRIDGE, IFACE[, IFACE...])
120 dnl Verifies that "ovs-vsctl list-ifaces BRIDGE" prints the specified
121 dnl list of ifaces, which must be in alphabetical order. Also checks
122 dnl that "ovs-vsctl iface-to-br" reports that each interface is
124 m4_define([CHECK_IFACES],
126 [RUN_OVS_VSCTL([list-ifaces $1])],
128 [m4_foreach([iface], m4_cdr($@), [iface
132 AT_CHECK([RUN_OVS_VSCTL([iface-to-br $1])], [1], [],
133 [ovs-vsctl: no interface named $1
138 [AT_CHECK([RUN_OVS_VSCTL([[iface-to-br] iface])], [0], [$1
140 [], [OVS_VSCTL_CLEANUP])])])
142 dnl ----------------------------------------------------------------------
143 AT_BANNER([ovs-vsctl unit tests -- real bridges])
146 AT_KEYWORDS([ovs-vsctl])
148 AT_CHECK([RUN_OVS_VSCTL([add-br a])], [0], [], [], [OVS_VSCTL_CLEANUP])
149 CHECK_BRIDGES([a, a, 0])
155 AT_SETUP([add-br a, add-br a])
156 AT_KEYWORDS([ovs-vsctl])
158 AT_CHECK([RUN_OVS_VSCTL([add-br a])], [0], [], [], [OVS_VSCTL_CLEANUP])
159 AT_CHECK([RUN_OVS_VSCTL([add-br a])], [1], [],
160 [ovs-vsctl: cannot create a bridge named a because a bridge named a already exists
161 ], [OVS_VSCTL_CLEANUP])
165 AT_SETUP([add-br a, add-br b])
166 AT_KEYWORDS([ovs-vsctl])
168 AT_CHECK([RUN_OVS_VSCTL([add-br a], [add-br b])], [0], [], [],
170 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br a b 9])], [1], [],
171 [ovs-vsctl: "--may-exist add-br a b 9" but a is not a VLAN bridge
174 CHECK_BRIDGES([a, a, 0], [b, b, 0])
182 AT_SETUP([add-br a, add-br b, del-br a])
183 AT_KEYWORDS([ovs-vsctl])
185 AT_CHECK([RUN_OVS_VSCTL([add-br a], [add-br b], [del-br a])], [0], [], [],
187 CHECK_BRIDGES([b, b, 0])
193 AT_SETUP([add-br a, del-br a, add-br a])
194 AT_KEYWORDS([ovs-vsctl])
196 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
200 [set Interface a other_config:key=value],
201 [get Interface a other_config:key])], [0], [
206 ], [], [OVS_VSCTL_CLEANUP])
207 CHECK_BRIDGES([a, a, 0])
213 AT_SETUP([add-br a, add-port a a1, add-port a a2])
214 AT_KEYWORDS([ovs-vsctl])
216 AT_CHECK([RUN_OVS_VSCTL(
218 [--if-exists del-br b],
220 [add-port a a2])], [0], [], [], [OVS_VSCTL_CLEANUP])
221 CHECK_BRIDGES([a, a, 0])
222 CHECK_PORTS([a], [a1], [a2])
223 CHECK_IFACES([a], [a1], [a2])
227 AT_SETUP([add-br a, add-port a a1, add-port a a1])
228 AT_KEYWORDS([ovs-vsctl])
230 AT_CHECK([RUN_OVS_VSCTL(
232 [add-port a a1])], [0], [], [], [OVS_VSCTL_CLEANUP])
233 AT_CHECK([RUN_OVS_VSCTL([add-port a a1])], [1], [],
234 [ovs-vsctl: cannot create a port named a1 because a port named a1 already exists on bridge a
235 ], [OVS_VSCTL_CLEANUP])
239 AT_SETUP([add-br a b, add-port a a1, add-port b b1, del-br a])
240 AT_KEYWORDS([ovs-vsctl])
242 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
247 [--if-exists del-port b b2],
254 ], [], [OVS_VSCTL_CLEANUP])
255 CHECK_BRIDGES([b, b, 0])
256 CHECK_PORTS([b], [b1])
257 CHECK_IFACES([b], [b1])
261 AT_SETUP([add-br a, add-bond a bond0 a1 a2 a3])
262 AT_KEYWORDS([ovs-vsctl])
264 AT_CHECK([RUN_OVS_VSCTL(
266 [add-bond a bond0 a1 a2 a3])], [0], [], [], [OVS_VSCTL_CLEANUP])
267 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-bond a bond0 a3 a1 a2])], [0], [], [],
269 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-bond a bond0 a2 a1])], [1], [],
270 [ovs-vsctl: "--may-exist add-bond a bond0 a2 a1" but bond0 actually has interface(s) a1, a2, a3
273 CHECK_BRIDGES([a, a, 0])
274 CHECK_PORTS([a], [bond0])
275 CHECK_IFACES([a], [a1], [a2], [a3])
279 AT_SETUP([add-br a b, add-port a a1, add-port b b1, del-port a a1])
280 AT_KEYWORDS([ovs-vsctl])
282 AT_CHECK([RUN_OVS_VSCTL(
285 [add-port a a1 tag=9],
287 [--may-exist add-port b b1],
288 [del-port a a1])], [0], [9
289 ], [], [OVS_VSCTL_CLEANUP])
290 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-port b b1])], [0], [], [],
292 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-port a b1])], [1], [],
293 [ovs-vsctl: "--may-exist add-port a b1" but b1 is actually attached to bridge b
296 CHECK_BRIDGES([a, a, 0], [b, b, 0])
299 CHECK_PORTS([b], [b1])
300 CHECK_IFACES([b], [b1])
304 AT_SETUP([add-br a, add-bond a bond0 a1 a2 a3, del-port bond0])
305 AT_KEYWORDS([ovs-vsctl])
307 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
309 [add-bond a bond0 a1 a2 a3 tag=9],
310 [get Port bond0 tag],
311 [del-port bond0])], [0], [
315 ], [], [OVS_VSCTL_CLEANUP])
316 CHECK_BRIDGES([a, a, 0])
321 AT_SETUP([external IDs])
322 AT_KEYWORDS([ovs-vsctl])
324 AT_CHECK([RUN_OVS_VSCTL_ONELINE(
327 [add-bond a bond0 a2 a3],
328 [br-set-external-id a key0 value0],
329 [set port a1 external-ids:key1=value1],
330 [set interface a2 external-ids:key2=value2],
331 [set interface a2 external-ids:key3=value3],
332 [set interface a3 external-ids:key4=value4],
333 [br-get-external-id a],
334 [br-get-external-id a key0],
335 [br-get-external-id a key1],
336 [br-set-external-id a key0 othervalue],
337 [br-get-external-id a],
338 [br-set-external-id a key0],
339 [br-get-external-id a],
340 [get port a1 external-ids],
341 [get interface a2 external-ids],
342 [get interface a3 external-ids])], [0], [
358 {"key2"="value2", "key3"="value3"}
360 ], [], [OVS_VSCTL_CLEANUP])
361 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
362 [br-get-external-id a],
363 [get port a1 external-ids],
364 [get interface a2 external-ids],
365 [get interface a3 external-ids])], [0],
368 {"key2"="value2", "key3"="value3"}
370 ], [], [OVS_VSCTL_CLEANUP])
371 CHECK_BRIDGES([a, a, 0])
372 CHECK_PORTS([a], [a1], [bond0])
373 CHECK_IFACES([a], [a1], [a2], [a3])
377 AT_SETUP([controllers])
378 AT_KEYWORDS([controller ovs-vsctl])
380 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
383 [get-controller br0],
384 [set-controller br0 tcp:4.5.6.7],
385 [get-controller br0],
387 [del-controller br0],
388 [get-controller br0],
390 [set-controller br0 tcp:8.9.10.11 tcp:5.4.3.2],
391 [get-controller br0])], [0], [
398 tcp:5.4.3.2\ntcp:8.9.10.11
399 ], [], [OVS_VSCTL_CLEANUP])
403 dnl ----------------------------------------------------------------------
404 dnl OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([VLAN])
405 m4_define([OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF],
409 [--may-exist add-br xenbr0],
410 [add-port xenbr0 eth0],
411 [--may-exist add-port xenbr0 eth0],
412 [add-br xapi1 xenbr0 $1],
413 [--may-exist add-br xapi1 xenbr0 $1],
414 [add-port xapi1 eth0.$1])],
415 [0], [], [], [OVS_VSCTL_CLEANUP])])
417 dnl OVS_VSCTL_FAKE_BRIDGE_TESTS([VLAN])
418 m4_define([OVS_VSCTL_FAKE_BRIDGE_TESTS], [
419 AT_BANNER([ovs-vsctl unit tests -- fake bridges (VLAN $1)])
421 AT_SETUP([simple fake bridge (VLAN $1)])
422 AT_KEYWORDS([ovs-vsctl fake-bridge])
424 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
425 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1])], [1], [],
426 [ovs-vsctl: "--may-exist add-br xapi1" but xapi1 is a VLAN bridge for VLAN $1
427 ], [OVS_VSCTL_CLEANUP])
428 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1 xxx $1])], [1], [],
429 [ovs-vsctl: "--may-exist add-br xapi1 xxx $1" but xapi1 has the wrong parent xenbr0
430 ], [OVS_VSCTL_CLEANUP])
431 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1 xenbr0 10])], [1], [],
432 [ovs-vsctl: "--may-exist add-br xapi1 xenbr0 10" but xapi1 is a VLAN bridge for the wrong VLAN $1
433 ], [OVS_VSCTL_CLEANUP])
434 CHECK_BRIDGES([xapi1, xenbr0, $1], [xenbr0, xenbr0, 0])
435 CHECK_PORTS([xenbr0], [eth0])
436 CHECK_IFACES([xenbr0], [eth0])
437 CHECK_PORTS([xapi1], [eth0.$1])
438 CHECK_IFACES([xapi1], [eth0.$1])
442 AT_SETUP([simple fake bridge + del-br fake bridge (VLAN $1)])
443 AT_KEYWORDS([ovs-vsctl fake-bridge])
445 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
446 AT_CHECK([RUN_OVS_VSCTL([del-br xapi1])], [0], [], [], [OVS_VSCTL_CLEANUP])
447 CHECK_BRIDGES([xenbr0, xenbr0, 0])
448 CHECK_PORTS([xenbr0], [eth0])
449 CHECK_IFACES([xenbr0], [eth0])
453 AT_SETUP([simple fake bridge + del-br real bridge (VLAN $1)])
454 AT_KEYWORDS([ovs-vsctl fake-bridge])
456 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
457 AT_CHECK([RUN_OVS_VSCTL([del-br xenbr0])], [0], [], [], [OVS_VSCTL_CLEANUP])
462 AT_SETUP([simple fake bridge + external IDs (VLAN $1)])
463 AT_KEYWORDS([ovs-vsctl fake-bridge])
465 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
466 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
467 [br-set-external-id xenbr0 key0 value0],
468 [br-set-external-id xapi1 key1 value1],
469 [br-get-external-id xenbr0],
470 [br-get-external-id xenbr0 key0],
471 [br-get-external-id xapi1],
472 [br-get-external-id xapi1 key1])], [0], [
478 ], [], [OVS_VSCTL_CLEANUP])
479 CHECK_BRIDGES([xapi1, xenbr0, $1], [xenbr0, xenbr0, 0])
480 CHECK_PORTS([xenbr0], [eth0])
481 CHECK_IFACES([xenbr0], [eth0])
482 CHECK_PORTS([xapi1], [eth0.$1])
483 CHECK_IFACES([xapi1], [eth0.$1])
486 ]) # OVS_VSCTL_FAKE_BRIDGE_TESTS
488 OVS_VSCTL_FAKE_BRIDGE_TESTS([9])
489 OVS_VSCTL_FAKE_BRIDGE_TESTS([0])
491 dnl OVS_VSCTL_SETUP_BOND_FAKE_CONF([VLAN])
492 m4_define([OVS_VSCTL_SETUP_BOND_FAKE_CONF],
496 [add-bond xapi1 bond0 eth0 eth1],
497 [add-br xapi2 xapi1 $1],
498 [add-port xapi2 bond0.$1])],
499 [0], [], [], [OVS_VSCTL_CLEANUP])])
501 AT_SETUP([fake bridge on bond])
502 AT_KEYWORDS([ovs-vsctl fake-bridge])
504 OVS_VSCTL_SETUP_BOND_FAKE_CONF([11])
505 CHECK_BRIDGES([xapi1, xapi1, 0], [xapi2, xapi1, 11])
506 CHECK_PORTS([xapi1], [bond0])
507 CHECK_IFACES([xapi1], [eth0], [eth1])
508 CHECK_PORTS([xapi2], [bond0.11])
509 CHECK_IFACES([xapi2], [bond0.11])
513 AT_SETUP([fake bridge on bond + del-br fake bridge])
514 AT_KEYWORDS([ovs-vsctl fake-bridge])
516 OVS_VSCTL_SETUP_BOND_FAKE_CONF([11])
517 AT_CHECK([RUN_OVS_VSCTL_ONELINE([del-br xapi2])], [0], [
518 ], [], [OVS_VSCTL_CLEANUP])
519 CHECK_BRIDGES([xapi1, xapi1, 0])
520 CHECK_PORTS([xapi1], [bond0])
521 CHECK_IFACES([xapi1], [eth0], [eth1])
525 AT_SETUP([fake bridge on bond + del-br real bridge])
526 AT_KEYWORDS([ovs-vsctl fake-bridge])
528 OVS_VSCTL_SETUP_BOND_FAKE_CONF([11])
529 AT_CHECK([RUN_OVS_VSCTL([del-br xapi1])])
534 dnl ----------------------------------------------------------------------
535 AT_BANNER([ovs-vsctl unit tests -- manager commands])
538 AT_KEYWORDS([manager ovs-vsctl])
540 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
543 [set-manager tcp:4.5.6.7],
545 [set-manager tcp:8.9.10.11 tcp:5.4.3.2],
548 [get-manager])], [0], [
553 tcp:5.4.3.2\ntcp:8.9.10.11
556 ], [], [OVS_VSCTL_CLEANUP])
560 dnl ----------------------------------------------------------------------
561 AT_BANNER([ovs-vsctl unit tests -- database commands])
563 AT_SETUP([database commands -- positive checks])
564 AT_KEYWORDS([ovs-vsctl])
567 [RUN_OVS_VSCTL_TOGETHER([--id=@br0 create b name=br0],
568 [set o . bridges=@br0])],
569 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
571 AT_CHECK([RUN_OVS_VSCTL([list b], [get b br0 _uuid])],
572 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
574 AT_CHECK([perl $srcdir/uuidfilt.pl out1 out2], [0],
594 ]], [ignore], [test ! -e pid || kill `cat pid`])
596 [RUN_OVS_VSCTL([--columns=fail_mode,name,datapath_type list b])],
601 ]], [ignore], [test ! -e pid || kill `cat pid`])
603 [RUN_OVS_VSCTL([--columns=fail_mode,name,datapath_type find b])],
608 ]], [ignore], [test ! -e pid || kill `cat pid`])
610 RUN_OVS_VSCTL_TOGETHER([--id=@br1 create b name=br1 datapath_type="foo"],
611 [--id=@br2 create b name=br2 external-ids:bar=quux],
612 [add o . bridges @br1 @br2])],
613 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
615 [RUN_OVS_VSCTL([--columns=name find b datapath_type!=foo])], [0], [stdout],
616 [ignore], [test ! -e pid || kill `cat pid`])
617 AT_CHECK([sed -n '/./p' stdout | sort], [0],
624 'other_config:datapath_id="0123456789ab"' \
625 'other_config:hwaddr="00:11:22:33:44:55"' \
626 'external-ids={"uuids"="9c45f225-a7cf-439d-976d-83db6271fda1"}' -- \
627 add bridge br0 external_ids '"roles"="local; remote; cloud"'])],
628 [0], [], [], [OVS_VSCTL_CLEANUP])
629 AT_CHECK([RUN_OVS_VSCTL_ONELINE([get bridge br0 other_config external-ids])],
630 [0], [{datapath_id="0123456789ab", hwaddr="00:11:22:33:44:55"}\n{roles="local; remote; cloud", uuids="9c45f225-a7cf-439d-976d-83db6271fda1"}
631 ], [], [OVS_VSCTL_CLEANUP])
632 AT_CHECK([RUN_OVS_VSCTL([get bridge br0 other_config:hwaddr -- --if-exists get bridge br0 other-config:nonexistent])],
633 [0], ["00:11:22:33:44:55"
635 ], [], [OVS_VSCTL_CLEANUP])
636 AT_CHECK([RUN_OVS_VSCTL([remove br br0 other_config hwaddr 'datapath_id=""' -- get br br0 other_config])],
637 [0], [{datapath_id="0123456789ab"}
638 ], [], [OVS_VSCTL_CLEANUP])
639 AT_CHECK([RUN_OVS_VSCTL([remove br br0 other_config 'datapath_id="0123456789ab"' -- get br br0 other_config])],
641 ], [], [OVS_VSCTL_CLEANUP])
642 AT_CHECK([RUN_OVS_VSCTL([clear br br0 external-ids -- get br br0 external_ids])],
644 ], [], [OVS_VSCTL_CLEANUP])
645 AT_CHECK([RUN_OVS_VSCTL_TOGETHER([destroy b br0],
648 [clear o . bridges])],
649 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
650 AT_CHECK([RUN_OVS_VSCTL([list b])],
651 [0], [], [], [OVS_VSCTL_CLEANUP])
655 AT_SETUP([database commands -- negative checks])
656 AT_KEYWORDS([ovs-vsctl])
658 AT_CHECK([RUN_OVS_VSCTL([add-br br0])],
659 [0], [ignore], [], [OVS_VSCTL_CLEANUP])
660 AT_CHECK([RUN_OVS_VSCTL([add-br br1])],
661 [0], [ignore], [], [OVS_VSCTL_CLEANUP])
662 AT_CHECK([RUN_OVS_VSCTL([set-controller br1 tcp:127.0.0.1])],
663 [0], [ignore], [], [OVS_VSCTL_CLEANUP])
665 RUN_OVS_VSCTL_TOGETHER([--id=@n create netflow targets='"1.2.3.4:567"'],
666 [set bridge br0 netflow=@n])],
667 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
668 cp stdout netflow-uuid
669 AT_CHECK([RUN_OVS_VSCTL([list netflow `cat netflow-uuid`])],
670 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
671 AT_CHECK([perl $srcdir/uuidfilt.pl netflow-uuid stdout], [0],
676 add_id_to_interface : false
680 targets : ["1.2.3.4:567"]
681 ]], [ignore], [test ! -e pid || kill `cat pid`])
682 AT_CHECK([RUN_OVS_VSCTL([list interx x])],
683 [1], [], [ovs-vsctl: unknown table "interx"
684 ], [OVS_VSCTL_CLEANUP])
685 AT_CHECK([RUN_OVS_VSCTL([list b x])],
686 [1], [], [ovs-vsctl: no row "x" in table Bridge
687 ], [OVS_VSCTL_CLEANUP])
688 AT_CHECK([RUN_OVS_VSCTL([get b br0 d])],
689 [1], [], [ovs-vsctl: Bridge contains more than one column whose name matches "d"
690 ], [OVS_VSCTL_CLEANUP])
691 AT_CHECK([RUN_OVS_VSCTL([get b br0 x])],
692 [1], [], [ovs-vsctl: Bridge does not contain a column whose name matches "x"
693 ], [OVS_VSCTL_CLEANUP])
694 AT_CHECK([RUN_OVS_VSCTL([get b br0 :y=z])],
695 [1], [], [ovs-vsctl: :y=z: missing column name
696 ], [OVS_VSCTL_CLEANUP])
697 AT_CHECK([RUN_OVS_VSCTL([get b br0 datapath_id:y=z])],
698 [1], [], [ovs-vsctl: datapath_id:y=z: trailing garbage "=z" in argument
699 ], [OVS_VSCTL_CLEANUP])
700 AT_CHECK([RUN_OVS_VSCTL([set b br0 'datapath_id:y>=z'])],
701 [1], [], [ovs-vsctl: datapath_id:y>=z: argument does not end in "=" followed by a value.
702 ], [OVS_VSCTL_CLEANUP])
703 AT_CHECK([RUN_OVS_VSCTL([wait-until b br0 datapath_id:y,z])],
704 [1], [], [ovs-vsctl: datapath_id:y,z: argument does not end in "=", "!=", "<", ">", "<=", ">=", "{=}", "{!=}", "{<}", "{>}", "{<=}", or "{>=}" followed by a value.
705 ], [OVS_VSCTL_CLEANUP])
706 AT_CHECK([RUN_OVS_VSCTL([get b br0 datapath_id::])],
707 [1], [], [ovs-vsctl: datapath_id::: trailing garbage ":" in argument
708 ], [OVS_VSCTL_CLEANUP])
709 AT_CHECK([RUN_OVS_VSCTL([get b br0 datapath_id:x])],
710 [1], [], [ovs-vsctl: cannot specify key to get for non-map column datapath_id
711 ], [OVS_VSCTL_CLEANUP])
712 AT_CHECK([RUN_OVS_VSCTL([get b br0 external_ids:x])],
713 [1], [], [ovs-vsctl: no key "x" in Bridge record "br0" column external_ids
714 ], [OVS_VSCTL_CLEANUP])
715 AT_CHECK([RUN_OVS_VSCTL([set b br0 flood_vlans=-1])],
716 [1], [], [ovs-vsctl: constraint violation: -1 is not in the valid range 0 to 4095 (inclusive)
717 ], [OVS_VSCTL_CLEANUP])
718 AT_CHECK([RUN_OVS_VSCTL([set b br0 flood_vlans=4096])],
719 [1], [], [ovs-vsctl: constraint violation: 4096 is not in the valid range 0 to 4095 (inclusive)
720 ], [OVS_VSCTL_CLEANUP])
721 AT_CHECK([RUN_OVS_VSCTL([set c br1 'connection-mode=xyz'])],
722 [1], [], [[ovs-vsctl: constraint violation: xyz is not one of the allowed values ([in-band, out-of-band])
723 ]], [OVS_VSCTL_CLEANUP])
724 AT_CHECK([RUN_OVS_VSCTL([set c br1 connection-mode:x=y])],
725 [1], [], [ovs-vsctl: cannot specify key to set for non-map column connection_mode
726 ], [OVS_VSCTL_CLEANUP])
727 AT_CHECK([RUN_OVS_VSCTL([add b br1 datapath_id x y])],
728 [1], [], [ovs-vsctl: "add" operation would put 2 values in column datapath_id of table Bridge but the maximum number is 1
729 ], [OVS_VSCTL_CLEANUP])
730 AT_CHECK([RUN_OVS_VSCTL([remove netflow `cat netflow-uuid` targets '"1.2.3.4:567"'])],
731 [1], [], [ovs-vsctl: "remove" operation would put 0 values in column targets of table NetFlow but the minimum number is 1
732 ], [OVS_VSCTL_CLEANUP])
733 AT_CHECK([RUN_OVS_VSCTL([clear netflow `cat netflow-uuid` targets])],
734 [1], [], [ovs-vsctl: "clear" operation cannot be applied to column targets of table NetFlow, which is not allowed to be empty
735 ], [OVS_VSCTL_CLEANUP])
736 AT_CHECK([RUN_OVS_VSCTL([destroy b br2])],
737 [1], [], [ovs-vsctl: no row "br2" in table Bridge
738 ], [OVS_VSCTL_CLEANUP])
742 AT_SETUP([database commands -- conditions])
743 AT_KEYWORDS([ovs-vsctl])
744 trap 'kill `cat pid`' 0
747 [RUN_OVS_VSCTL_TOGETHER(
749 [add-br br1], [set bridge br1 flood_vlans=0 other-config:x='""'],
750 [add-br br2], [set bridge br2 flood_vlans=1 other-config:x=y],
751 [add-br br3], [set bridge br3 flood_vlans=0,1 other-config:x=z],
752 [add-br br4], [set bridge br4 flood_vlans=2],
753 [add-br br5], [set bridge br5 flood_vlans=0,2],
754 [add-br br6], [set bridge br6 flood_vlans=1,2],
755 [add-br br7], [set bridge br7 flood_vlans=0,1,2])], [0], [
771 m4_define([VSCTL_CHECK_FIND],
772 [AT_CHECK([ovs-vsctl --bare --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket -- --columns=name find bridge '$1' | sort | xargs echo], [0], [$2
775 # Arithmetic relational operators without keys.
776 VSCTL_CHECK_FIND([flood_vlans=0], [br1])
777 VSCTL_CHECK_FIND([flood_vlans=1], [br2])
778 VSCTL_CHECK_FIND([flood_vlans=0,2], [br5])
779 VSCTL_CHECK_FIND([flood_vlans=0,1,2], [br7])
780 VSCTL_CHECK_FIND([flood_vlans=3], [])
782 VSCTL_CHECK_FIND([flood_vlans!=0], [br0 br2 br3 br4 br5 br6 br7])
783 VSCTL_CHECK_FIND([flood_vlans!=1], [br0 br1 br3 br4 br5 br6 br7])
784 VSCTL_CHECK_FIND([flood_vlans!=0,2], [br0 br1 br2 br3 br4 br6 br7])
785 VSCTL_CHECK_FIND([flood_vlans!=0,1,2], [br0 br1 br2 br3 br4 br5 br6])
786 VSCTL_CHECK_FIND([flood_vlans!=3], [br0 br1 br2 br3 br4 br5 br6 br7])
788 VSCTL_CHECK_FIND([flood_vlans<2], [br0 br1 br2])
789 VSCTL_CHECK_FIND([flood_vlans<0,2], [br0 br1 br2 br3 br4])
790 VSCTL_CHECK_FIND([flood_vlans>1], [br3 br4 br5 br6 br7])
791 VSCTL_CHECK_FIND([flood_vlans>0,1], [br5 br6 br7])
792 VSCTL_CHECK_FIND([flood_vlans<=2], [br0 br1 br2 br4])
793 VSCTL_CHECK_FIND([flood_vlans<=0,2], [br0 br1 br2 br3 br4 br5])
794 VSCTL_CHECK_FIND([flood_vlans>=1], [br2 br3 br4 br5 br6 br7])
795 VSCTL_CHECK_FIND([flood_vlans>=0,1], [br3 br5 br6 br7])
797 # Set relational operators without keys.
798 VSCTL_CHECK_FIND([flood_vlans{=}0], [br1])
799 VSCTL_CHECK_FIND([flood_vlans{=}1], [br2])
800 VSCTL_CHECK_FIND([flood_vlans{=}0,2], [br5])
801 VSCTL_CHECK_FIND([flood_vlans{=}0,1,2], [br7])
802 VSCTL_CHECK_FIND([flood_vlans{=}3], [])
804 VSCTL_CHECK_FIND([flood_vlans{!=}0], [br0 br2 br3 br4 br5 br6 br7])
805 VSCTL_CHECK_FIND([flood_vlans{!=}1], [br0 br1 br3 br4 br5 br6 br7])
806 VSCTL_CHECK_FIND([flood_vlans{!=}0,2], [br0 br1 br2 br3 br4 br6 br7])
807 VSCTL_CHECK_FIND([flood_vlans{!=}0,1,2], [br0 br1 br2 br3 br4 br5 br6])
808 VSCTL_CHECK_FIND([flood_vlans{!=}3], [br0 br1 br2 br3 br4 br5 br6 br7])
810 VSCTL_CHECK_FIND([flood_vlans{<}[[]]], [])
811 VSCTL_CHECK_FIND([flood_vlans{<=}[[]]], [br0])
812 VSCTL_CHECK_FIND([flood_vlans{<}0], [br0])
813 VSCTL_CHECK_FIND([flood_vlans{<=}0], [br0 br1])
814 VSCTL_CHECK_FIND([flood_vlans{<}1,2], [br0 br2 br4])
815 VSCTL_CHECK_FIND([flood_vlans{<=}1,2], [br0 br2 br4 br6])
817 VSCTL_CHECK_FIND([flood_vlans{>}[[]]], [br1 br2 br3 br4 br5 br6 br7])
818 VSCTL_CHECK_FIND([flood_vlans{>=}[[]]], [br0 br1 br2 br3 br4 br5 br6 br7])
819 VSCTL_CHECK_FIND([flood_vlans{>}0], [br3 br5 br7])
820 VSCTL_CHECK_FIND([flood_vlans{>=}0], [br1 br3 br5 br7])
821 VSCTL_CHECK_FIND([flood_vlans{>}0,2], [br7])
822 VSCTL_CHECK_FIND([flood_vlans{>=}1,2], [br6 br7])
823 VSCTL_CHECK_FIND([flood_vlans{>=}0,2], [br5 br7])
825 # Arithmetic relational operators with keys.
826 VSCTL_CHECK_FIND([other-config:x=""], [br1])
827 VSCTL_CHECK_FIND([other-config:x=y], [br2])
828 VSCTL_CHECK_FIND([other-config:x=z], [br3])
830 VSCTL_CHECK_FIND([other-config:x!=""], [br2 br3])
831 VSCTL_CHECK_FIND([other-config:x!=y], [br1 br3])
832 VSCTL_CHECK_FIND([other-config:x!=z], [br1 br2])
834 VSCTL_CHECK_FIND([other-config:x>y], [br3])
835 VSCTL_CHECK_FIND([other-config:x>=y], [br2 br3])
836 VSCTL_CHECK_FIND([other-config:x<y], [br1])
837 VSCTL_CHECK_FIND([other-config:x<=y], [br1 br2])
839 # Set relational operators with keys.
840 VSCTL_CHECK_FIND([other-config:x{=}[[]]], [br0 br4 br5 br6 br7])
841 VSCTL_CHECK_FIND([other-config:x{=}""], [br1])
842 VSCTL_CHECK_FIND([other-config:x{=}y], [br2])
843 VSCTL_CHECK_FIND([other-config:x{=}z], [br3])
845 VSCTL_CHECK_FIND([other-config:x{!=}[[]]], [br1 br2 br3])
846 VSCTL_CHECK_FIND([other-config:x{!=}""], [br0 br2 br3 br4 br5 br6 br7])
847 VSCTL_CHECK_FIND([other-config:x{!=}y], [br0 br1 br3 br4 br5 br6 br7])
848 VSCTL_CHECK_FIND([other-config:x{!=}z], [br0 br1 br2 br4 br5 br6 br7])
850 VSCTL_CHECK_FIND([other-config:x{<=}[[]]], [br0 br4 br5 br6 br7])
851 VSCTL_CHECK_FIND([other-config:x{<=}x], [br0 br4 br5 br6 br7])
852 VSCTL_CHECK_FIND([other-config:x{<=}""], [br0 br1 br4 br5 br6 br7])
853 VSCTL_CHECK_FIND([other-config:x{<=}y], [br0 br2 br4 br5 br6 br7])
854 VSCTL_CHECK_FIND([other-config:x{<=}z], [br0 br3 br4 br5 br6 br7])
855 VSCTL_CHECK_FIND([other-config:x{<=}x,y,z], [br0 br2 br3 br4 br5 br6 br7])
857 VSCTL_CHECK_FIND([other-config:x{<}[[]]], [])
858 VSCTL_CHECK_FIND([other-config:x{<}x], [br0 br4 br5 br6 br7])
859 VSCTL_CHECK_FIND([other-config:x{<}""], [br0 br4 br5 br6 br7])
860 VSCTL_CHECK_FIND([other-config:x{<}y], [br0 br4 br5 br6 br7])
861 VSCTL_CHECK_FIND([other-config:x{<}z], [br0 br4 br5 br6 br7])
863 VSCTL_CHECK_FIND([other-config:x{>=}[[]]], [br0 br1 br2 br3 br4 br5 br6 br7])
864 VSCTL_CHECK_FIND([other-config:x{>=}x], [])
865 VSCTL_CHECK_FIND([other-config:x{>=}""], [br1])
866 VSCTL_CHECK_FIND([other-config:x{>=}y], [br2])
867 VSCTL_CHECK_FIND([other-config:x{>=}z], [br3])
869 VSCTL_CHECK_FIND([other-config:x{>}[[]]], [br1 br2 br3])
870 VSCTL_CHECK_FIND([other-config:x{>}x], [])
871 VSCTL_CHECK_FIND([other-config:x{>}""], [])
872 VSCTL_CHECK_FIND([other-config:x{>}y], [])
873 VSCTL_CHECK_FIND([other-config:x{>}z], [])
876 AT_SETUP([database commands -- wait-until immediately true])
877 AT_KEYWORDS([ovs-vsctl])
879 AT_CHECK([RUN_OVS_VSCTL(
881 [add-bond br0 bond0 eth0 eth1],
882 [set port bond0 bond_updelay=500 other-config:abc=def])],
883 [0], [], [], [OVS_VSCTL_CLEANUP])
884 AT_CHECK([RUN_OVS_VSCTL([[wait-until Open_vSwitch . manager_options=[]]])],
885 [0], [], [], [OVS_VSCTL_CLEANUP])
886 AT_CHECK([RUN_OVS_VSCTL([[wait-until Open_vSwitch . bridges!=[]]])],
887 [0], [], [], [OVS_VSCTL_CLEANUP])
888 AT_CHECK([RUN_OVS_VSCTL([[wait-until Port bond0 other-config:abc=def]])],
889 [0], [], [], [OVS_VSCTL_CLEANUP])
890 AT_CHECK([RUN_OVS_VSCTL([[wait-until port bond0 'bond_updelay>50' 'other-config:abc>d' 'other-config:abc<e']])],
891 [0], [], [], [OVS_VSCTL_CLEANUP])
895 AT_SETUP([database commands -- wait-until must wait])
896 AT_KEYWORDS([ovs-vsctl])
898 # Disable lcov for this test. All the programs running in parallel
899 # race badly on access to profiling data.
905 # Start ovs-vsctls in background.
906 (RUN_OVS_VSCTL([[wait-until o . bridges!=[] -- get bridge br10 other-config:abc]])) > stdout1 &
907 (RUN_OVS_VSCTL([[wait-until bridge br1 -- get bridge br1 other-config:abc]])) > stdout2 &
908 (RUN_OVS_VSCTL([[wait-until b br1 other-config={abc=def} -- get bridge br1 other-config]])) > stdout3 &
909 (RUN_OVS_VSCTL([[wait-until port bond0 'bond_updelay>50' -- get port bond0 bond-updelay]])) > stdout4 &
911 # Give the ovs-vsctls a chance to read the database
914 AT_CHECK([RUN_OVS_VSCTL([add-br br10 -- set bridge br10 other-config:abc=quux])
915 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])],
916 [0], [], [], [OVS_VSCTL_CLEANUP])
918 # Wait for the ovs-vsctls to finish.
922 AT_CHECK([cat stdout1], [0], [quux
923 ], [], [OVS_VSCTL_CLEANUP])
924 AT_CHECK([cat stdout2], [0], [def
925 ], [], [OVS_VSCTL_CLEANUP])
926 AT_CHECK([cat stdout3], [0], [{abc=def}
927 ], [], [OVS_VSCTL_CLEANUP])
928 AT_CHECK([cat stdout4], [0], [500
929 ], [], [OVS_VSCTL_CLEANUP])
934 AT_SETUP([--id option on create, get commands])
935 AT_KEYWORDS([ovs-vsctl])
937 AT_CHECK([RUN_OVS_VSCTL([add-br br0],
939 [add-port br0 eth1])])
941 [RUN_OVS_VSCTL_TOGETHER(
942 [set bridge br0 mirrors=@m],
943 [--id=@eth0 get port eth0],
944 [--id=@eth1 get port eth1],
945 [--id=@m create mirror name=mymirror select-dst-port=@eth0 select-src-port=@eth0 output-port=@eth1])],
946 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
948 [perl $srcdir/uuidfilt.pl stdout], [0], [dnl
954 [], [OVS_VSCTL_CLEANUP])
957 [list port eth0 eth1],
960 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
962 [sed -n -e '/uuid/p' -e '/name/p' -e '/mirrors/p' -e '/select/p' -e '/output/p' < stdout | $srcdir/uuidfilt.pl], [0], [dnl
972 select_dst_port : [<0>]
973 select_src_port : [<0>]
979 [], [OVS_VSCTL_CLEANUP])
983 AT_SETUP([unreferenced record warnings])
984 AT_KEYWORDS([ovs-vsctl])
987 [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket \
988 -- create Bridge name=br0 | $srcdir/uuidfilt.pl],
990 ], [vsctl|WARN|applying "create" command to table Bridge without --id option will have no effect
991 ], [OVS_VSCTL_CLEANUP])
993 [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket \
994 -- --id=@br0 create Bridge name=br0 | $srcdir/uuidfilt.pl],
996 ], [vsctl|WARN|row id "@br0" was created but no reference to it was inserted, so it will not actually appear in the database
997 ], [OVS_VSCTL_CLEANUP])
999 [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket \
1000 -- --id=@eth0_iface create Interface name=eth0 \
1001 -- --id=@eth0 create Port name=eth0 interfaces=@eth0_iface \
1002 -- --id=@m0 create Mirror name=m0 output_port=@eth0 \
1003 -- --id=@br0 create Bridge name=br0 mirrors=@m0 \
1004 -- set Open_vSwitch . bridges=@br0 | $srcdir/uuidfilt.pl],
1009 ], [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
1010 ], [OVS_VSCTL_CLEANUP])
1014 dnl This test really shows a bug -- "create" followed by "list" in
1015 dnl the same execution shows the wrong UUID on the "list" command.
1016 dnl The bug is documented in ovs-vsctl.8.
1017 AT_SETUP([created row UUID is wrong in same execution])
1018 AT_KEYWORDS([ovs-vsctl])
1020 AT_CHECK([RUN_OVS_VSCTL([--id=@br0 create Bridge name=br0 -- add Open_vSwitch . bridges @br0 -- list b])],
1021 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
1022 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0],
1040 ]], [ignore], [test ! -e pid || kill `cat pid`])