X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Fovs-vsctl.at;h=103b17ae00cda8429b762d8b63609691705aa787;hb=0d0f05b909b6428d44eb147bd4edd73782d2a137;hp=22028d900eb8236069b6236d2fcde213ce2bf173;hpb=0b1fae1b73c4c6cfc84edafc6845a17257191e42;p=openvswitch diff --git a/tests/ovs-vsctl.at b/tests/ovs-vsctl.at index 22028d90..103b17ae 100644 --- a/tests/ovs-vsctl.at +++ b/tests/ovs-vsctl.at @@ -3,29 +3,13 @@ dnl dnl Creates an empty database in the current directory and then starts dnl an ovsdb-server on it for ovs-vsctl to connect to. m4_define([OVS_VSCTL_SETUP], - [OVS_CHECK_LCOV( - [SCHEMA=$abs_top_builddir/vswitchd/vswitch-idl.ovsschema - if test ! -e $SCHEMA; then - SCHEMA=$abs_top_srcdir/vswitchd/vswitch-idl.ovsschema - if test ! -e $SCHEMA; then - echo 'Failed to find vswitch-idl.ovsschema' - exit 1 - fi - fi - ovsdb-tool create db $SCHEMA], - [0], [stdout], [ignore]) - OVS_CHECK_LCOV( - [[ovsdb-tool transact db \ - '[{"op": "insert", - "table": "Open_vSwitch", - "row": {}}]']], - [0], [ignore], [ignore]) + [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])]) dnl OVS_VSCTL_CLEANUP dnl dnl Kills off the database server. -m4_define([OVS_VSCTL_CLEANUP], [test ! -e pid || kill `cat pid`]) +m4_define([OVS_VSCTL_CLEANUP], [OVSDB_SERVER_SHUTDOWN]) dnl RUN_OVS_VSCTL(COMMAND, ...) dnl @@ -302,10 +286,10 @@ AT_CHECK([RUN_OVS_VSCTL_TOGETHER( [add-port a a1], [add-bond a bond0 a2 a3], [br-set-external-id a key0 value0], - [port-set-external-id a1 key1 value1], - [iface-set-external-id a2 key2 value2], - [iface-set-external-id a2 key3 value3], - [iface-set-external-id a3 key4 value4], + [set port a1 external-ids:key1=value1], + [set interface a2 external-ids:key2=value2], + [set interface a2 external-ids:key3=value3], + [set interface a3 external-ids:key4=value4], [br-get-external-id a], [br-get-external-id a key0], [br-get-external-id a key1], @@ -313,9 +297,9 @@ AT_CHECK([RUN_OVS_VSCTL_TOGETHER( [br-get-external-id a], [br-set-external-id a key0], [br-get-external-id a], - [port-get-external-id a1], - [iface-get-external-id a2], - [iface-get-external-id a3])], [0], [ + [get port a1 external-ids], + [get interface a2 external-ids], + [get interface a3 external-ids])], [0], [ @@ -330,19 +314,19 @@ value0 key0=othervalue -key1=value1 -key2=value2\nkey3=value3 -key4=value4 +{"key1"="value1"} +{"key2"="value2", "key3"="value3"} +{"key4"="value4"} ], [], [OVS_VSCTL_CLEANUP]) AT_CHECK([RUN_OVS_VSCTL_TOGETHER( [br-get-external-id a], - [port-get-external-id a1], - [iface-get-external-id a2], - [iface-get-external-id a3])], [0], + [get port a1 external-ids], + [get interface a2 external-ids], + [get interface a3 external-ids])], [0], [ -key1=value1 -key2=value2\nkey3=value3 -key4=value4 +{"key1"="value1"} +{"key2"="value2", "key3"="value3"} +{"key4"="value4"} ], [], [OVS_VSCTL_CLEANUP]) CHECK_BRIDGES([a, a, 0]) CHECK_PORTS([a], [a1], [bond0]) @@ -460,3 +444,167 @@ AT_CHECK([RUN_OVS_VSCTL([del-br xapi1])]) CHECK_BRIDGES OVS_VSCTL_CLEANUP AT_CLEANUP + +dnl ---------------------------------------------------------------------- +AT_BANNER([ovs-vsctl unit tests -- database commands]) + +AT_SETUP([database commands -- positive checks]) +AT_KEYWORDS([ovs-vsctl]) +OVS_VSCTL_SETUP +AT_CHECK([RUN_OVS_VSCTL([create b name=br0])], + [0], [stdout], [], [OVS_VSCTL_CLEANUP]) +cp stdout out1 +AT_CHECK([RUN_OVS_VSCTL([list b])], + [0], [stdout], [], [OVS_VSCTL_CLEANUP]) +cp stdout out2 +AT_CHECK([perl $srcdir/uuidfilt.pl out1 out2], [0], + [[<0> +_uuid : <0> +controller : [] +datapath_id : [] +datapath_type : "" +external_ids : {} +flood_vlans : [] +mirrors : [] +name : "br0" +netflow : [] +other_config : {} +ports : [] +sflow : [] +]], [ignore], [test ! -e pid || kill `cat pid`]) +AT_CHECK( + [RUN_OVS_VSCTL( + [set bridge br0 \ + 'other_config:datapath_id="0123456789ab"' \ + 'other_config:hwaddr="00:11:22:33:44:55"' \ + 'external-ids={"xs-network-uuids"="9c45f225-a7cf-439d-976d-83db6271fda1"}' -- \ + add bridge br0 external_ids '"xs-network-names"="local; remote; cloud"'])], + [0], [], [], [OVS_VSCTL_CLEANUP]) +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{xs-network-names="local; remote; cloud", xs-network-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])], + [0], ["00:11:22:33:44:55" + +], [], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([remove br br0 other_config hwaddr 'datapath_id=""' -- get br br0 other_config])], + [0], [{datapath_id="0123456789ab"} +], [], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([remove br br0 other_config 'datapath_id="0123456789ab"' -- get br br0 other_config])], + [0], [{} +], [], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([clear br br0 external-ids -- get br br0 external_ids])], + [0], [{} +], [], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([destroy b br0])], + [0], [stdout], [], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([list b])], + [0], [], [], [OVS_VSCTL_CLEANUP]) +OVS_VSCTL_CLEANUP +AT_CLEANUP + +AT_SETUP([database commands -- negative checks]) +AT_KEYWORDS([ovs-vsctl]) +OVS_VSCTL_SETUP +AT_CHECK([RUN_OVS_VSCTL([create b name=br0])], + [0], [ignore], [], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([add-br br1])], + [0], [ignore], [], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([set-controller br1 tcp:127.0.0.1])], + [0], [ignore], [], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([create n targets='"1.2.3.4:567"'])], + [0], [stdout], [], [OVS_VSCTL_CLEANUP]) +cp stdout netflow-uuid +AT_CHECK([RUN_OVS_VSCTL([list n `cat netflow-uuid`])], + [0], [stdout], [], [OVS_VSCTL_CLEANUP]) +AT_CHECK([perl $srcdir/uuidfilt.pl netflow-uuid stdout], [0], + [[<0> +_uuid : <0> +active_timeout : 0 +add_id_to_interface : false +engine_id : [] +engine_type : [] +targets : ["1.2.3.4:567"] +]], [ignore], [test ! -e pid || kill `cat pid`]) +AT_CHECK([RUN_OVS_VSCTL([list interx x])], + [1], [], [ovs-vsctl: unknown table "interx" +], [OVS_VSCTL_CLEANUP]) +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([list b br])], + [1], [], [ovs-vsctl: multiple rows in Bridge match "br" +], [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([get b br0 x])], + [1], [], [ovs-vsctl: Bridge does not contain a column whose name matches "x" +], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([get b br0 :y=z])], + [1], [], [ovs-vsctl: :y=z: missing column name +], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([get b br0 datapath_id:y=z])], + [1], [], [ovs-vsctl: datapath_id:y=z: value not accepted here +], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([get b br0 datapath_id::])], + [1], [], [ovs-vsctl: datapath_id::: trailing garbage ":" in argument +], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([get b br0 datapath_id:x])], + [1], [], [ovs-vsctl: cannot specify key to get for non-map column datapath_id +], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([get b br0 external_ids:x])], + [1], [], [ovs-vsctl: no key "x" in Bridge record "br0" column external_ids +], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([set b br0 flood_vlans=-1])], + [1], [], [ovs-vsctl: constraint violation: -1 is not in the valid range 0 to 4095 (inclusive) +], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([set b br0 flood_vlans=4096])], + [1], [], [ovs-vsctl: constraint violation: 4096 is not in the valid range 0 to 4095 (inclusive) +], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([set c br1 'connection-mode=xyz'])], + [1], [], [ovs-vsctl: constraint violation: "xyz" is not a either "in-band" or "out-of-band" +], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([set c br1 connection-mode:x=y])], + [1], [], [ovs-vsctl: cannot specify key to set for non-map column connection_mode +], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([add b br1 datapath_id x y])], + [1], [], [ovs-vsctl: "add" operation would put 2 values in column datapath_id of table Bridge but the maximum number is 1 +], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([remove n `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 minimun number is 1 +], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([clear n `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]) +OVS_VSCTL_CLEANUP +AT_CLEANUP + +dnl This test really shows a bug -- "create" followed by "list" in +dnl the same execution shows the wrong UUID on the "list" command. +dnl The bug is documented in ovs-vsctl.8. +AT_SETUP([created row UUID is wrong in same execution]) +AT_KEYWORDS([ovs-vsctl]) +OVS_VSCTL_SETUP +AT_CHECK([RUN_OVS_VSCTL([create Bridge name=br0 -- list b])], + [0], [stdout], [], [OVS_VSCTL_CLEANUP]) +AT_CHECK([perl $srcdir/uuidfilt.pl stdout], [0], + [[<0> +_uuid : <1> +controller : [] +datapath_id : [] +datapath_type : "" +external_ids : {} +flood_vlans : [] +mirrors : [] +name : "br0" +netflow : [] +other_config : {} +ports : [] +sflow : [] +]], [ignore], [test ! -e pid || kill `cat pid`]) +OVS_VSCTL_CLEANUP +AT_CLEANUP