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, add-port a a1, add-port a a2])
194 AT_KEYWORDS([ovs-vsctl])
196 AT_CHECK([RUN_OVS_VSCTL(
198 [--if-exists del-br b],
200 [add-port a a2])], [0], [], [], [OVS_VSCTL_CLEANUP])
201 CHECK_BRIDGES([a, a, 0])
202 CHECK_PORTS([a], [a1], [a2])
203 CHECK_IFACES([a], [a1], [a2])
207 AT_SETUP([add-br a, add-port a a1, add-port a a1])
208 AT_KEYWORDS([ovs-vsctl])
210 AT_CHECK([RUN_OVS_VSCTL(
212 [add-port a a1])], [0], [], [], [OVS_VSCTL_CLEANUP])
213 AT_CHECK([RUN_OVS_VSCTL([add-port a a1])], [1], [],
214 [ovs-vsctl: cannot create a port named a1 because a port named a1 already exists on bridge a
215 ], [OVS_VSCTL_CLEANUP])
219 AT_SETUP([add-br a b, add-port a a1, add-port b b1, del-br a])
220 AT_KEYWORDS([ovs-vsctl])
222 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
227 [--if-exists del-port b b2],
234 ], [], [OVS_VSCTL_CLEANUP])
235 CHECK_BRIDGES([b, b, 0])
236 CHECK_PORTS([b], [b1])
237 CHECK_IFACES([b], [b1])
241 AT_SETUP([add-br a, add-bond a bond0 a1 a2 a3])
242 AT_KEYWORDS([ovs-vsctl])
244 AT_CHECK([RUN_OVS_VSCTL(
246 [add-bond a bond0 a1 a2 a3])], [0], [], [], [OVS_VSCTL_CLEANUP])
247 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-bond a bond0 a3 a1 a2])], [0], [], [],
249 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-bond a bond0 a2 a1])], [1], [],
250 [ovs-vsctl: "--may-exist add-bond a bond0 a2 a1" but bond0 actually has interface(s) a1, a2, a3
253 CHECK_BRIDGES([a, a, 0])
254 CHECK_PORTS([a], [bond0])
255 CHECK_IFACES([a], [a1], [a2], [a3])
259 AT_SETUP([add-br a b, add-port a a1, add-port b b1, del-port a a1])
260 AT_KEYWORDS([ovs-vsctl])
262 AT_CHECK([RUN_OVS_VSCTL(
265 [add-port a a1 tag=9],
267 [--may-exist add-port b b1],
268 [del-port a a1])], [0], [9
269 ], [], [OVS_VSCTL_CLEANUP])
270 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-port b b1])], [0], [], [],
272 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-port a b1])], [1], [],
273 [ovs-vsctl: "--may-exist add-port a b1" but b1 is actually attached to bridge b
276 CHECK_BRIDGES([a, a, 0], [b, b, 0])
279 CHECK_PORTS([b], [b1])
280 CHECK_IFACES([b], [b1])
284 AT_SETUP([add-br a, add-bond a bond0 a1 a2 a3, del-port bond0])
285 AT_KEYWORDS([ovs-vsctl])
287 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
289 [add-bond a bond0 a1 a2 a3 tag=9],
290 [get Port bond0 tag],
291 [del-port bond0])], [0], [
295 ], [], [OVS_VSCTL_CLEANUP])
296 CHECK_BRIDGES([a, a, 0])
301 AT_SETUP([external IDs])
302 AT_KEYWORDS([ovs-vsctl])
304 AT_CHECK([RUN_OVS_VSCTL_ONELINE(
307 [add-bond a bond0 a2 a3],
308 [br-set-external-id a key0 value0],
309 [set port a1 external-ids:key1=value1],
310 [set interface a2 external-ids:key2=value2],
311 [set interface a2 external-ids:key3=value3],
312 [set interface a3 external-ids:key4=value4],
313 [br-get-external-id a],
314 [br-get-external-id a key0],
315 [br-get-external-id a key1],
316 [br-set-external-id a key0 othervalue],
317 [br-get-external-id a],
318 [br-set-external-id a key0],
319 [br-get-external-id a],
320 [get port a1 external-ids],
321 [get interface a2 external-ids],
322 [get interface a3 external-ids])], [0], [
338 {"key2"="value2", "key3"="value3"}
340 ], [], [OVS_VSCTL_CLEANUP])
341 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
342 [br-get-external-id a],
343 [get port a1 external-ids],
344 [get interface a2 external-ids],
345 [get interface a3 external-ids])], [0],
348 {"key2"="value2", "key3"="value3"}
350 ], [], [OVS_VSCTL_CLEANUP])
351 CHECK_BRIDGES([a, a, 0])
352 CHECK_PORTS([a], [a1], [bond0])
353 CHECK_IFACES([a], [a1], [a2], [a3])
357 AT_SETUP([controllers])
358 AT_KEYWORDS([controller ovs-vsctl])
360 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
363 [get-controller br0],
364 [set-controller br0 tcp:4.5.6.7],
365 [get-controller br0],
367 [del-controller br0],
368 [get-controller br0],
370 [set-controller br0 tcp:8.9.10.11 tcp:5.4.3.2],
371 [get-controller br0])], [0], [
378 tcp:5.4.3.2\ntcp:8.9.10.11
379 ], [], [OVS_VSCTL_CLEANUP])
383 dnl ----------------------------------------------------------------------
384 AT_BANNER([ovs-vsctl unit tests -- fake bridges])
386 m4_define([OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF],
390 [--may-exist add-br xenbr0],
391 [add-port xenbr0 eth0],
392 [--may-exist add-port xenbr0 eth0],
393 [add-br xapi1 xenbr0 9],
394 [--may-exist add-br xapi1 xenbr0 9],
395 [add-port xapi1 eth0.9])],
396 [0], [], [], [OVS_VSCTL_CLEANUP])])
398 AT_SETUP([simple fake bridge])
399 AT_KEYWORDS([ovs-vsctl fake-bridge])
401 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF
402 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1])], [1], [],
403 [ovs-vsctl: "--may-exist add-br xapi1" but xapi1 is a VLAN bridge for VLAN 9
404 ], [OVS_VSCTL_CLEANUP])
405 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1 xxx 9])], [1], [],
406 [ovs-vsctl: "--may-exist add-br xapi1 xxx 9" but xapi1 has the wrong parent xenbr0
407 ], [OVS_VSCTL_CLEANUP])
408 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1 xenbr0 10])], [1], [],
409 [ovs-vsctl: "--may-exist add-br xapi1 xenbr0 10" but xapi1 is a VLAN bridge for the wrong VLAN 9
410 ], [OVS_VSCTL_CLEANUP])
411 CHECK_BRIDGES([xapi1, xenbr0, 9], [xenbr0, xenbr0, 0])
412 CHECK_PORTS([xenbr0], [eth0])
413 CHECK_IFACES([xenbr0], [eth0])
414 CHECK_PORTS([xapi1], [eth0.9])
415 CHECK_IFACES([xapi1], [eth0.9])
419 AT_SETUP([simple fake bridge + del-br fake bridge])
420 AT_KEYWORDS([ovs-vsctl fake-bridge])
422 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF
423 AT_CHECK([RUN_OVS_VSCTL([del-br xapi1])], [0], [], [], [OVS_VSCTL_CLEANUP])
424 CHECK_BRIDGES([xenbr0, xenbr0, 0])
425 CHECK_PORTS([xenbr0], [eth0])
426 CHECK_IFACES([xenbr0], [eth0])
430 AT_SETUP([simple fake bridge + del-br real bridge])
431 AT_KEYWORDS([ovs-vsctl fake-bridge])
433 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF
434 AT_CHECK([RUN_OVS_VSCTL([del-br xenbr0])], [0], [], [], [OVS_VSCTL_CLEANUP])
439 AT_SETUP([simple fake bridge + external IDs])
440 AT_KEYWORDS([ovs-vsctl fake-bridge])
442 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF
443 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
444 [br-set-external-id xenbr0 key0 value0],
445 [br-set-external-id xapi1 key1 value1],
446 [br-get-external-id xenbr0],
447 [br-get-external-id xenbr0 key0],
448 [br-get-external-id xapi1],
449 [br-get-external-id xapi1 key1])], [0], [
455 ], [], [OVS_VSCTL_CLEANUP])
456 CHECK_BRIDGES([xapi1, xenbr0, 9], [xenbr0, xenbr0, 0])
457 CHECK_PORTS([xenbr0], [eth0])
458 CHECK_IFACES([xenbr0], [eth0])
459 CHECK_PORTS([xapi1], [eth0.9])
460 CHECK_IFACES([xapi1], [eth0.9])
464 m4_define([OVS_VSCTL_SETUP_BOND_FAKE_CONF],
468 [add-bond xapi1 bond0 eth0 eth1],
469 [add-br xapi2 xapi1 11],
470 [add-port xapi2 bond0.11])],
471 [0], [], [], [OVS_VSCTL_CLEANUP])])
473 AT_SETUP([fake bridge on bond])
474 AT_KEYWORDS([ovs-vsctl fake-bridge])
476 OVS_VSCTL_SETUP_BOND_FAKE_CONF
477 CHECK_BRIDGES([xapi1, xapi1, 0], [xapi2, xapi1, 11])
478 CHECK_PORTS([xapi1], [bond0])
479 CHECK_IFACES([xapi1], [eth0], [eth1])
480 CHECK_PORTS([xapi2], [bond0.11])
481 CHECK_IFACES([xapi2], [bond0.11])
485 AT_SETUP([fake bridge on bond + del-br fake bridge])
486 AT_KEYWORDS([ovs-vsctl fake-bridge])
488 OVS_VSCTL_SETUP_BOND_FAKE_CONF
489 AT_CHECK([RUN_OVS_VSCTL_ONELINE([del-br xapi2])], [0], [
490 ], [], [OVS_VSCTL_CLEANUP])
491 CHECK_BRIDGES([xapi1, xapi1, 0])
492 CHECK_PORTS([xapi1], [bond0])
493 CHECK_IFACES([xapi1], [eth0], [eth1])
497 AT_SETUP([fake bridge on bond + del-br real bridge])
498 AT_KEYWORDS([ovs-vsctl fake-bridge])
500 OVS_VSCTL_SETUP_BOND_FAKE_CONF
501 AT_CHECK([RUN_OVS_VSCTL([del-br xapi1])])
506 dnl ----------------------------------------------------------------------
507 AT_BANNER([ovs-vsctl unit tests -- manager commands])
510 AT_KEYWORDS([manager ovs-vsctl])
512 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
515 [set-manager tcp:4.5.6.7],
517 [set-manager tcp:8.9.10.11 tcp:5.4.3.2],
520 [get-manager])], [0], [
525 tcp:5.4.3.2\ntcp:8.9.10.11
528 ], [], [OVS_VSCTL_CLEANUP])
532 dnl ----------------------------------------------------------------------
533 AT_BANNER([ovs-vsctl unit tests -- database commands])
535 AT_SETUP([database commands -- positive checks])
536 AT_KEYWORDS([ovs-vsctl])
539 [RUN_OVS_VSCTL_TOGETHER([--id=@br0 create b name=br0],
540 [set o . bridges=@br0])],
541 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
543 AT_CHECK([RUN_OVS_VSCTL([list b], [get b br0 _uuid])],
544 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
546 AT_CHECK([perl $srcdir/uuidfilt.pl out1 out2], [0],
563 ]], [ignore], [test ! -e pid || kill `cat pid`])
565 [RUN_OVS_VSCTL([--columns=fail_mode,name,datapath_type list b])],
570 ]], [ignore], [test ! -e pid || kill `cat pid`])
572 [RUN_OVS_VSCTL([--columns=fail_mode,name,datapath_type find b])],
577 ]], [ignore], [test ! -e pid || kill `cat pid`])
579 RUN_OVS_VSCTL_TOGETHER([--id=@br1 create b name=br1 datapath_type="foo"],
580 [--id=@br2 create b name=br2 external-ids:bar=quux],
581 [add o . bridges @br1 @br2])],
582 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
584 [RUN_OVS_VSCTL([--columns=name find b datapath_type!=foo])], [0], [stdout],
585 [ignore], [test ! -e pid || kill `cat pid`])
586 AT_CHECK([sed -n '/./p' stdout | sort], [0],
593 'other_config:datapath_id="0123456789ab"' \
594 'other_config:hwaddr="00:11:22:33:44:55"' \
595 'external-ids={"uuids"="9c45f225-a7cf-439d-976d-83db6271fda1"}' -- \
596 add bridge br0 external_ids '"roles"="local; remote; cloud"'])],
597 [0], [], [], [OVS_VSCTL_CLEANUP])
598 AT_CHECK([RUN_OVS_VSCTL_ONELINE([get bridge br0 other_config external-ids])],
599 [0], [{datapath_id="0123456789ab", hwaddr="00:11:22:33:44:55"}\n{roles="local; remote; cloud", uuids="9c45f225-a7cf-439d-976d-83db6271fda1"}
600 ], [], [OVS_VSCTL_CLEANUP])
601 AT_CHECK([RUN_OVS_VSCTL([get bridge br0 other_config:hwaddr -- --if-exists get bridge br0 other-config:nonexistent])],
602 [0], ["00:11:22:33:44:55"
604 ], [], [OVS_VSCTL_CLEANUP])
605 AT_CHECK([RUN_OVS_VSCTL([remove br br0 other_config hwaddr 'datapath_id=""' -- get br br0 other_config])],
606 [0], [{datapath_id="0123456789ab"}
607 ], [], [OVS_VSCTL_CLEANUP])
608 AT_CHECK([RUN_OVS_VSCTL([remove br br0 other_config 'datapath_id="0123456789ab"' -- get br br0 other_config])],
610 ], [], [OVS_VSCTL_CLEANUP])
611 AT_CHECK([RUN_OVS_VSCTL([clear br br0 external-ids -- get br br0 external_ids])],
613 ], [], [OVS_VSCTL_CLEANUP])
614 AT_CHECK([RUN_OVS_VSCTL_TOGETHER([destroy b br0],
617 [clear o . bridges])],
618 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
619 AT_CHECK([RUN_OVS_VSCTL([list b])],
620 [0], [], [], [OVS_VSCTL_CLEANUP])
624 AT_SETUP([database commands -- negative checks])
625 AT_KEYWORDS([ovs-vsctl])
627 AT_CHECK([RUN_OVS_VSCTL([add-br br0])],
628 [0], [ignore], [], [OVS_VSCTL_CLEANUP])
629 AT_CHECK([RUN_OVS_VSCTL([add-br br1])],
630 [0], [ignore], [], [OVS_VSCTL_CLEANUP])
631 AT_CHECK([RUN_OVS_VSCTL([set-controller br1 tcp:127.0.0.1])],
632 [0], [ignore], [], [OVS_VSCTL_CLEANUP])
634 RUN_OVS_VSCTL_TOGETHER([--id=@n create n targets='"1.2.3.4:567"'],
635 [set bridge br0 netflow=@n])],
636 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
637 cp stdout netflow-uuid
638 AT_CHECK([RUN_OVS_VSCTL([list n `cat netflow-uuid`])],
639 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
640 AT_CHECK([perl $srcdir/uuidfilt.pl netflow-uuid stdout], [0],
645 add_id_to_interface : false
649 targets : ["1.2.3.4:567"]
650 ]], [ignore], [test ! -e pid || kill `cat pid`])
651 AT_CHECK([RUN_OVS_VSCTL([list interx x])],
652 [1], [], [ovs-vsctl: unknown table "interx"
653 ], [OVS_VSCTL_CLEANUP])
654 AT_CHECK([RUN_OVS_VSCTL([list b x])],
655 [1], [], [ovs-vsctl: no row "x" in table Bridge
656 ], [OVS_VSCTL_CLEANUP])
657 AT_CHECK([RUN_OVS_VSCTL([get b br0 d])],
658 [1], [], [ovs-vsctl: Bridge contains more than one column whose name matches "d"
659 ], [OVS_VSCTL_CLEANUP])
660 AT_CHECK([RUN_OVS_VSCTL([get b br0 x])],
661 [1], [], [ovs-vsctl: Bridge does not contain a column whose name matches "x"
662 ], [OVS_VSCTL_CLEANUP])
663 AT_CHECK([RUN_OVS_VSCTL([get b br0 :y=z])],
664 [1], [], [ovs-vsctl: :y=z: missing column name
665 ], [OVS_VSCTL_CLEANUP])
666 AT_CHECK([RUN_OVS_VSCTL([get b br0 datapath_id:y=z])],
667 [1], [], [ovs-vsctl: datapath_id:y=z: trailing garbage "=z" in argument
668 ], [OVS_VSCTL_CLEANUP])
669 AT_CHECK([RUN_OVS_VSCTL([set b br0 'datapath_id:y>=z'])],
670 [1], [], [ovs-vsctl: datapath_id:y>=z: argument does not end in "=" followed by a value.
671 ], [OVS_VSCTL_CLEANUP])
672 AT_CHECK([RUN_OVS_VSCTL([wait-until b br0 datapath_id:y,z])],
673 [1], [], [ovs-vsctl: datapath_id:y,z: argument does not end in "=", "!=", "<", ">", "<=", or ">=" followed by a value.
674 ], [OVS_VSCTL_CLEANUP])
675 AT_CHECK([RUN_OVS_VSCTL([get b br0 datapath_id::])],
676 [1], [], [ovs-vsctl: datapath_id::: trailing garbage ":" in argument
677 ], [OVS_VSCTL_CLEANUP])
678 AT_CHECK([RUN_OVS_VSCTL([get b br0 datapath_id:x])],
679 [1], [], [ovs-vsctl: cannot specify key to get for non-map column datapath_id
680 ], [OVS_VSCTL_CLEANUP])
681 AT_CHECK([RUN_OVS_VSCTL([get b br0 external_ids:x])],
682 [1], [], [ovs-vsctl: no key "x" in Bridge record "br0" column external_ids
683 ], [OVS_VSCTL_CLEANUP])
684 AT_CHECK([RUN_OVS_VSCTL([set b br0 flood_vlans=-1])],
685 [1], [], [ovs-vsctl: constraint violation: -1 is not in the valid range 0 to 4095 (inclusive)
686 ], [OVS_VSCTL_CLEANUP])
687 AT_CHECK([RUN_OVS_VSCTL([set b br0 flood_vlans=4096])],
688 [1], [], [ovs-vsctl: constraint violation: 4096 is not in the valid range 0 to 4095 (inclusive)
689 ], [OVS_VSCTL_CLEANUP])
690 AT_CHECK([RUN_OVS_VSCTL([set c br1 'connection-mode=xyz'])],
691 [1], [], [[ovs-vsctl: constraint violation: xyz is not one of the allowed values ([in-band, out-of-band])
692 ]], [OVS_VSCTL_CLEANUP])
693 AT_CHECK([RUN_OVS_VSCTL([set c br1 connection-mode:x=y])],
694 [1], [], [ovs-vsctl: cannot specify key to set for non-map column connection_mode
695 ], [OVS_VSCTL_CLEANUP])
696 AT_CHECK([RUN_OVS_VSCTL([add b br1 datapath_id x y])],
697 [1], [], [ovs-vsctl: "add" operation would put 2 values in column datapath_id of table Bridge but the maximum number is 1
698 ], [OVS_VSCTL_CLEANUP])
699 AT_CHECK([RUN_OVS_VSCTL([remove n `cat netflow-uuid` targets '"1.2.3.4:567"'])],
700 [1], [], [ovs-vsctl: "remove" operation would put 0 values in column targets of table NetFlow but the minimum number is 1
701 ], [OVS_VSCTL_CLEANUP])
702 AT_CHECK([RUN_OVS_VSCTL([clear n `cat netflow-uuid` targets])],
703 [1], [], [ovs-vsctl: "clear" operation cannot be applied to column targets of table NetFlow, which is not allowed to be empty
704 ], [OVS_VSCTL_CLEANUP])
705 AT_CHECK([RUN_OVS_VSCTL([destroy b br2])],
706 [1], [], [ovs-vsctl: no row "br2" in table Bridge
707 ], [OVS_VSCTL_CLEANUP])
711 AT_SETUP([database commands -- wait-until immediately true])
712 AT_KEYWORDS([ovs-vsctl])
714 AT_CHECK([RUN_OVS_VSCTL(
716 [add-bond br0 bond0 eth0 eth1],
717 [set port bond0 bond_updelay=500 other-config:abc=def])],
718 [0], [], [], [OVS_VSCTL_CLEANUP])
719 AT_CHECK([RUN_OVS_VSCTL([[wait-until Open_vSwitch . manager_options=[]]])],
720 [0], [], [], [OVS_VSCTL_CLEANUP])
721 AT_CHECK([RUN_OVS_VSCTL([[wait-until Open_vSwitch . bridges!=[]]])],
722 [0], [], [], [OVS_VSCTL_CLEANUP])
723 AT_CHECK([RUN_OVS_VSCTL([[wait-until Port bond0 other-config:abc=def]])],
724 [0], [], [], [OVS_VSCTL_CLEANUP])
725 AT_CHECK([RUN_OVS_VSCTL([[wait-until port bond0 'bond_updelay>50' 'other-config:abc>d' 'other-config:abc<e']])],
726 [0], [], [], [OVS_VSCTL_CLEANUP])
730 AT_SETUP([database commands -- wait-until must wait])
731 AT_KEYWORDS([ovs-vsctl])
733 # Disable lcov for this test. All the programs running in parallel
734 # race badly on access to profiling data.
740 # Start ovs-vsctls in background.
741 (RUN_OVS_VSCTL([[wait-until o . bridges!=[] -- get bridge br10 other-config:abc]])) > stdout1 &
742 (RUN_OVS_VSCTL([[wait-until bridge br1 -- get bridge br1 other-config:abc]])) > stdout2 &
743 (RUN_OVS_VSCTL([[wait-until b br1 other-config={abc=def} -- get bridge br1 other-config]])) > stdout3 &
744 (RUN_OVS_VSCTL([[wait-until port bond0 'bond_updelay>50' -- get port bond0 bond-updelay]])) > stdout4 &
746 # Give the ovs-vsctls a chance to read the database
749 AT_CHECK([RUN_OVS_VSCTL([add-br br10 -- set bridge br10 other-config:abc=quux])
750 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])],
751 [0], [], [], [OVS_VSCTL_CLEANUP])
753 # Wait for the ovs-vsctls to finish.
757 AT_CHECK([cat stdout1], [0], [quux
758 ], [], [OVS_VSCTL_CLEANUP])
759 AT_CHECK([cat stdout2], [0], [def
760 ], [], [OVS_VSCTL_CLEANUP])
761 AT_CHECK([cat stdout3], [0], [{abc=def}
762 ], [], [OVS_VSCTL_CLEANUP])
763 AT_CHECK([cat stdout4], [0], [500
764 ], [], [OVS_VSCTL_CLEANUP])
769 AT_SETUP([--id option on create, get commands])
770 AT_KEYWORDS([ovs-vsctl])
772 AT_CHECK([RUN_OVS_VSCTL([add-br br0],
774 [add-port br0 eth1])])
776 [RUN_OVS_VSCTL_TOGETHER(
777 [set bridge br0 mirrors=@m],
778 [--id=@eth0 get port eth0],
779 [--id=@eth1 get port eth1],
780 [--id=@m create mirror name=mymirror select-dst-port=@eth0 select-src-port=@eth0 output-port=@eth1])],
781 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
783 [perl $srcdir/uuidfilt.pl stdout], [0], [dnl
789 [], [OVS_VSCTL_CLEANUP])
792 [list port eth0 eth1],
795 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
797 [sed -n -e '/uuid/p' -e '/name/p' -e '/mirrors/p' -e '/select/p' -e '/output/p' < stdout | $srcdir/uuidfilt.pl], [0], [dnl
807 select_dst_port : [<0>]
808 select_src_port : [<0>]
814 [], [OVS_VSCTL_CLEANUP])
818 AT_SETUP([unreferenced record warnings])
819 AT_KEYWORDS([ovs-vsctl])
822 [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket \
823 -- create Bridge name=br0 | $srcdir/uuidfilt.pl],
825 ], [vsctl|WARN|applying "create" command to table Bridge without --id option will have no effect
826 ], [OVS_VSCTL_CLEANUP])
828 [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket \
829 -- --id=@br0 create Bridge name=br0 | $srcdir/uuidfilt.pl],
831 ], [vsctl|WARN|row id "@br0" was created but no reference to it was inserted, so it will not actually appear in the database
832 ], [OVS_VSCTL_CLEANUP])
834 [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket \
835 -- --id=@eth0_iface create Interface name=eth0 \
836 -- --id=@eth0 create Port name=eth0 interfaces=@eth0_iface \
837 -- --id=@m0 create Mirror name=m0 output_port=@eth0 \
838 -- --id=@br0 create Bridge name=br0 mirrors=@m0 \
839 -- set Open_vSwitch . bridges=@br0 | $srcdir/uuidfilt.pl],
844 ], [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
845 ], [OVS_VSCTL_CLEANUP])
849 dnl This test really shows a bug -- "create" followed by "list" in
850 dnl the same execution shows the wrong UUID on the "list" command.
851 dnl The bug is documented in ovs-vsctl.8.
852 AT_SETUP([created row UUID is wrong in same execution])
853 AT_KEYWORDS([ovs-vsctl])
855 AT_CHECK([RUN_OVS_VSCTL([--id=@br0 create Bridge name=br0 -- add Open_vSwitch . bridges @br0 -- list b])],
856 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
857 AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0],
872 ]], [ignore], [test ! -e pid || kill `cat pid`])