dnl OVS_VSCTL_SETUP 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], [OVSDB_INIT([db]) AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:db.sock db >/dev/null 2>&1], [0], [ignore], [ignore]) on_exit 'kill `cat ovsdb-server.pid`']) dnl OVS_VSCTL_CLEANUP dnl dnl Kills off the database server. m4_define([OVS_VSCTL_CLEANUP], [OVS_APP_EXIT_AND_WAIT_BY_TARGET([ovsdb-server], [ovsdb-server.pid])]) dnl RUN_OVS_VSCTL(COMMAND, ...) dnl dnl Executes each ovs-vsctl COMMAND. m4_define([RUN_OVS_VSCTL], [m4_foreach([command], [$@], [ovs-vsctl --no-wait -vreconnect:emer command ])]) m4_define([RUN_OVS_VSCTL_ONELINE], [m4_foreach([command], [$@], [ovs-vsctl --no-wait -vreconnect:emer --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 --no-wait -vreconnect:emer --oneline dnl m4_foreach([command], [$@], [ -- command])]) dnl CHECK_BRIDGES([BRIDGE, PARENT, VLAN], ...) dnl dnl Verifies that "ovs-vsctl list-br" prints the specified list of bridges, dnl which must be in alphabetical order. Also checks that each BRIDGE has the dnl specified PARENT and is on the given VLAN. m4_define([_CHECK_BRIDGE], [AT_CHECK([RUN_OVS_VSCTL([br-to-parent $1])], [0], [$2 ]) # Check br-to-vlan, without --oneline. AT_CHECK([RUN_OVS_VSCTL([br-to-vlan $1])], [0], [$3 ]) # Check br-to-vlan, with --oneline. # (This particular test is interesting with --oneline because it returns # an integer instead of a string and that can cause type mismatches inside # python if not done carefully.) AT_CHECK([RUN_OVS_VSCTL_ONELINE([br-to-vlan $1])], [0], [$3 ]) # Check multiple queries in a single run. AT_CHECK([RUN_OVS_VSCTL_TOGETHER([br-to-parent $1], [br-to-vlan $1])], [0], [$2 $3 ])]) m4_define([CHECK_BRIDGES], [dnl Check that the bridges appear on list-br, without --oneline. AT_CHECK( [RUN_OVS_VSCTL([list-br])], [0], [m4_foreach([brinfo], [$@], [m4_car(brinfo) ])]) dnl Check that the bridges appear on list-br, with --oneline. AT_CHECK( [RUN_OVS_VSCTL_ONELINE([list-br])], [0], [m4_join([\n], m4_foreach([brinfo], [$@], [m4_car(brinfo),])) ]) dnl Check that each bridge exists according to br-exists and that dnl a bridge that should not exist does not. m4_foreach([brinfo], [$@], [AT_CHECK([RUN_OVS_VSCTL([br-exists m4_car(brinfo)])])]) AT_CHECK([RUN_OVS_VSCTL([br-exists nonexistent])], [2]) dnl Check that each bridge has the expected parent and VLAN. m4_map([_CHECK_BRIDGE], [$@])]) dnl CHECK_PORTS(BRIDGE, PORT[, PORT...]) dnl dnl Verifies that "ovs-vsctl list-ports BRIDGE" prints the specified dnl list of ports, which must be in alphabetical order. Also checks dnl that "ovs-vsctl port-to-br" reports that each port is dnl in BRIDGE. m4_define([CHECK_PORTS], [dnl Check ports without --oneline. AT_CHECK( [RUN_OVS_VSCTL([list-ports $1])], [0], [m4_foreach([port], m4_cdr($@), [port ])]) dnl Check ports with --oneline. AT_CHECK( [RUN_OVS_VSCTL_ONELINE([list-ports $1])], [0], [m4_join([\n], m4_shift($@)) ]) AT_CHECK([RUN_OVS_VSCTL([port-to-br $1])], [1], [], [ovs-vsctl: no port named $1 ]) m4_foreach( [port], m4_cdr($@), [AT_CHECK([RUN_OVS_VSCTL([[port-to-br] port])], [0], [$1 ])])]) dnl CHECK_IFACES(BRIDGE, IFACE[, IFACE...]) dnl dnl Verifies that "ovs-vsctl list-ifaces BRIDGE" prints the specified dnl list of ifaces, which must be in alphabetical order. Also checks dnl that "ovs-vsctl iface-to-br" reports that each interface is dnl in BRIDGE. m4_define([CHECK_IFACES], [AT_CHECK( [RUN_OVS_VSCTL([list-ifaces $1])], [0], [m4_foreach([iface], m4_cdr($@), [iface ])]) AT_CHECK([RUN_OVS_VSCTL([iface-to-br $1])], [1], [], [ovs-vsctl: no interface named $1 ]) m4_foreach( [iface], m4_cdr($@), [AT_CHECK([RUN_OVS_VSCTL([[iface-to-br] iface])], [0], [$1 ])])]) dnl ---------------------------------------------------------------------- AT_BANNER([ovs-vsctl unit tests]) AT_SETUP([ovs-vsctl connection retry]) 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 ]) if test "$IS_WIN32" = "yes"; then AT_CHECK([cat status], [0], [3 ]) else # 128 + SIGALRM AT_CHECK([cat status], [0], [142 ]) fi 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 ]) if test "$IS_WIN32" = "yes"; then AT_CHECK([cat status], [0], [3 ]) else # 128 + SIGALRM AT_CHECK([cat status], [0], [142 ]) fi AT_CLEANUP dnl ---------------------------------------------------------------------- AT_BANNER([ovs-vsctl unit tests -- real bridges]) AT_SETUP([add-br a]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK([RUN_OVS_VSCTL([add-br a])]) CHECK_BRIDGES([a, a, 0]) CHECK_PORTS([a]) CHECK_IFACES([a]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([add-br a, add-br a]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK([RUN_OVS_VSCTL([add-br a])], [0]) AT_CHECK([RUN_OVS_VSCTL([add-br a])], [1], [], [ovs-vsctl: cannot create a bridge named a because a bridge named a already exists ]) AT_CHECK([RUN_OVS_VSCTL([add-br ''])], [1], [], [ovs-vsctl: bridge name must not be empty string ]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([add-br a, add-br b]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK([RUN_OVS_VSCTL([add-br a], [add-br b])]) AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br a b 9])], [1], [], [ovs-vsctl: "--may-exist add-br a b 9" but a is not a VLAN bridge ]) CHECK_BRIDGES([a, a, 0], [b, b, 0]) CHECK_PORTS([a]) CHECK_IFACES([a]) CHECK_PORTS([b]) CHECK_IFACES([b]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([add-br a, add-br b, del-br a]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK([RUN_OVS_VSCTL([add-br a], [add-br b], [del-br a])]) CHECK_BRIDGES([b, b, 0]) CHECK_PORTS([b]) CHECK_IFACES([b]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([add-br a, del-br a, add-br a]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK([RUN_OVS_VSCTL_TOGETHER( [add-br a], [del-br a], [add-br a], [set Interface a other_config:key=value], [get Interface a other_config:key])], [0], [ value ]) CHECK_BRIDGES([a, a, 0]) CHECK_PORTS([a]) CHECK_IFACES([a]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([add-br a, add-port a a1, add-port a a2]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK([RUN_OVS_VSCTL( [add-br a], [--if-exists del-br b], [add-port a a1], [add-port a a2])]) CHECK_BRIDGES([a, a, 0]) CHECK_PORTS([a], [a1], [a2]) CHECK_IFACES([a], [a1], [a2]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([add-br a, add-port a a1, add-port a a1]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK([RUN_OVS_VSCTL( [add-br a], [add-port a a1])]) AT_CHECK([RUN_OVS_VSCTL([add-port a a1])], [1], [], [ovs-vsctl: cannot create a port named a1 because a port named a1 already exists on bridge a ]) AT_CHECK([RUN_OVS_VSCTL([add-port a ''])], [1], [], [ovs-vsctl: port name must not be empty string ]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([add-br a b, add-port a a1, add-port b b1, del-br a]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK([RUN_OVS_VSCTL_TOGETHER( [add-br a], [add-br b], [add-port a a1], [add-port b b1], [--if-exists del-port b b2], [del-br a])], [0], [ ]) CHECK_BRIDGES([b, b, 0]) CHECK_PORTS([b], [b1]) CHECK_IFACES([b], [b1]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([add-br a, add-bond a bond0 a1 a2 a3]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK([RUN_OVS_VSCTL( [add-br a], [add-bond a bond0 a1 a2 a3])]) AT_CHECK([RUN_OVS_VSCTL([--may-exist add-bond a bond0 a3 a1 a2])]) AT_CHECK([RUN_OVS_VSCTL([--may-exist add-bond a bond0 a2 a1])], [1], [], [ovs-vsctl: "--may-exist add-bond a bond0 a2 a1" but bond0 actually has interface(s) a1, a2, a3 ]) AT_CHECK([RUN_OVS_VSCTL([add-bond a '' x y z])], [1], [], [ovs-vsctl: port name must not be empty string ]) AT_CHECK([RUN_OVS_VSCTL([add-bond a x '' y z])], [1], [], [ovs-vsctl: interface name must not be empty string ]) CHECK_BRIDGES([a, a, 0]) CHECK_PORTS([a], [bond0]) CHECK_IFACES([a], [a1], [a2], [a3]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([add-bond-iface and del-bond-iface]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP # Create 2-interface bond. AT_CHECK([RUN_OVS_VSCTL( [add-br a], [add-bond a bond0 a1 a2])]) CHECK_BRIDGES([a, a, 0]) CHECK_PORTS([a], [bond0]) CHECK_IFACES([a], [a1], [a2]) # Add interface a3 to bond. AT_CHECK([RUN_OVS_VSCTL([add-bond-iface bond0 a3])]) CHECK_BRIDGES([a, a, 0]) CHECK_PORTS([a], [bond0]) CHECK_IFACES([a], [a1], [a2], [a3]) # Delete interface a2 from bond. AT_CHECK([RUN_OVS_VSCTL([del-bond-iface bond0 a2])]) CHECK_BRIDGES([a, a, 0]) CHECK_PORTS([a], [bond0]) CHECK_IFACES([a], [a1], [a3]) # Add interface a2 to bond. AT_CHECK([RUN_OVS_VSCTL([add-bond-iface bond0 a2])]) CHECK_BRIDGES([a, a, 0]) CHECK_PORTS([a], [bond0]) CHECK_IFACES([a], [a1], [a2], [a3]) # Delete interface a2 from bond. AT_CHECK([RUN_OVS_VSCTL([del-bond-iface a2])]) CHECK_BRIDGES([a, a, 0]) CHECK_PORTS([a], [bond0]) CHECK_IFACES([a], [a1], [a3]) AT_CHECK([RUN_OVS_VSCTL([--if-exists del-bond-iface bond0 a4])]) AT_CHECK([RUN_OVS_VSCTL([del-bond-iface bond0 a4])], [1], [], [ovs-vsctl: no interface named a4 ]) AT_CHECK([RUN_OVS_VSCTL([del-bond-iface a4])], [1], [], [ovs-vsctl: no interface named a4 ]) AT_CHECK([RUN_OVS_VSCTL_TOGETHER([add-port a a4], [del-bond-iface bond0 a4])], [1], [], [ovs-vsctl: port bond0 does not have an interface a4 ]) AT_CHECK([RUN_OVS_VSCTL([--may-exist add-bond-iface bond0 a3])]) AT_CHECK([RUN_OVS_VSCTL_TOGETHER([add-bond a bond1 b1 b2 b3], [--may-exist add-bond-iface bond1 a3])], [1], [], [ovs-vsctl: "--may-exist add-bond-iface bond1 a3" but a3 is actually attached to port bond0 ]) AT_CHECK([RUN_OVS_VSCTL([add-bond-iface bond0 a3])], [1], [], [ovs-vsctl: cannot create an interface named a3 because an interface named a3 already exists on bridge a ]) AT_CHECK([RUN_OVS_VSCTL_TOGETHER([del-bond-iface a1], [del-bond-iface a3])], [1], [], [ovs-vsctl: cannot delete last interface from port bond0 ]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([add-br a b, add-port a a1, add-port b b1, del-port a a1]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK([RUN_OVS_VSCTL( [add-br a], [add-br b], [add-port a a1 tag=9], [get port a1 tag], [--may-exist add-port b b1], [del-port a a1])], [0], [9 ]) AT_CHECK([RUN_OVS_VSCTL([--may-exist add-port b b1])]) AT_CHECK([RUN_OVS_VSCTL([del-port a])], [1], [], [ovs-vsctl: cannot delete port a because it is the local port for bridge a (deleting this port requires deleting the entire bridge) ]) AT_CHECK([RUN_OVS_VSCTL([--if-exists del-port a])]) AT_CHECK([RUN_OVS_VSCTL([--may-exist add-port a b1])], [1], [], [ovs-vsctl: "--may-exist add-port a b1" but b1 is actually attached to bridge b ]) CHECK_BRIDGES([a, a, 0], [b, b, 0]) CHECK_PORTS([a]) CHECK_IFACES([a]) CHECK_PORTS([b], [b1]) CHECK_IFACES([b], [b1]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([add-br a, add-bond a bond0 a1 a2 a3, del-port bond0]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK([RUN_OVS_VSCTL_TOGETHER( [add-br a], [add-bond a bond0 a1 a2 a3 tag=9], [get Port bond0 tag], [del-port bond0])], [0], [ 9 ]) CHECK_BRIDGES([a, a, 0]) CHECK_PORTS([a]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([external IDs]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK([RUN_OVS_VSCTL_ONELINE( [add-br a], [add-port a a1], [add-bond a bond0 a2 a3], [br-set-external-id a key0 value0], [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], [br-set-external-id a key0 othervalue], [br-get-external-id a], [br-set-external-id a key0], [br-get-external-id a], [get port a1 external-ids], [get interface a2 external-ids], [get interface a3 external-ids])], [0], [ key0=value0 value0 key0=othervalue {"key1"="value1"} {"key2"="value2", "key3"="value3"} {"key4"="value4"} ]) AT_CHECK([RUN_OVS_VSCTL_TOGETHER( [br-get-external-id a], [get port a1 external-ids], [get interface a2 external-ids], [get interface a3 external-ids])], [0], [ {"key1"="value1"} {"key2"="value2", "key3"="value3"} {"key4"="value4"} ]) CHECK_BRIDGES([a, a, 0]) CHECK_PORTS([a], [a1], [bond0]) CHECK_IFACES([a], [a1], [a2], [a3]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([controllers]) AT_KEYWORDS([controller ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK([RUN_OVS_VSCTL_TOGETHER( [add-br br0], [get-controller br0], [set-controller br0 tcp:4.5.6.7], [get-controller br0], [del-controller br0], [get-controller br0], [set-controller br0 tcp:8.9.10.11 tcp:5.4.3.2], [get-controller br0], [--inactivity-probe=30000 set-controller br0 tcp:1.2.3.4], [get-controller br0])], [0], [ tcp:4.5.6.7 tcp:5.4.3.2\ntcp:8.9.10.11 tcp:1.2.3.4 ]) OVS_VSCTL_CLEANUP AT_CLEANUP dnl ---------------------------------------------------------------------- dnl OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([VLAN]) m4_define([OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF], [AT_CHECK( [RUN_OVS_VSCTL( [add-br xenbr0], [--may-exist add-br xenbr0], [add-port xenbr0 eth0], [--may-exist add-port xenbr0 eth0], [add-br xapi1 xenbr0 $1], [--may-exist add-br xapi1 xenbr0 $1], [add-port xapi1 eth0.$1])])]) dnl OVS_VSCTL_FAKE_BRIDGE_TESTS([VLAN]) m4_define([OVS_VSCTL_FAKE_BRIDGE_TESTS], [ AT_BANNER([ovs-vsctl unit tests -- fake bridges (VLAN $1)]) AT_SETUP([simple fake bridge (VLAN $1)]) AT_KEYWORDS([ovs-vsctl fake-bridge]) OVS_VSCTL_SETUP OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1]) AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1])], [1], [], [ovs-vsctl: "--may-exist add-br xapi1" but xapi1 is a VLAN bridge for VLAN $1 ]) AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1 xxx $1])], [1], [], [ovs-vsctl: "--may-exist add-br xapi1 xxx $1" but xapi1 has the wrong parent xenbr0 ]) AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1 xenbr0 10])], [1], [], [ovs-vsctl: "--may-exist add-br xapi1 xenbr0 10" but xapi1 is a VLAN bridge for the wrong VLAN $1 ]) AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br dup xenbr0 $1])], [1], [], [ovs-vsctl: bridge xenbr0 already has a child VLAN bridge xapi1 on VLAN $1 ]) CHECK_BRIDGES([xapi1, xenbr0, $1], [xenbr0, xenbr0, 0]) CHECK_PORTS([xenbr0], [eth0]) CHECK_IFACES([xenbr0], [eth0]) CHECK_PORTS([xapi1], [eth0.$1]) CHECK_IFACES([xapi1], [eth0.$1]) 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 ]) AT_CHECK([RUN_OVS_VSCTL_ONELINE([-- --real list-br])], [0], [xenbr0 ]) AT_CHECK([RUN_OVS_VSCTL_ONELINE([-- --fake list-br])], [0], [xapi1 ]) 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 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1]) AT_CHECK([RUN_OVS_VSCTL([del-br xapi1])]) CHECK_BRIDGES([xenbr0, xenbr0, 0]) CHECK_PORTS([xenbr0], [eth0]) CHECK_IFACES([xenbr0], [eth0]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([simple fake bridge + del-br real bridge (VLAN $1)]) AT_KEYWORDS([ovs-vsctl fake-bridge]) OVS_VSCTL_SETUP OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1]) AT_CHECK([RUN_OVS_VSCTL([del-br xenbr0])]) CHECK_BRIDGES OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([simple fake bridge + external IDs (VLAN $1)]) AT_KEYWORDS([ovs-vsctl fake-bridge]) OVS_VSCTL_SETUP OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1]) AT_CHECK([RUN_OVS_VSCTL_TOGETHER( [br-set-external-id xenbr0 key0 value0], [br-set-external-id xapi1 key1 value1], [br-get-external-id xenbr0], [br-get-external-id xenbr0 key0], [br-get-external-id xapi1], [br-get-external-id xapi1 key1])], [0], [ key0=value0 value0 key1=value1 value1 ]) CHECK_BRIDGES([xapi1, xenbr0, $1], [xenbr0, xenbr0, 0]) CHECK_PORTS([xenbr0], [eth0]) CHECK_IFACES([xenbr0], [eth0]) CHECK_PORTS([xapi1], [eth0.$1]) CHECK_IFACES([xapi1], [eth0.$1]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([simple fake bridge + del-port from parent (VLAN $1)]) AT_KEYWORDS([ovs-vsctl fake-bridge del-port]) OVS_VSCTL_SETUP OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1]) AT_CHECK([RUN_OVS_VSCTL([del-port xenbr0 eth0.$1])], [1], [], [ovs-vsctl: bridge xenbr0 does not have a port eth0.$1 (although its child bridge xapi1 does) ]) CHECK_PORTS([xenbr0], [eth0]) CHECK_IFACES([xenbr0], [eth0]) CHECK_PORTS([xapi1], [eth0.$1]) CHECK_IFACES([xapi1], [eth0.$1]) AT_CHECK([RUN_OVS_VSCTL([del-port xapi1 eth0.$1])]) CHECK_PORTS([xenbr0], [eth0]) CHECK_IFACES([xenbr0], [eth0]) OVS_VSCTL_CLEANUP AT_CLEANUP ]) # OVS_VSCTL_FAKE_BRIDGE_TESTS OVS_VSCTL_FAKE_BRIDGE_TESTS([9]) OVS_VSCTL_FAKE_BRIDGE_TESTS([0]) dnl OVS_VSCTL_SETUP_BOND_FAKE_CONF([VLAN]) m4_define([OVS_VSCTL_SETUP_BOND_FAKE_CONF], [AT_CHECK( [RUN_OVS_VSCTL( [add-br xapi1], [add-bond xapi1 bond0 eth0 eth1], [add-br xapi2 xapi1 $1], [add-port xapi2 bond0.$1])])]) AT_SETUP([fake bridge on bond]) AT_KEYWORDS([ovs-vsctl fake-bridge]) OVS_VSCTL_SETUP OVS_VSCTL_SETUP_BOND_FAKE_CONF([11]) CHECK_BRIDGES([xapi1, xapi1, 0], [xapi2, xapi1, 11]) CHECK_PORTS([xapi1], [bond0]) CHECK_IFACES([xapi1], [eth0], [eth1]) CHECK_PORTS([xapi2], [bond0.11]) CHECK_IFACES([xapi2], [bond0.11]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([fake bridge on bond + del-br fake bridge]) AT_KEYWORDS([ovs-vsctl fake-bridge]) OVS_VSCTL_SETUP OVS_VSCTL_SETUP_BOND_FAKE_CONF([11]) AT_CHECK([RUN_OVS_VSCTL_ONELINE([del-br xapi2])], [0], [ ]) CHECK_BRIDGES([xapi1, xapi1, 0]) CHECK_PORTS([xapi1], [bond0]) CHECK_IFACES([xapi1], [eth0], [eth1]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([fake bridge on bond + del-br real bridge]) AT_KEYWORDS([ovs-vsctl fake-bridge]) OVS_VSCTL_SETUP OVS_VSCTL_SETUP_BOND_FAKE_CONF([11]) AT_CHECK([RUN_OVS_VSCTL([del-br xapi1])]) CHECK_BRIDGES OVS_VSCTL_CLEANUP AT_CLEANUP dnl ---------------------------------------------------------------------- AT_BANNER([ovs-vsctl unit tests -- manager commands]) AT_SETUP([managers]) AT_KEYWORDS([manager ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK([RUN_OVS_VSCTL_TOGETHER( [del-manager], [get-manager], [set-manager tcp:4.5.6.7], [get-manager], [set-manager tcp:8.9.10.11 tcp:5.4.3.2], [get-manager], [--inactivity-probe=30000 set-manager tcp:1.2.3.4], [get-manager], [del-manager], [get-manager])], [0], [ tcp:4.5.6.7 tcp:5.4.3.2\ntcp:8.9.10.11 tcp:1.2.3.4 ]) 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_TOGETHER([--id=@br0 create bridge name=br123], [set b br123 name=br0], [set o . bridges=@br0])], [0], [stdout]) cp stdout out1 AT_CHECK([RUN_OVS_VSCTL([list bridge], [get bridge br0 _uuid])], [0], [stdout]) cp stdout out2 AT_CHECK([uuidfilt out1 out2], [0], [[<0> _uuid : <0> auto_attach : [] controller : [] datapath_id : [] datapath_type : "" datapath_version : "" external_ids : {} fail_mode : [] flood_vlans : [] flow_tables : {} ipfix : [] mcast_snooping_enable: false mirrors : [] name : "br0" netflow : [] other_config : {} ports : [] protocols : [] rstp_enable : false rstp_status : {} sflow : [] status : {} stp_enable : false <0> ]], [ignore]) AT_CHECK( [RUN_OVS_VSCTL([--columns=fail_mode,name,datapath_type list bridge])], [0], [[fail_mode : [] name : "br0" datapath_type : "" ]], [ignore]) AT_CHECK( [RUN_OVS_VSCTL([--columns=fail_mode,name,datapath_type find bridge])], [0], [[fail_mode : [] name : "br0" datapath_type : "" ]], [ignore]) AT_CHECK([ RUN_OVS_VSCTL_TOGETHER([--id=@br1 create bridge name=br1 datapath_type="foo"], [--id=@br2 create bridge name=br2 external-ids:bar=quux], [add o . bridges @br1 @br2])], [0], [stdout]) AT_CHECK( [RUN_OVS_VSCTL([--columns=name find bridge datapath_type!=foo])], [0], [stdout], [ignore]) AT_CHECK([sed -n '/./p' stdout | sort], [0], [[name : "br0" name : "br2" ]]) AT_CHECK( [RUN_OVS_VSCTL( [set bridge br0 \ '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"'])]) 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"} ]) 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" ]) AT_CHECK([RUN_OVS_VSCTL([remove bridge br0 other_config hwaddr 'datapath_id=""' -- get bridge br0 other_config])], [0], [{datapath_id="0123456789ab"} ]) AT_CHECK([RUN_OVS_VSCTL([remove bridge br0 other_config 'datapath_id="0123456789ab"' -- get bridge br0 other_config])], [0], [{} ]) AT_CHECK([RUN_OVS_VSCTL([clear bridge br0 external-ids -- get bridge br0 external_ids])], [0], [{} ]) AT_CHECK([RUN_OVS_VSCTL_TOGETHER([destroy bridge br0], [destroy bridge br1], [destroy bridge br2], [clear o . bridges])], [0], [stdout]) AT_CHECK([RUN_OVS_VSCTL([list bridge])]) AT_CHECK([RUN_OVS_VSCTL([--if-exists get bridge x datapath_id])]) AT_CHECK([RUN_OVS_VSCTL([--if-exists list bridge x])]) AT_CHECK([RUN_OVS_VSCTL([--if-exists set controller x connection_mode=standalone])]) AT_CHECK( [RUN_OVS_VSCTL([--if-exists remove netflow x targets '"1.2.3.4:567"'])]) AT_CHECK( [RUN_OVS_VSCTL([--if-exists clear netflow x targets])]) 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) ]) AT_CHECK([ovs-vsctl --may-exist --], [1], [ignore], [ovs-vsctl: missing command name (use --help for help) ]) AT_CHECK([ovs-vsctl -- --may-exist], [1], [ignore], [ovs-vsctl: missing command name (use --help for help) ]) AT_CHECK([RUN_OVS_VSCTL([add-br br0])], [0], [ignore]) AT_CHECK([RUN_OVS_VSCTL([add-br br1])], [0], [ignore]) AT_CHECK([RUN_OVS_VSCTL([set-controller br1 tcp:127.0.0.1])], [0], [ignore]) AT_CHECK([RUN_OVS_VSCTL([list netflow br0])], [1], [], [ovs-vsctl: no row "br0" in table NetFlow ]) AT_CHECK([ RUN_OVS_VSCTL_TOGETHER([--id=@n create netflow targets='"1.2.3.4:567"'], [set bridge br0 netflow=@n])], [0], [stdout]) cp stdout netflow-uuid AT_CHECK([RUN_OVS_VSCTL([list netflow `cat netflow-uuid`])], [0], [stdout]) AT_CHECK([uuidfilt netflow-uuid stdout], [0], [[<0> _uuid : <0> active_timeout : 0 add_id_to_interface : false engine_id : [] engine_type : [] external_ids : {} targets : ["1.2.3.4:567"] ]], [ignore]) AT_CHECK([RUN_OVS_VSCTL([list interx x])], [1], [], [ovs-vsctl: unknown table "interx" ]) AT_CHECK([RUN_OVS_VSCTL([list bridge x])], [1], [], [ovs-vsctl: no row "x" in table Bridge ]) AT_CHECK([RUN_OVS_VSCTL([get bridge x datapath_id])], [1], [], [ovs-vsctl: no row "x" in table Bridge ]) AT_CHECK([RUN_OVS_VSCTL([get bridge br0 d])], [1], [], [ovs-vsctl: Bridge contains more than one column whose name matches "d" ]) AT_CHECK([RUN_OVS_VSCTL([get bridge br0 x])], [1], [], [ovs-vsctl: Bridge does not contain a column whose name matches "x" ]) AT_CHECK([RUN_OVS_VSCTL([get bridge br0 :y=z])], [1], [], [ovs-vsctl: :y=z: missing column name ]) AT_CHECK([RUN_OVS_VSCTL([get bridge br0 datapath_id:y=z])], [1], [], [ovs-vsctl: datapath_id:y=z: trailing garbage "=z" in argument ]) AT_CHECK([RUN_OVS_VSCTL([set bridge br0 'datapath_id:y>=z'])], [1], [], [ovs-vsctl: datapath_id:y>=z: argument does not end in "=" followed by a value. ]) AT_CHECK([RUN_OVS_VSCTL([set controller x connection_mode=standalone])], [1], [], [ovs-vsctl: no row "x" in table Controller ]) AT_CHECK([RUN_OVS_VSCTL([wait-until bridge br0 datapath_id:y,z])], [1], [], [ovs-vsctl: datapath_id:y,z: argument does not end in "=", "!=", "<", ">", "<=", ">=", "{=}", "{!=}", "{<}", "{>}", "{<=}", or "{>=}" followed by a value. ]) AT_CHECK([RUN_OVS_VSCTL([get bridge br0 datapath_id::])], [1], [], [ovs-vsctl: datapath_id::: trailing garbage ":" in argument ]) AT_CHECK([RUN_OVS_VSCTL([get bridge br0 datapath_id:x])], [1], [], [ovs-vsctl: cannot specify key to get for non-map column datapath_id ]) AT_CHECK([RUN_OVS_VSCTL([get bridge br0 external_ids:x])], [1], [], [ovs-vsctl: no key "x" in Bridge record "br0" column external_ids ]) AT_CHECK([RUN_OVS_VSCTL([set bridge br0 flood_vlans=-1])], [1], [], [ovs-vsctl: constraint violation: -1 is not in the valid range 0 to 4095 (inclusive) ]) AT_CHECK([RUN_OVS_VSCTL([set bridge br0 flood_vlans=4096])], [1], [], [ovs-vsctl: constraint violation: 4096 is not in the valid range 0 to 4095 (inclusive) ]) AT_CHECK([RUN_OVS_VSCTL([set c br1 'connection-mode=xyz'])], [1], [], [[ovs-vsctl: constraint violation: xyz is not one of the allowed values ([in-band, out-of-band]) ]]) 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 ]) AT_CHECK([RUN_OVS_VSCTL([add bridge 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 ]) 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 ]) AT_CHECK([RUN_OVS_VSCTL([remove netflow x targets '"1.2.3.4:567"'])], [1], [], [ovs-vsctl: no row "x" in table NetFlow ]) AT_CHECK([RUN_OVS_VSCTL([clear netflow x targets])], [1], [], [ovs-vsctl: no row "x" in table NetFlow ]) 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 ]) AT_CHECK([RUN_OVS_VSCTL([destroy bridge br2])], [1], [], [ovs-vsctl: no row "br2" in table Bridge ]) AT_CHECK([RUN_OVS_VSCTL([add in br1 name x])], [1], [], [ovs-vsctl: cannot modify read-only column name in table Interface ]) AT_CHECK([RUN_OVS_VSCTL([set port br0 name=br2])], [1], [], [ovs-vsctl: cannot modify read-only column name in table Port ]) AT_CHECK([RUN_OVS_VSCTL([remove bridge br0 name br1])], [1], [], [ovs-vsctl: cannot modify read-only column name in table Bridge ]) AT_CHECK([RUN_OVS_VSCTL([remove bridge br1 flood-vlans true])], [1], [], [ovs-vsctl: "true" is not a valid integer or range ]) AT_CHECK([RUN_OVS_VSCTL([clear bridge br1 name])], [1], [], [ovs-vsctl: cannot modify read-only column name in table Bridge ]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([database commands -- conditions]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK( [RUN_OVS_VSCTL_TOGETHER( [add-br br0], [add-br br1], [set bridge br1 flood_vlans=0 other-config:x='""'], [add-br br2], [set bridge br2 flood_vlans=1 other-config:x=y], [add-br br3], [set bridge br3 flood_vlans=0,1 other-config:x=z], [add-br br4], [set bridge br4 flood_vlans=2], [add-br br5], [set bridge br5 flood_vlans=0,2], [add-br br6], [set bridge br6 flood_vlans=1,2], [add-br br7], [set bridge br7 flood_vlans=0,1,2])], [0], [ ]) m4_define([VSCTL_CHECK_FIND], [AT_CHECK([echo `ovs-vsctl --bare --no-wait -vreconnect:emer -- --columns=name find bridge '$1' | sort`], [0], [$2 ])]) # Arithmetic relational operators without keys. VSCTL_CHECK_FIND([flood_vlans=0], [br1]) VSCTL_CHECK_FIND([flood_vlans=1], [br2]) VSCTL_CHECK_FIND([flood_vlans=0,2], [br5]) VSCTL_CHECK_FIND([flood_vlans=0,1,2], [br7]) VSCTL_CHECK_FIND([flood_vlans=3], []) VSCTL_CHECK_FIND([flood_vlans!=0], [br0 br2 br3 br4 br5 br6 br7]) VSCTL_CHECK_FIND([flood_vlans!=1], [br0 br1 br3 br4 br5 br6 br7]) VSCTL_CHECK_FIND([flood_vlans!=0,2], [br0 br1 br2 br3 br4 br6 br7]) VSCTL_CHECK_FIND([flood_vlans!=0,1,2], [br0 br1 br2 br3 br4 br5 br6]) VSCTL_CHECK_FIND([flood_vlans!=3], [br0 br1 br2 br3 br4 br5 br6 br7]) VSCTL_CHECK_FIND([flood_vlans<2], [br0 br1 br2]) VSCTL_CHECK_FIND([flood_vlans<0,2], [br0 br1 br2 br3 br4]) VSCTL_CHECK_FIND([flood_vlans>1], [br3 br4 br5 br6 br7]) VSCTL_CHECK_FIND([flood_vlans>0,1], [br5 br6 br7]) VSCTL_CHECK_FIND([flood_vlans<=2], [br0 br1 br2 br4]) VSCTL_CHECK_FIND([flood_vlans<=0,2], [br0 br1 br2 br3 br4 br5]) VSCTL_CHECK_FIND([flood_vlans>=1], [br2 br3 br4 br5 br6 br7]) VSCTL_CHECK_FIND([flood_vlans>=0,1], [br3 br5 br6 br7]) # Set relational operators without keys. VSCTL_CHECK_FIND([flood_vlans{=}0], [br1]) VSCTL_CHECK_FIND([flood_vlans{=}1], [br2]) VSCTL_CHECK_FIND([flood_vlans{=}0,2], [br5]) VSCTL_CHECK_FIND([flood_vlans{=}0,1,2], [br7]) VSCTL_CHECK_FIND([flood_vlans{=}3], []) VSCTL_CHECK_FIND([flood_vlans{!=}0], [br0 br2 br3 br4 br5 br6 br7]) VSCTL_CHECK_FIND([flood_vlans{!=}1], [br0 br1 br3 br4 br5 br6 br7]) VSCTL_CHECK_FIND([flood_vlans{!=}0,2], [br0 br1 br2 br3 br4 br6 br7]) VSCTL_CHECK_FIND([flood_vlans{!=}0,1,2], [br0 br1 br2 br3 br4 br5 br6]) VSCTL_CHECK_FIND([flood_vlans{!=}3], [br0 br1 br2 br3 br4 br5 br6 br7]) VSCTL_CHECK_FIND([flood_vlans{<}[[]]], []) VSCTL_CHECK_FIND([flood_vlans{<=}[[]]], [br0]) VSCTL_CHECK_FIND([flood_vlans{<}0], [br0]) VSCTL_CHECK_FIND([flood_vlans{<=}0], [br0 br1]) VSCTL_CHECK_FIND([flood_vlans{<}1,2], [br0 br2 br4]) VSCTL_CHECK_FIND([flood_vlans{<=}1,2], [br0 br2 br4 br6]) VSCTL_CHECK_FIND([flood_vlans{>}[[]]], [br1 br2 br3 br4 br5 br6 br7]) VSCTL_CHECK_FIND([flood_vlans{>=}[[]]], [br0 br1 br2 br3 br4 br5 br6 br7]) VSCTL_CHECK_FIND([flood_vlans{>}0], [br3 br5 br7]) VSCTL_CHECK_FIND([flood_vlans{>=}0], [br1 br3 br5 br7]) VSCTL_CHECK_FIND([flood_vlans{>}0,2], [br7]) VSCTL_CHECK_FIND([flood_vlans{>=}1,2], [br6 br7]) VSCTL_CHECK_FIND([flood_vlans{>=}0,2], [br5 br7]) # Arithmetic relational operators with keys. VSCTL_CHECK_FIND([other-config:x=""], [br1]) VSCTL_CHECK_FIND([other-config:x=y], [br2]) VSCTL_CHECK_FIND([other-config:x=z], [br3]) VSCTL_CHECK_FIND([other-config:x!=""], [br2 br3]) VSCTL_CHECK_FIND([other-config:x!=y], [br1 br3]) VSCTL_CHECK_FIND([other-config:x!=z], [br1 br2]) VSCTL_CHECK_FIND([other-config:x>y], [br3]) VSCTL_CHECK_FIND([other-config:x>=y], [br2 br3]) VSCTL_CHECK_FIND([other-config:x=}[[]]], [br0 br1 br2 br3 br4 br5 br6 br7]) VSCTL_CHECK_FIND([other-config:x{>=}x], []) VSCTL_CHECK_FIND([other-config:x{>=}""], [br1]) VSCTL_CHECK_FIND([other-config:x{>=}y], [br2]) VSCTL_CHECK_FIND([other-config:x{>=}z], [br3]) VSCTL_CHECK_FIND([other-config:x{>}[[]]], [br1 br2 br3]) VSCTL_CHECK_FIND([other-config:x{>}x], []) VSCTL_CHECK_FIND([other-config:x{>}""], []) VSCTL_CHECK_FIND([other-config:x{>}y], []) VSCTL_CHECK_FIND([other-config:x{>}z], []) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([database commands -- wait-until immediately true]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK([RUN_OVS_VSCTL( [add-br br0], [add-bond br0 bond0 eth0 eth1], [set port bond0 bond_updelay=500 other-config:abc=def])]) AT_CHECK([RUN_OVS_VSCTL([[wait-until Open_vSwitch . manager_options=[]]])]) AT_CHECK([RUN_OVS_VSCTL([[wait-until Open_vSwitch . bridges!=[]]])]) AT_CHECK([RUN_OVS_VSCTL([[wait-until Port bond0 other-config:abc=def]])]) AT_CHECK([RUN_OVS_VSCTL([[wait-until port bond0 'bond_updelay>50' 'other-config:abc>d' 'other-config:abc stdout1 & (RUN_OVS_VSCTL([[wait-until bridge br1 -- get bridge br1 other-config:abc]])) > stdout2 & (RUN_OVS_VSCTL([[wait-until bridge br1 other-config={abc=def} -- get bridge br1 other-config]])) > stdout3 & (RUN_OVS_VSCTL([[wait-until port bond0 'bond_updelay>50' -- get port bond0 bond-updelay]])) > stdout4 & # Give the ovs-vsctls a chance to read the database sleep 1 AT_CHECK([RUN_OVS_VSCTL([add-br br10 -- set bridge br10 other-config:abc=quux]) 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])]) # Wait for the ovs-vsctls to finish. wait # Check output AT_CHECK([cat stdout1], [0], [quux ]) AT_CHECK([cat stdout2], [0], [def ]) AT_CHECK([cat stdout3], [0], [{abc=def} ]) AT_CHECK([cat stdout4], [0], [500 ]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([--id option on create, get commands]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK([RUN_OVS_VSCTL([add-br br0], [add-port br0 eth0], [add-port br0 eth1])]) AT_CHECK( [RUN_OVS_VSCTL_TOGETHER( [set bridge br0 mirrors=@m], [--id=@eth0 get port eth0], [--id=@eth1 get port eth1], [--id=@m create mirror name=mymirror select-dst-port=@eth0 select-src-port=@eth0 output-port=@eth1])], [0], [stdout]) AT_CHECK( [uuidfilt stdout], [0], [dnl <0> ]) AT_CHECK( [RUN_OVS_VSCTL( [list port eth0 eth1], [list mirror], [list bridge br0])], [0], [stdout]) AT_CHECK( [sed -n -e '/uuid/p' -e '/name/p' -e '/mirrors/p' -e '/select/p' -e '/output/p' < stdout | uuidfilt], [0], [dnl [_uuid : <0> name : "eth0" _uuid : <1> name : "eth1" _uuid : <2> name : mymirror output_port : <1> output_vlan : [] select_all : false select_dst_port : [<0>] select_src_port : [<0>] select_vlan : [] _uuid : <3> mirrors : [<2>] name : "br0" ]]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([unreferenced record warnings]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK( [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer \ -- create Bridge name=br0 | uuidfilt], [0], [<0> ], [db_ctl_base|WARN|applying "create" command to table Bridge without --id option will have no effect ]) AT_CHECK( [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer \ -- --id=@br0 create Bridge name=br0 | uuidfilt], [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 ]) AT_CHECK( [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer \ -- --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 | uuidfilt], [0], [<0> <1> <2> <3> ], [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 ]) 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([--id=@br0 create Bridge name=br0 -- add Open_vSwitch . bridges @br0 -- list bridge])], [0], [stdout]) AT_CHECK([uuidfilt stdout], [0], [[<0> _uuid : <1> auto_attach : [] controller : [] datapath_id : [] datapath_type : "" datapath_version : "" external_ids : {} fail_mode : [] flood_vlans : [] flow_tables : {} ipfix : [] mcast_snooping_enable: false mirrors : [] name : "br0" netflow : [] other_config : {} ports : [] protocols : [] rstp_enable : false rstp_status : {} sflow : [] status : {} stp_enable : false ]], [ignore]) 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])]) 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]) AT_CHECK([RUN_OVS_VSCTL( [--columns=other_config,type list Qos])], [0], [other_config : {max-rate="1000000000"} type : linux-htb ]) AT_CHECK([RUN_OVS_VSCTL( [--columns=other_config list Queue | sort | sed '/^$/d'])], [0], [other_config : {max-rate="100000000", min-rate="100000000"} other_config : {min-rate="500000000"} ]) AT_CHECK([RUN_OVS_VSCTL( [clear Port a1 qos], [clear Port a2 qos])]) AT_CHECK([RUN_OVS_VSCTL( [--columns=qos list Port a1 a2])], [0], [[qos : [] qos : [] ]]) AT_CHECK([RUN_OVS_VSCTL( [--all destroy Qos])]) AT_CHECK([RUN_OVS_VSCTL( [-- list Qos])]) AT_CHECK([RUN_OVS_VSCTL( [--all destroy Queue])]) AT_CHECK([RUN_OVS_VSCTL( [-- list Queue])]) OVS_VSCTL_CLEANUP AT_CLEANUP dnl ---------------------------------------------------------------------- AT_BANNER([ovs-vsctl add-port -- reserved port names]) AT_SETUP([add-port -- reserved names 1]) OVS_VSWITCHD_START # Test creating all reserved port names m4_foreach( [reserved_name], [[ovs-netdev], [ovs-dummy], [genev_sys], [gre_sys], [lisp_sys], [vxlan_sys]], [ # Try creating the port cat >experr < ovs-vswitchd.log], [0], [], []) # Delete the port AT_CHECK([ovs-vsctl del-port br0 reserved_name], [0], [], [])]) OVS_VSWITCHD_STOP AT_CLEANUP AT_SETUP([add-port -- reserved names 2]) # Creates all type of tunnel ports OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \ options:remote_ip=1.1.1.1 ofport_request=1\ -- add-port br0 p3 -- set Interface p3 type=lisp \ options:remote_ip=2.2.2.2 ofport_request=3 \ -- add-port br0 p4 -- set Interface p4 type=vxlan \ options:remote_ip=2.2.2.2 ofport_request=4 \ -- add-port br0 p5 -- set Interface p5 type=geneve \ options:remote_ip=2.2.2.2 ofport_request=5]) # Test creating all reserved tunnel port names m4_foreach( [reserved_name], [[genev_sys], [gre_sys], [lisp_sys], [vxlan_sys]], [ # Try creating the port cat >experr < ovs-vswitchd.log], [0], [], []) # Delete the port AT_CHECK([ovs-vsctl del-port br0 reserved_name], [0], [], [])]) OVS_VSWITCHD_STOP AT_CLEANUP AT_SETUP([naming in db commands]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP dnl First check that the database commands can refer to row by database UUID. AT_CHECK([RUN_OVS_VSCTL([add-br br0])]) uuid=`[]RUN_OVS_VSCTL(get port br0 _uuid)` AT_CHECK([RUN_OVS_VSCTL([get port $uuid name])], [0], ["br0" ]) dnl Next check that, if a database row is given a name that has the same form dnl as the database UUIDs, the name can still be used to refer to rows. AT_CHECK([RUN_OVS_VSCTL([add-br 0fcd11a1-2ba8-4b38-a358-4bccf2bf3057])]) AT_CHECK([RUN_OVS_VSCTL([get interface 0fcd11a1-2ba8-4b38-a358-4bccf2bf3057 type])], [0], [internal ]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([bootstrap ca cert]) AT_KEYWORDS([ovs-vsctl ssl]) AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) PKIDIR=`pwd` OVS_PKI="sh $abs_top_srcdir/utilities/ovs-pki.in --dir=$PKIDIR/pki --log=$PKIDIR/ovs-pki.log" AT_CHECK([$OVS_PKI init && $OVS_PKI req+sign vsctl switch && $OVS_PKI req ovsdbserver && $OVS_PKI self-sign ovsdbserver], [0], [ignore], [ignore]) dnl Create database. OVSDB_INIT([conf.db]) 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]) on_exit "kill `cat ovsdb-server.pid`" PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT]) # During bootstrap, the connection gets torn down. So the o/p of ovs-vsctl is error. 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]) # If the bootstrap was successful, the following file should exist. OVS_WAIT_UNTIL([test -e $PKIDIR/cacert.pem]) # After bootstrap, the connection should be successful. 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]) 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 ]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([peer ca cert]) AT_KEYWORDS([ovs-vsctl ssl]) AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) PKIDIR=`pwd` OVS_PKI="sh $abs_top_srcdir/utilities/ovs-pki.in --dir=$PKIDIR/pki --log=$PKIDIR/ovs-pki.log" AT_CHECK([$OVS_PKI init && $OVS_PKI req+sign vsctl switch && $OVS_PKI req+sign ovsdbserver controller], [0], [ignore], [ignore]) dnl Create database. OVSDB_INIT([conf.db]) 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]) on_exit "kill `cat ovsdb-server.pid`" PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT]) # During bootstrap, the connection gets torn down. So the o/p of ovs-vsctl is error. 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]) # If the bootstrap was successful, the following file should exist. OVS_WAIT_UNTIL([test -e $PKIDIR/cacert.pem]) # After bootstrap, the connection should be successful. 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]) 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 ]) OVS_VSCTL_CLEANUP AT_CLEANUP AT_SETUP([TLS server name indication (SNI)]) AT_KEYWORDS([ovsdb server positive ssl tls sni]) AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) AT_SKIP_IF([test "$OPENSSL_SUPPORTS_SNI" = no]) AT_SKIP_IF([test "$HAVE_UNBOUND" = no]) OVSDB_INIT([conf.db]) PKIDIR=$abs_top_builddir/tests AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile --private-key=$PKIDIR/testpki-privkey2.pem --certificate=$PKIDIR/testpki-cert2.pem --ca-cert=$PKIDIR/testpki-cacert.pem --remote=pssl:0:127.0.0.1 -vPATTERN:file:%m -vstream_ssl conf.db], [0], [ignore], [ignore]) PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT]) AT_CHECK([ovs-vsctl -t 5 --no-wait --db=ssl:localhost:$SSL_PORT --private-key=$PKIDIR/testpki-privkey.pem --certificate=$PKIDIR/testpki-cert.pem --bootstrap-ca-cert=$PKIDIR/testpki-cacert.pem add-br br0]) AT_CAPTURE_FILE([ovsdb-server.log]) AT_CHECK([grep "server name" ovsdb-server.log], [0], [connection indicated server name localhost ]) OVS_VSCTL_CLEANUP AT_CLEANUP