dnl an ovsdb-server on it for ovs-vsctl to connect to.
m4_define([OVS_VSCTL_SETUP],
[OVSDB_INIT([db])
- AT_CHECK([ovsdb-server --detach --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db >/dev/null 2>&1], [0], [ignore], [ignore])])
+ AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db >/dev/null 2>&1], [0], [ignore], [ignore])])
dnl OVS_VSCTL_CLEANUP
dnl
dnl
dnl Executes each ovs-vsctl COMMAND.
m4_define([RUN_OVS_VSCTL],
- [m4_foreach([command], [$@], [ovs-vsctl --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket -- command
+ [m4_foreach([command], [$@], [ovs-vsctl --no-wait -vreconnect:emer --db=unix:socket command
])])
m4_define([RUN_OVS_VSCTL_ONELINE],
- [m4_foreach([command], [$@], [ovs-vsctl --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket --oneline -- command
+ [m4_foreach([command], [$@], [ovs-vsctl --no-wait -vreconnect:emer --db=unix:socket --oneline -- command
])])
dnl RUN_OVS_VSCTL_TOGETHER(COMMAND, ...)
dnl
dnl Executes each ovs-vsctl COMMAND in a single run of ovs-vsctl.
m4_define([RUN_OVS_VSCTL_TOGETHER],
- [ovs-vsctl --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket --oneline dnl
+ [ovs-vsctl --no-wait -vreconnect:emer --db=unix:socket --oneline dnl
m4_foreach([command], [$@], [ -- command])])
dnl CHECK_BRIDGES([BRIDGE, PARENT, VLAN], ...)
],
[], [OVS_VSCTL_CLEANUP])])])
+dnl ----------------------------------------------------------------------
+AT_BANNER([ovs-vsctl unit tests])
+
+AT_SETUP([ovs-vsctl connection retry])
+OVS_RUNDIR=$PWD; export OVS_RUNDIR
+
+dnl Without --retry, there should be no retry for active connections.
+AT_CHECK([ovs-vsctl --db=unix:foo --timeout=10 -vreconnect:emer -- init],
+ [1], [], [stderr])
+AT_CHECK([[sed 's/([^()]*)/(...reason...)/' stderr]], [0],
+ [ovs-vsctl: unix:foo: database connection failed (...reason...)
+])
+
+dnl With --retry, we should retry for active connections.
+AT_CHECK(
+ [ovs-vsctl --db=unix:foo --timeout=1 --retry -vreconnect:emer -vPATTERN:console:'%c|%p|%m' -- init
+ echo $? > status],
+ [0], [], [stderr])
+AT_CHECK([grep -c 'terminating with signal' stderr], [0], [1
+])
+AT_CHECK([kill -l `cat status`], [0], [ALRM
+])
+
+dnl Without --retry, we should retry for passive connections.
+AT_CHECK(
+ [ovs-vsctl --db=punix:foo --timeout=1 -vreconnect:emer -vPATTERN:console:'%c|%p|%m' -- init
+ echo $? > status],
+ [0], [], [stderr])
+AT_CHECK([grep -c 'terminating with signal' stderr], [0], [1
+])
+AT_CHECK([kill -l `cat status`], [0], [ALRM
+])
+AT_CLEANUP
+
dnl ----------------------------------------------------------------------
AT_BANNER([ovs-vsctl unit tests -- real bridges])
AT_KEYWORDS([controller ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
- [add-br br0],
+ [add-br br0],
[get-controller br0],
[set-controller br0 tcp:4.5.6.7],
OVS_VSCTL_CLEANUP
AT_CLEANUP
+AT_SETUP([list bridges -- real and fake (VLAN $1)])
+AT_KEYWORDS([ovs-vsctl fake-bridge])
+OVS_VSCTL_SETUP
+OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
+AT_CHECK([RUN_OVS_VSCTL_ONELINE([-- list-br])], [0],
+ [xapi1\nxenbr0
+], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL_ONELINE([-- --real list-br])], [0],
+ [xenbr0
+], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL_ONELINE([-- --fake list-br])], [0],
+ [xapi1
+], [], [OVS_VSCTL_CLEANUP])
+OVS_VSCTL_CLEANUP
+AT_CLEANUP
+
AT_SETUP([simple fake bridge + del-br fake bridge (VLAN $1)])
AT_KEYWORDS([ovs-vsctl fake-bridge])
OVS_VSCTL_SETUP
[set o . bridges=@br0])],
[0], [stdout], [], [OVS_VSCTL_CLEANUP])
cp stdout out1
-AT_CHECK([RUN_OVS_VSCTL([list b], [get b br0 _uuid])],
+AT_CHECK([RUN_OVS_VSCTL([list b], [get b br0 _uuid])],
[0], [stdout], [], [OVS_VSCTL_CLEANUP])
cp stdout out2
-AT_CHECK([perl $srcdir/uuidfilt.pl out1 out2], [0],
+AT_CHECK([${PERL} $srcdir/uuidfilt.pl out1 out2], [0],
[[<0>
_uuid : <0>
fail_mode : []
flood_vlans : []
flow_tables : {}
+ipfix : []
mirrors : []
name : "br0"
netflow : []
other_config : {}
ports : []
+protocols : []
sflow : []
status : {}
stp_enable : false
'other_config:datapath_id="0123456789ab"' \
'other_config:hwaddr="00:11:22:33:44:55"' \
'external-ids={"uuids"="9c45f225-a7cf-439d-976d-83db6271fda1"}' -- \
- add bridge br0 external_ids '"roles"="local; remote; cloud"'])],
+ add bridge br0 external_ids '"roles"="local; remote; cloud"'])],
[0], [], [], [OVS_VSCTL_CLEANUP])
-AT_CHECK([RUN_OVS_VSCTL_ONELINE([get bridge br0 other_config external-ids])],
+AT_CHECK([RUN_OVS_VSCTL_ONELINE([get bridge br0 other_config external-ids])],
[0], [{datapath_id="0123456789ab", hwaddr="00:11:22:33:44:55"}\n{roles="local; remote; cloud", uuids="9c45f225-a7cf-439d-976d-83db6271fda1"}
], [], [OVS_VSCTL_CLEANUP])
-AT_CHECK([RUN_OVS_VSCTL([get bridge br0 other_config:hwaddr -- --if-exists get bridge br0 other-config:nonexistent])],
+AT_CHECK([RUN_OVS_VSCTL([get bridge br0 other_config:hwaddr -- --if-exists get bridge br0 other-config:nonexistent])],
[0], ["00:11:22:33:44:55"
], [], [OVS_VSCTL_CLEANUP])
[0], [stdout], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([list b])],
[0], [], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL([--if-exists get b x datapath_id])],
+ [0], [], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL([--if-exists list b x])],
+ [0], [], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL([--if-exists set controller x connection_mode=standalone])],
+ [0], [], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK(
+ [RUN_OVS_VSCTL([--if-exists remove netflow x targets '"1.2.3.4:567"'])],
+ [0], [], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK(
+ [RUN_OVS_VSCTL([--if-exists clear netflow x targets])],
+ [0], [], [], [OVS_VSCTL_CLEANUP])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([database commands -- negative checks])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
+
+AT_CHECK([ovs-vsctl --may-exist],
+ [1], [ignore], [ovs-vsctl: missing command name (use --help for help)
+], [OVS_VSCTL_CLEANUP])
+AT_CHECK([ovs-vsctl --may-exist --],
+ [1], [ignore], [ovs-vsctl: missing command name (use --help for help)
+], [OVS_VSCTL_CLEANUP])
+AT_CHECK([ovs-vsctl -- --may-exist],
+ [1], [ignore], [ovs-vsctl: missing command name (use --help for help)
+], [OVS_VSCTL_CLEANUP])
+
AT_CHECK([RUN_OVS_VSCTL([add-br br0])],
[0], [ignore], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([add-br br1])],
cp stdout netflow-uuid
AT_CHECK([RUN_OVS_VSCTL([list netflow `cat netflow-uuid`])],
[0], [stdout], [], [OVS_VSCTL_CLEANUP])
-AT_CHECK([perl $srcdir/uuidfilt.pl netflow-uuid stdout], [0],
+AT_CHECK([${PERL} $srcdir/uuidfilt.pl netflow-uuid stdout], [0],
[[<0>
_uuid : <0>
AT_CHECK([RUN_OVS_VSCTL([list b x])],
[1], [], [ovs-vsctl: no row "x" in table Bridge
], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL([get b x datapath_id])],
+ [1], [], [ovs-vsctl: no row "x" in table Bridge
+], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([get b br0 d])],
[1], [], [ovs-vsctl: Bridge contains more than one column whose name matches "d"
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([set b br0 'datapath_id:y>=z'])],
[1], [], [ovs-vsctl: datapath_id:y>=z: argument does not end in "=" followed by a value.
], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL([set controller x connection_mode=standalone])],
+ [1], [], [ovs-vsctl: no row "x" in table Controller
+], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([wait-until b br0 datapath_id:y,z])],
[1], [], [ovs-vsctl: datapath_id:y,z: argument does not end in "=", "!=", "<", ">", "<=", ">=", "{=}", "{!=}", "{<}", "{>}", "{<=}", or "{>=}" followed by a value.
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([remove netflow `cat netflow-uuid` targets '"1.2.3.4:567"'])],
[1], [], [ovs-vsctl: "remove" operation would put 0 values in column targets of table NetFlow but the minimum number is 1
], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL([remove netflow x targets '"1.2.3.4:567"'])],
+ [1], [], [ovs-vsctl: no row "x" in table NetFlow
+], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL([clear netflow x targets])],
+ [1], [], [ovs-vsctl: no row "x" in table NetFlow
+], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([clear netflow `cat netflow-uuid` targets])],
[1], [], [ovs-vsctl: "clear" operation cannot be applied to column targets of table NetFlow, which is not allowed to be empty
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([destroy b br2])],
[1], [], [ovs-vsctl: no row "br2" in table Bridge
], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL([add in br1 name x])],
+ [1], [], [ovs-vsctl: cannot modify read-only column name in table Interface
+], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL([set port br1 name br2])],
+ [1], [], [ovs-vsctl: cannot modify read-only column name in table Port
+], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL([remove b br1 name br1])],
+ [1], [], [ovs-vsctl: cannot modify read-only column name in table Bridge
+], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL([clear b br1 name])],
+ [1], [], [ovs-vsctl: cannot modify read-only column name in table Bridge
+], [OVS_VSCTL_CLEANUP])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([database commands -- conditions])
AT_KEYWORDS([ovs-vsctl])
-trap 'kill `cat pid`' 0
+ON_EXIT([kill `cat pid`])
OVS_VSCTL_SETUP
AT_CHECK(
[RUN_OVS_VSCTL_TOGETHER(
])
m4_define([VSCTL_CHECK_FIND],
- [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
+ [AT_CHECK([echo `ovs-vsctl --bare --no-wait -vreconnect:emer --db=unix:socket -- --columns=name find bridge '$1' | sort`], [0], [$2
])])
# Arithmetic relational operators without keys.
AT_SETUP([database commands -- wait-until must wait])
AT_KEYWORDS([ovs-vsctl])
-# Disable lcov for this test. All the programs running in parallel
-# race badly on access to profiling data.
-DISABLE_LCOV=true
-export DISABLE_LCOV
-
OVS_VSCTL_SETUP
# Start ovs-vsctls in background.
[--id=@m create mirror name=mymirror select-dst-port=@eth0 select-src-port=@eth0 output-port=@eth1])],
[0], [stdout], [], [OVS_VSCTL_CLEANUP])
AT_CHECK(
- [perl $srcdir/uuidfilt.pl stdout], [0], [dnl
+ [${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
[list bridge br0])],
[0], [stdout], [], [OVS_VSCTL_CLEANUP])
AT_CHECK(
- [sed -n -e '/uuid/p' -e '/name/p' -e '/mirrors/p' -e '/select/p' -e '/output/p' < stdout | $srcdir/uuidfilt.pl], [0], [dnl
+ [sed -n -e '/uuid/p' -e '/name/p' -e '/mirrors/p' -e '/select/p' -e '/output/p' < stdout | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
[_uuid : <0>
name : "eth0"
_uuid : <1>
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK(
- [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket \
- -- create Bridge name=br0 | $srcdir/uuidfilt.pl],
+ [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer --db=unix:socket \
+ -- create Bridge name=br0 | ${PERL} $srcdir/uuidfilt.pl],
[0], [<0>
], [vsctl|WARN|applying "create" command to table Bridge without --id option will have no effect
], [OVS_VSCTL_CLEANUP])
AT_CHECK(
- [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket \
- -- --id=@br0 create Bridge name=br0 | $srcdir/uuidfilt.pl],
+ [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer --db=unix:socket \
+ -- --id=@br0 create Bridge name=br0 | ${PERL} $srcdir/uuidfilt.pl],
[0], [<0>
], [vsctl|WARN|row id "@br0" was created but no reference to it was inserted, so it will not actually appear in the database
], [OVS_VSCTL_CLEANUP])
AT_CHECK(
- [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket \
+ [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer --db=unix:socket \
-- --id=@eth0_iface create Interface name=eth0 \
-- --id=@eth0 create Port name=eth0 interfaces=@eth0_iface \
-- --id=@m0 create Mirror name=m0 output_port=@eth0 \
-- --id=@br0 create Bridge name=br0 mirrors=@m0 \
- -- set Open_vSwitch . bridges=@br0 | $srcdir/uuidfilt.pl],
+ -- set Open_vSwitch . bridges=@br0 | ${PERL} $srcdir/uuidfilt.pl],
[0], [<0>
<1>
<2>
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL([--id=@br0 create Bridge name=br0 -- add Open_vSwitch . bridges @br0 -- list b])],
[0], [stdout], [], [OVS_VSCTL_CLEANUP])
-AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0],
+AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0],
[[<0>
_uuid : <1>
controller : []
fail_mode : []
flood_vlans : []
flow_tables : {}
+ipfix : []
mirrors : []
name : "br0"
netflow : []
other_config : {}
ports : []
+protocols : []
sflow : []
status : {}
stp_enable : false
]], [ignore], [test ! -e pid || kill `cat pid`])
OVS_VSCTL_CLEANUP
AT_CLEANUP
+
+dnl This test will create a linux-htb QoS record that
+dnl points to a few queues and use it on a1 and a2 port.
+dnl It also destroys all records from Qos and Queue table.
+AT_SETUP([--all option on destroy command])
+AT_KEYWORDS([ovs-vsctl])
+OVS_VSCTL_SETUP
+AT_CHECK([RUN_OVS_VSCTL(
+ [add-br a],
+ [add-port a a1],
+ [add-port a a2])], [0], [], [], [OVS_VSCTL_CLEANUP])
+CHECK_BRIDGES([a, a, 0])
+CHECK_PORTS([a], [a1], [a2])
+CHECK_IFACES([a], [a1], [a2])
+AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
+ [set Port a1 qos=@newqos],
+ [set Port a2 qos=@newqos],
+ [--id=@newqos create QoS type=linux-htb other-config:max-rate=1000000000 queues=0=@q0,1=@q1],
+ [--id=@q0 create Queue other-config:min-rate=100000000 other-config:max-rate=100000000],
+ [--id=@q1 create Queue other-config:min-rate=500000000])], [0], [ignore], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL(
+ [--columns=other_config,type list Qos])], [0],
+[other_config : {max-rate="1000000000"}
+type : linux-htb
+], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL(
+ [--columns=other_config list Queue | sort | xargs echo])], [0],
+[other_config : {max-rate=100000000, min-rate=100000000} other_config : {min-rate=500000000}
+], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL(
+ [clear Port a1 qos],
+ [clear Port a2 qos])], [0], [], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL(
+ [--columns=qos list Port a1 a2])], [0],
+[[qos : []
+
+qos : []
+]], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL(
+ [--all destroy Qos])], [0], [], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL(
+ [-- list Qos])], [0], [], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL(
+ [--all destroy Queue])], [0], [], [], [OVS_VSCTL_CLEANUP])
+AT_CHECK([RUN_OVS_VSCTL(
+ [-- list Queue])], [0], [], [], [OVS_VSCTL_CLEANUP])
+OVS_VSCTL_CLEANUP
+AT_CLEANUP