Skip to content

Commit

Permalink
tests: Change to parse dynamically allocated ports on windows.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
shettyg committed May 15, 2014
1 parent c17b52e commit ecaf2f5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions tests/ofproto-dpif.at
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 -- \
Expand Down Expand Up @@ -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 -- \
Expand Down Expand Up @@ -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\" \
Expand Down
4 changes: 2 additions & 2 deletions tests/ofproto-macros.at
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down
4 changes: 2 additions & 2 deletions tests/ovsdb-idl.at
Original file line number Diff line number Diff line change
Expand Up @@ -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`])])
Expand All @@ -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], [], [],
Expand Down
12 changes: 6 additions & 6 deletions tests/ovsdb-server.at
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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`])
Expand Down Expand Up @@ -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`])
Expand All @@ -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
Expand Down Expand Up @@ -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`])
Expand Down Expand Up @@ -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`])
Expand Down

0 comments on commit ecaf2f5

Please sign in to comment.