X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tests%2Fovsdb-server.at;h=a2c53f3a6ee96e34650816b26ec86e282c2ff0f4;hb=bdd534291ff72077390f7b1745c4443ad3833d99;hp=16a1d952cdcd853a1e263ce82f8e8fd16fd64829;hpb=85606e05b691be7c2f2d4bcf0e91170b71ec8fbb;p=sliver-openvswitch.git diff --git a/tests/ovsdb-server.at b/tests/ovsdb-server.at index 16a1d952c..a2c53f3a6 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 @@ -234,9 +236,16 @@ AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db ordinals], [2], [], [Failed to find the database. ovs-appctl: ovsdb-server: server returned an error ]) + +# Add a removed database. +AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-db db2], [0]) +AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], + [0], [constraints +]) +AT_CHECK([ovsdb-client list-tables unix:socket constraints], [0], [ignore], [ignore]) AT_CLEANUP -AT_SETUP([ovsdb-server/add-db and remove-db with --monitor]) +AT_SETUP([ovsdb-server/add-db with --monitor]) AT_KEYWORDS([ovsdb server positive]) # Start ovsdb-server, initially with one db. OVS_RUNDIR=`pwd`; export OVS_RUNDIR @@ -266,8 +275,21 @@ AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], [0], [constraints ordinals ]) +AT_CLEANUP + +AT_SETUP([ovsdb-server/add-db and remove-db with --monitor]) +AT_KEYWORDS([ovsdb server positive]) +# Start ovsdb-server, initially with one db. +OVS_RUNDIR=`pwd`; export OVS_RUNDIR +OVS_LOGDIR=`pwd`; export OVS_LOGDIR +ordinal_schema > schema +AT_CHECK([ovsdb-tool create db1 schema], [0], [ignore], [ignore]) +constraint_schema > schema2 +AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore]) +ON_EXIT([kill `cat *.pid`]) +AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db1 db2]) -# Remove the recently added database. +# Remove the second database. AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-db constraints]) AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-dbs], [0], [ordinals @@ -392,7 +414,7 @@ AT_CHECK([test ! -e socket1]) AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes]) AT_CLEANUP -AT_SETUP([ovsdb-server/add-remote and remove-remote with --monitor]) +AT_SETUP([ovsdb-server/add-remote with --monitor]) AT_KEYWORDS([ovsdb server positive]) # Start ovsdb-server, initially with no remotes. OVS_RUNDIR=`pwd`; export OVS_RUNDIR @@ -420,6 +442,25 @@ OVS_WAIT_WHILE([kill -0 `cat old.pid`]) OVS_WAIT_UNTIL( [test -s ovsdb-server.pid && test `cat ovsdb-server.pid` != `cat old.pid`]) OVS_WAIT_UNTIL([test -S socket1]) +AT_CLEANUP + +AT_SETUP([ovsdb-server/add-remote and remove-remote with --monitor]) +AT_KEYWORDS([ovsdb server positive]) +# Start ovsdb-server, initially with no remotes. +OVS_RUNDIR=`pwd`; export OVS_RUNDIR +OVS_LOGDIR=`pwd`; export OVS_LOGDIR +ordinal_schema > schema +AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) +ON_EXIT([kill `cat *.pid`]) +AT_CHECK([ovsdb-server -v -vvlog:off --monitor --detach --no-chdir --pidfile --log-file db]) + +# Add a remote. +AT_CHECK([test ! -e socket1]) +AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/add-remote punix:socket1]) +OVS_WAIT_UNTIL([test -S socket1]) +AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/list-remotes], + [0], [punix:socket1 +]) # Remove the remote. AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/remove-remote punix:socket1]) @@ -442,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": { @@ -485,7 +526,7 @@ AT_CHECK( [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`]) cat stdout >> output AT_CHECK_UNQUOTED( - [${PERL} $srcdir/uuidfilt.pl output], [0], + [cat output], [0], [[[{"rows":[{"private_key":"$PKIDIR/testpki-privkey2.pem"}]}] ]], [ignore], [test ! -e pid || kill `cat pid`]) OVSDB_SERVER_SHUTDOWN @@ -623,6 +664,89 @@ _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)])