tests: Change to parse dynamically allocated ports on windows.
authorGurucharan Shetty <gshetty@nicira.com>
Mon, 12 May 2014 22:30:41 +0000 (15:30 -0700)
committerGurucharan Shetty <gshetty@nicira.com>
Thu, 15 May 2014 22:08:56 +0000 (15:08 -0700)
In Windows, we use kernel assigned TCP port for ssl/tcp and
unixctl. In tests, we parse the log files of ovsdb-server.log,
test-sflow.log and test-netflow.log to get this port. In all
the above cases, tcp port is allocated first and then the unixctl port.
So a 'head -1' on the result should be safe.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
tests/ofproto-dpif.at
tests/ofproto-macros.at
tests/ovsdb-idl.at
tests/ovsdb-server.at

index 4dcaf63..d4fe4e5 100644 (file)
@@ -3047,7 +3047,7 @@ m4_define([CHECK_SFLOW_SAMPLING_PACKET],
   ON_EXIT([kill `cat test-sflow.pid`])
   AT_CHECK([ovstest test-sflow --log-file --detach --no-chdir --pidfile 0:$1 > sflow.log], [0], [], [ignore])
   AT_CAPTURE_FILE([sflow.log])
-  SFLOW_PORT=`parse_listening_port test-sflow.log`
+  SFLOW_PORT=`parse_listening_port test-sflow.log`
   ovs-appctl time/stop
 
   ADD_OF_PORTS([br0], 1, 2)
@@ -3354,7 +3354,7 @@ m4_define([CHECK_NETFLOW_EXPIRATION],
   ON_EXIT([kill `cat test-netflow.pid`])
   AT_CHECK([ovstest test-netflow --log-file --detach --no-chdir --pidfile 0:$1 > netflow.log], [0], [], [ignore])
   AT_CAPTURE_FILE([netflow.log])
-  NETFLOW_PORT=`parse_listening_port test-netflow.log`
+  NETFLOW_PORT=`parse_listening_port test-netflow.log`
 
   ovs-vsctl \
      set Bridge br0 netflow=@nf -- \
@@ -3401,7 +3401,7 @@ m4_define([CHECK_NETFLOW_ACTIVE_EXPIRATION],
   ON_EXIT([kill `cat test-netflow.pid`])
   AT_CHECK([ovstest test-netflow --log-file --detach --no-chdir --pidfile 0:$1 > netflow.log], [0], [], [ignore])
   AT_CAPTURE_FILE([netflow.log])
-  NETFLOW_PORT=`parse_listening_port test-netflow.log`
+  NETFLOW_PORT=`parse_listening_port test-netflow.log`
 
   ovs-vsctl \
      set Bridge br0 netflow=@nf -- \
@@ -4017,7 +4017,7 @@ m4_define([CHECK_MEGAFLOW_NETFLOW],
   ON_EXIT([kill `cat test-netflow.pid`])
   AT_CHECK([ovstest test-netflow --log-file --detach --no-chdir --pidfile 0:$1 > netflow.log], [0], [], [ignore])
   AT_CAPTURE_FILE([netflow.log])
-  NETFLOW_PORT=`parse_listening_port test-netflow.log`
+  NETFLOW_PORT=`parse_listening_port test-netflow.log`
   ovs-vsctl \
      set Bridge br0 netflow=@nf -- \
      --id=@nf create NetFlow targets=\"$1:$NETFLOW_PORT\" \
index b4b6dab..4b16907 100644 (file)
@@ -27,9 +27,9 @@ s/ hard_age=[0-9]*,//
 #
 #    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`
+#    TCP_PORT=`parse_listening_port ovsdb-server.log`
 parse_listening_port () {
-    sed -n 's/.*0:.*: listening on port \([0-9]*\)$/\1/p'
+    sed -n 's/.*0:.*: listening on port \([0-9]*\)$/\1/p' "$1" | head -1
 }]
 m4_divert_pop([PREPARE_TESTS])
 
index 89752f0..d656ed4 100644 (file)
@@ -61,7 +61,7 @@ m4_define([OVSDB_CHECK_IDL_TCP_PY],
    AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
                   [0], [stdout], [ignore])
    AT_CHECK([ovsdb-server --log-file '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --remote=ptcp:0:127.0.0.1 --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
-   TCP_PORT=`parse_listening_port ovsdb-server.log`
+   TCP_PORT=`parse_listening_port ovsdb-server.log`
 
    m4_if([$2], [], [],
      [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore], [kill `cat pid`])])
@@ -82,7 +82,7 @@ m4_define([OVSDB_CHECK_IDL_TCP6_PY],
    AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema],
                   [0], [stdout], [ignore])
    AT_CHECK([ovsdb-server --log-file '-vPATTERN:console:ovsdb-server|%c|%m' --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`
+   TCP_PORT=`parse_listening_port ovsdb-server.log`
    echo "TCP_PORT=$TCP_PORT"
 
    m4_if([$2], [], [],
index 08c56ca..18dc7e0 100644 (file)
@@ -510,7 +510,7 @@ AT_CHECK(
         --ca-cert=db:mydb,SSL,ca_cert \
         --remote=pssl:0:127.0.0.1 --unixctl="`pwd`"/unixctl db],
   [0], [ignore], [ignore])
-SSL_PORT=`parse_listening_port ovsdb-server.log`
+SSL_PORT=`parse_listening_port ovsdb-server.log`
 AT_CHECK(
   [[ovsdb-client \
         --private-key=$PKIDIR/testpki-privkey.pem \
@@ -778,7 +778,7 @@ m4_define([OVSDB_CHECK_EXECUTION],
    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:127.0.0.1 --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
-   SSL_PORT=`parse_listening_port ovsdb-server.log`
+   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:127.0.0.1:$SSL_PORT 'txn'], [0], [stdout], [ignore],
      [test ! -e pid || kill `cat pid`])
@@ -817,7 +817,7 @@ m4_define([OVSDB_CHECK_EXECUTION],
    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`
+   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`])
@@ -838,7 +838,7 @@ ordinal_schema > schema
 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
 OVS_LOGDIR=`pwd`; export OVS_LOGDIR
 AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid --unixctl="`pwd`"/unixctl --remote=ptcp:0:127.0.0.1 db], [0], [ignore], [ignore])
-TCP_PORT=`parse_listening_port ovsdb-server.log`
+TCP_PORT=`parse_listening_port ovsdb-server.log`
 AT_CHECK([ovsdb-client get-schema-version tcp:127.0.0.1:$TCP_PORT ordinals], [0], [5.1.3
 ])
 OVSDB_SERVER_SHUTDOWN
@@ -867,7 +867,7 @@ m4_define([OVSDB_CHECK_EXECUTION],
    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:127.0.0.1 --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore])
-   TCP_PORT=`parse_listening_port ovsdb-server.log`
+   TCP_PORT=`parse_listening_port ovsdb-server.log`
    m4_foreach([txn], [$3],
      [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT 'txn'], [0], [stdout], [ignore],
      [test ! -e pid || kill `cat pid`])
@@ -905,7 +905,7 @@ m4_define([OVSDB_CHECK_EXECUTION],
    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`
+   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`])