[ovs-dev] [PATCH 3/3] tests: Avoid race conditions, by letting the kernel choose ports to bind.

Justin Pettit jpettit at nicira.com
Thu Apr 18 18:53:12 UTC 2013


On Apr 3, 2013, at 12:02 PM, Ben Pfaff <blp at nicira.com> wrote:

> diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at
> index 06ebf23..857e6ab 100644
> --- a/tests/ofproto-dpif.at
> +++ b/tests/ofproto-dpif.at
> @@ -1208,10 +1208,12 @@ AT_CLEANUP
> 
> dnl Test that sFlow samples packets correctly.
> AT_SETUP([ofproto-dpif - sFlow packet sampling])
> -AT_CHECK([perl $srcdir/choose-port.pl], [0], [stdout])
> -SFLOW_PORT=`cat stdout`
> OVS_VSWITCHD_START([set Bridge br0 fail-mode=standalone])
> 
> +AT_CHECK([test-sflow --log-file --detach --no-chdir --pidfile 0:127.0.0.1 > sflow.log], [0], [], [ignore])
> +AT_CAPTURE_FILE([sflow.log])
> +SFLOW_PORT=`parse_listening_port < test-sflow.log`
> +
> ovs-appctl time/stop
> 
> ADD_OF_PORTS([br0], 1, 2)
> @@ -1223,8 +1225,6 @@ ovs-vsctl \
>    --id=@sf create sflow targets=\"127.0.0.1:$SFLOW_PORT\" \
>      header=128 sampling=1 polling=1
> ON_EXIT([kill `cat test-sflow.pid`])

Should this ON_EXIT be moved before the test-sflow invocation?

> +# parse_listening_port [SERVER]
> +#
> +# Parses the TCP or SSL port on which a server is listening from the log,
> +# given that the server was told to listen on a kernel-chosen port,
> +# file provided on stdin, and prints the port number on stdout.
> +#
> +# Here's an example of how to use this with ovsdb-server:
> +#
> +#    OVS_LOGDIR=`pwd`; export OVS_LOGDIR
> +#    ovsdb-server --log-file --remote=ptcp:0:127.0.0.1 ...
> +#    TCP_PORT=`parse_listening_port < ovsdb-server.log`
> +#
> +# (Also works with pssl: in place of ptcp:.)

Maybe it's obvious, but it might be nice to indicate that the user must use "0:127.0.0.1".  I hadn't realized it until I'd read the sed input.

Otherwise, looks like a great improvement.  Thanks!

--Justin





More information about the dev mailing list