[ovs-dev] [bug15637 v2 2/2] jsonrpc-server: Add test for disconnecting connections with too long queues.

Ben Pfaff blp at nicira.com
Sun Nov 3 05:02:27 UTC 2013


Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 tests/ovsdb-server.at |   85 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/tests/ovsdb-server.at b/tests/ovsdb-server.at
index 444ab96..b05401f 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
@@ -662,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)])
 
-- 
1.7.10.4




More information about the dev mailing list