X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tests%2Fovsdb-server.at;h=0cc4375b97a2a740db169585005c964f0fd3d7fc;hb=06f64d032ab82237b4ff7d92f6d6328869d70931;hp=444ab965977f63e8a0d153829d68a12940feae97;hpb=b33bff0fbab0201f9df2faecc779129ac85e6632;p=sliver-openvswitch.git diff --git a/tests/ovsdb-server.at b/tests/ovsdb-server.at index 444ab9659..0cc4375b9 100644 --- a/tests/ovsdb-server.at +++ b/tests/ovsdb-server.at @@ -38,6 +38,8 @@ cat stdout >> output EXECUTION_EXAMPLES +AT_BANNER([ovsdb-server miscellaneous features]) + AT_SETUP([truncating corrupted database log]) AT_KEYWORDS([ovsdb server positive unix]) OVS_RUNDIR=`pwd`; export OVS_RUNDIR @@ -481,7 +483,7 @@ AT_KEYWORDS([ovsdb server positive ssl $5]) AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) PKIDIR=$abs_top_builddir/tests AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\" - \\]"]) +\\]"]) AT_DATA([schema], [[{"name": "mydb", "tables": { @@ -662,8 +664,91 @@ _uuid name number ], [], [test ! -e pid || kill `cat pid`]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP + +AT_SETUP([ovsdb-server connection queue limits]) +OVS_LOGDIR=`pwd`; export OVS_LOGDIR +OVS_RUNDIR=`pwd`; export OVS_RUNDIR +ON_EXIT([kill `cat *.pid`]) + +# The maximum socket receive buffer size is important for this test, which +# tests behavior when the receive buffer overflows. +if test -e /proc/sys/net/core/rmem_max; then + # Linux + rmem_max=`cat /proc/sys/net/core/rmem_max` +elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then + : # FreeBSD +else + # Don't know how to get maximum socket receive buffer on this OS + AT_SKIP_IF([:]) +fi +# Calculate the total amount of data we need to queue: rmem_max in the +# kernel plus 1024 kB in jsonrpc-server sending userspace (see default +# backlog_threshold in ovsdb_jsonrpc_session_create() in +# jsonrpc-server.c). +queue_size=`expr $rmem_max + 1024 \* 1024` +echo rmem_max=$rmem_max queue_size=$queue_size + +# Each flow update message takes up at least 48 bytes of space in queues +# and in practice more than that. +n_msgs=`expr $queue_size / 48` +echo n_msgs=$n_msgs + +# Start an ovsdb-server with the vswitchd schema. +OVSDB_INIT([db]) +AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:socket db], + [0], [ignore], [ignore]) + +# Executes a pair of transactions that add a bridge with 100 ports, +# and then deletes that bridge. Each of these transactions yields +# a monitor update about 25 kB in size. +trigger_big_update () { + ovs-vsctl --db=unix:socket --no-wait -- add-br br0 $add + ovs-vsctl --db=unix:socket --no-wait -- del-br br0 +} +add_ports () { + for j in `seq 1 100`; do + printf " -- add-port br0 p%d" $j + done +} +add=`add_ports` + +AT_CAPTURE_FILE([ovsdb-client.out]) +AT_CAPTURE_FILE([ovsdb-client.err]) + +# Start an ovsdb-client monitoring all changes to the database, +# make it block to force the buffers to fill up, and then execute +# enough transactions that ovsdb-server disconnects it. +AT_CHECK([ovsdb-client --detach --no-chdir --pidfile monitor unix:socket ALL >ovsdb-client.out 2>ovsdb-client.err]) +AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/block]) +for i in `seq 1 100`; do + echo "blocked update ($i of 100)" + trigger_big_update +done +AT_CHECK([ovs-appctl -t ovsdb-client ovsdb-client/unblock]) + +# Make sure that ovsdb-server disconnected the client and +# that the client exited as a result. +if grep "bytes backlogged but a complete replica would only take [[0-9]]* bytes, disconnecting" ovsdb-server.log; then + : +else + AT_FAIL_IF([:]) +fi +OVS_WAIT_WHILE([test -e ovsdb-client.pid]) + +# Start an ovsdb-client monitoring all changes to the database, +# without making it block, and then execute the same transactions that +# we did before. This time the client should not get disconnected. +AT_CHECK([ovsdb-client --detach --no-chdir --pidfile monitor unix:socket ALL >ovsdb-client.out 2>ovsdb-client.err]) +for i in `seq 1 100`; do + echo "unblocked update ($i of 100)" + trigger_big_update + + # Make sure that ovsdb-client gets enough CPU time to process the updates. + ovs-appctl -t ovsdb-client version > /dev/null +done +AT_CLEANUP -AT_BANNER([OVSDB -- ovsdb-server transactions (SSL sockets)]) +AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv4 sockets)]) # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) # @@ -702,7 +787,46 @@ cat stdout >> output EXECUTION_EXAMPLES -AT_BANNER([OVSDB -- ovsdb-server transactions (TCP sockets)]) +AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv6 sockets)]) + +# OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) +# +# Creates a database with the given SCHEMA, starts an ovsdb-server on +# that database, and runs each of the TRANSACTIONS (which should be a +# quoted list of quoted strings) against it with ovsdb-client one at a +# time. +# +# Checks that the overall output is OUTPUT, but UUIDs in the output +# are replaced by markers of the form where N is a number. The +# first unique UUID is replaced by <0>, the next by <1>, and so on. +# If a given UUID appears more than once it is always replaced by the +# same marker. +# +# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. +m4_define([OVSDB_CHECK_EXECUTION], + [AT_SETUP([$1]) + AT_KEYWORDS([ovsdb server positive ssl6 $5]) + AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) + OVS_RUNDIR=`pwd`; export OVS_RUNDIR + OVS_LOGDIR=`pwd`; export OVS_LOGDIR + $2 > schema + PKIDIR=$abs_top_builddir/tests + AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) + AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid --private-key=$PKIDIR/testpki-privkey2.pem --certificate=$PKIDIR/testpki-cert2.pem --ca-cert=$PKIDIR/testpki-cacert.pem --remote=pssl:0:[[::1]] --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore]) + SSL_PORT=`parse_listening_port < ovsdb-server.log` + m4_foreach([txn], [$3], + [AT_CHECK([ovsdb-client --private-key=$PKIDIR/testpki-privkey.pem --certificate=$PKIDIR/testpki-cert.pem --ca-cert=$PKIDIR/testpki-cacert.pem transact ssl:[[::1]]:$SSL_PORT 'txn'], [0], [stdout], [ignore], + [test ! -e pid || kill `cat pid`]) +cat stdout >> output +]) + AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore], + [test ! -e pid || kill `cat pid`]) + OVSDB_SERVER_SHUTDOWN + AT_CLEANUP]) + +ONE_EXECUTION_EXAMPLE + +AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv4 sockets)]) AT_SETUP([ovsdb-client get-schema-version - tcp socket]) AT_KEYWORDS([ovsdb server positive tcp]) @@ -751,6 +875,44 @@ cat stdout >> output AT_CLEANUP]) EXECUTION_EXAMPLES + +AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv6 sockets)]) + +# OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) +# +# Creates a database with the given SCHEMA, starts an ovsdb-server on +# that database, and runs each of the TRANSACTIONS (which should be a +# quoted list of quoted strings) against it with ovsdb-client one at a +# time. +# +# Checks that the overall output is OUTPUT, but UUIDs in the output +# are replaced by markers of the form where N is a number. The +# first unique UUID is replaced by <0>, the next by <1>, and so on. +# If a given UUID appears more than once it is always replaced by the +# same marker. +# +# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. +m4_define([OVSDB_CHECK_EXECUTION], + [AT_SETUP([$1]) + AT_KEYWORDS([ovsdb server positive tcp6 $5]) + OVS_RUNDIR=`pwd`; export OVS_RUNDIR + OVS_LOGDIR=`pwd`; export OVS_LOGDIR + $2 > schema + PKIDIR=$abs_top_builddir/tests + AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) + AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid --remote=ptcp:0:[[::1]] --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore]) + TCP_PORT=`parse_listening_port < ovsdb-server.log` + m4_foreach([txn], [$3], + [AT_CHECK([ovsdb-client transact tcp:[[::1]]:$TCP_PORT 'txn'], [0], [stdout], [ignore], + [test ! -e pid || kill `cat pid`]) +cat stdout >> output +]) + AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore], + [test ! -e pid || kill `cat pid`]) + OVSDB_SERVER_SHUTDOWN + AT_CLEANUP]) + +ONE_EXECUTION_EXAMPLE AT_BANNER([OVSDB -- transactions on transient ovsdb-server])