public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Hangbin Liu <liuhangbin@gmail.com>
To: LTP list <ltp-list@lists.sourceforge.net>
Subject: [LTP] [PATCH] networking/stress/tcp: make sure we will kill the test case after timeout
Date: Tue, 25 Jun 2013 15:48:52 +0800	[thread overview]
Message-ID: <1372146532-3182-1-git-send-email-liuhangbin@gmail.com> (raw)

In some old machines or guests, the system may not have the ability to set up
all the connections, e.g. 4000 tcp connections, quickly. Then the system will
take lots of time to try setup the connections or just huang there.

I think we should just kill all the connections after testing timeout, no
matter how many connections we have setup. So mv the connecting setup while
loop into whatchdog while loop.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 .../stress/tcp/multi-diffip/tcp4-multi-diffip01    | 62 ++++++++++-----------
 .../stress/tcp/multi-diffnic/tcp4-multi-diffnic01  | 28 +++++-----
 .../tcp/multi-diffport/tcp4-multi-diffport01       | 64 +++++++++++-----------
 .../tcp/multi-sameport/tcp4-multi-sameport01       | 33 +++++------
 4 files changed, 94 insertions(+), 93 deletions(-)

diff --git a/testcases/network/stress/tcp/multi-diffip/tcp4-multi-diffip01 b/testcases/network/stress/tcp/multi-diffip/tcp4-multi-diffip01
index 8b9652c..58fdde7 100644
--- a/testcases/network/stress/tcp/multi-diffip/tcp4-multi-diffip01
+++ b/testcases/network/stress/tcp/multi-diffip/tcp4-multi-diffip01
@@ -389,41 +389,41 @@ done
 server_pid=`grep PID: $info_file | cut -f 2 -d ' '`
 rm -f $info_file
 
-# Make connections
 connection_num=0
-while [ $connection_num -lt $ipaddr_pair_num ]; do
-    # IP addresses
-    x=`expr $connection_num \/ 255 % 255`
-    y=`expr $connection_num % 255`
-
-    case $IP_VER in
-	4)
-	lhost_addr="10.${x}.${y}.2"
-	;;
-
-	6)
-	hex_x=`printf %x $x`
-	hex_y=`printf %x $y`
-	lhost_addr="fd00:1:${hex_x}:${hex_y}::2"
-	;;
-    esac
-
-    ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-tcpclient -b -f $IP_VER -S $lhost_addr -p $server_port' ; echo $?'`
-    if [ $ret -ne 0 ]; then
-	if [ $connection_num -eq 0 ]; then
-	    tst_resm TFAIL "Failed to run any client"
-		exit 1
-	else
-	    tst_resm TINFO "$connection_num seems the maximum number of the client"
-	fi
-	break
-    fi
-    connection_num=`expr $connection_num + 1`
-done
-
 # Watch the TCP traffic server
 start_epoc=`date +%s`
 while true ; do
+	# Make connections
+	if [ $connection_num -lt $ipaddr_pair_num ]; then
+		# IP addresses
+		x=`expr $connection_num \/ 255 % 255`
+		y=`expr $connection_num % 255`
+
+		case $IP_VER in
+			4)
+				lhost_addr="10.${x}.${y}.2"
+				;;
+
+			6)
+				hex_x=`printf %x $x`
+				hex_y=`printf %x $y`
+				lhost_addr="fd00:1:${hex_x}:${hex_y}::2"
+				;;
+		esac
+
+		ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-tcpclient -b -f $IP_VER -S $lhost_addr -p $server_port' ; echo $?'`
+		if [ $ret -ne 0 ]; then
+			if [ $connection_num -eq 0 ]; then
+				tst_resm TFAIL "Failed to run any client"
+				exit 1
+			else
+				tst_resm TINFO "$connection_num seems the maximum number of the client"
+			fi
+			break
+		fi
+		connection_num=`expr $connection_num + 1`
+	fi
+
     current_epoc=`date +%s`
     elapse_epoc=`expr $current_epoc - $start_epoc`
 
diff --git a/testcases/network/stress/tcp/multi-diffnic/tcp4-multi-diffnic01 b/testcases/network/stress/tcp/multi-diffnic/tcp4-multi-diffnic01
index dc9e784..6a5a72c 100644
--- a/testcases/network/stress/tcp/multi-diffnic/tcp4-multi-diffnic01
+++ b/testcases/network/stress/tcp/multi-diffnic/tcp4-multi-diffnic01
@@ -340,24 +340,24 @@ done
 server_pid=`grep PID: $info_file | cut -f 2 -d ' '`
 rm -f $info_file
 
-# Main loop
 connection_num=0
-while [ $connection_num -lt $link_total ]; do
-    field=`expr $connection_num + 1`
-    lhost_addr=`echo $lhost_addrs | cut -d ' ' -f $field`
-
-    # Run a client
-    ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-tcpclient -b -f $IP_VER -S $lhost_addr -p $server_port'; echo $?'`
-    if [ $ret -ne 0 ]; then
-	tst_resm TFAIL "Failed to run client on Link${connection_num}"
-	exit 1
-    fi
-    connection_num=`expr $connection_num + 1`
-done
-
 # Watch the TCP traffic server
 start_epoc=`date +%s`
 while true ; do
+	# Main loop
+	if [ $connection_num -lt $link_total ]; then
+		field=`expr $connection_num + 1`
+		lhost_addr=`echo $lhost_addrs | cut -d ' ' -f $field`
+
+		# Run a client
+		ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-tcpclient -b -f $IP_VER -S $lhost_addr -p $server_port'; echo $?'`
+		if [ $ret -ne 0 ]; then
+			tst_resm TFAIL "Failed to run client on Link${connection_num}"
+			exit 1
+		fi
+		connection_num=`expr $connection_num + 1`
+	fi
+
     current_epoc=`date +%s`
     elapse_epoc=`expr $current_epoc - $start_epoc`
 
diff --git a/testcases/network/stress/tcp/multi-diffport/tcp4-multi-diffport01 b/testcases/network/stress/tcp/multi-diffport/tcp4-multi-diffport01
index e260d35..1b9f342 100644
--- a/testcases/network/stress/tcp/multi-diffport/tcp4-multi-diffport01
+++ b/testcases/network/stress/tcp/multi-diffport/tcp4-multi-diffport01
@@ -320,44 +320,44 @@ fi
 start_port=`echo $portbundle | cut -f 1 -d '-'`
 end_port=`echo $portbundle | cut -f 2 -d '-'`
 
-# Making connections
 connection_num=0
 current_port=$start_port
-while [ $current_port -le $end_port ]; do
-    # Run a server
-    ns-tcpserver -b -f $IP_VER -p $current_port
-    if [ $? -ne 0 ]; then
-	# Failed to start no server
-	if [ $connection_num -eq 0 ]; then
-	    tst_resm TFAIL "Failed to run a server"
-	    exit 1
-	fi
-	# Failed to start a server
-	tst_resm TINFO "$connection_num seems the maximum number of the server"
-	break
-    fi
-
-    # Run a clinet
-    ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-tcpclient -b -f $IP_VER -S $lhost_addr -p $current_port' ; echo $?'`
-    if [ $ret -ne 0 ]; then
-	# Failed to start any client
-	if [ $connection_num -eq 0 ]; then
-	    tst_resm TFAIL "Failed to run any client."
-	    exit 1
-	fi
-	# Failed to start a client
-	tst_resm TINFO "$connection_num seems the maximum number of the client"
-	break
-    fi
-
-    current_port=`expr $current_port + 1`
-    connection_num=`expr $connection_num + 1`
-done
-
 
 # Watch the TCP traffic server
 start_epoc=`date +%s`
 while true ; do
+	# Making connections
+	if [ $current_port -le $end_port ]; then
+		# Run a server
+		ns-tcpserver -b -f $IP_VER -p $current_port
+		if [ $? -ne 0 ]; then
+			# Failed to start no server
+			if [ $connection_num -eq 0 ]; then
+				tst_resm TFAIL "Failed to run a server"
+				exit 1
+			fi
+			# Failed to start a server
+			tst_resm TINFO "$connection_num seems the maximum number of the server"
+			break
+		fi
+
+		# Run a clinet
+		ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-tcpclient -b -f $IP_VER -S $lhost_addr -p $current_port' ; echo $?'`
+		if [ $ret -ne 0 ]; then
+			# Failed to start any client
+			if [ $connection_num -eq 0 ]; then
+				tst_resm TFAIL "Failed to run any client."
+				exit 1
+			fi
+			# Failed to start a client
+			tst_resm TINFO "$connection_num seems the maximum number of the client"
+			break
+		fi
+
+		current_port=`expr $current_port + 1`
+		connection_num=`expr $connection_num + 1`
+	fi
+
     current_epoc=`date +%s`
     elapse_epoc=`expr $current_epoc - $start_epoc`
     if [ $elapse_epoc -ge $NS_DURATION ]; then
diff --git a/testcases/network/stress/tcp/multi-sameport/tcp4-multi-sameport01 b/testcases/network/stress/tcp/multi-sameport/tcp4-multi-sameport01
index aff2481..206a0d1 100644
--- a/testcases/network/stress/tcp/multi-sameport/tcp4-multi-sameport01
+++ b/testcases/network/stress/tcp/multi-sameport/tcp4-multi-sameport01
@@ -334,27 +334,28 @@ done
 server_pid=`grep PID: $info_file | cut -f 2 -d ' '`
 rm -f $info_file
 
-# Making connections
 connection_num=0
-while [ $connection_num -lt $CONNECTION_TOTAL ]; do
-    # Run a client
-    ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-tcpclient -b -f $IP_VER -S $lhost_addr -p $server_port' ; echo $?'`
-    if [ $ret -ne 0 ]; then
-	# Failed to start any client
-	if [ $connection_num -eq 0 ]; then
-	    tst_resm TFAIL "Failed to run any client"
-	    exit 1
-	fi
-	# Failed to start a client
-	tst_resm TINFO "$connection_num seems the maximum number of the client"
-	break
-    fi
-    connection_num=`expr $connection_num + 1`
-done
 
 # Watch the TCP traffic server
 start_epoc=`date +%s`
 while true ; do
+	# Making connections
+	if [ $connection_num -lt $CONNECTION_TOTAL ]; then
+		# Run a client
+		ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/ns-tcpclient -b -f $IP_VER -S $lhost_addr -p $server_port' ; echo $?'`
+		if [ $ret -ne 0 ]; then
+			# Failed to start any client
+			if [ $connection_num -eq 0 ]; then
+				tst_resm TFAIL "Failed to run any client"
+				exit 1
+			fi
+			# Failed to start a client
+			tst_resm TINFO "$connection_num seems the maximum number of the client"
+			break
+		fi
+		connection_num=`expr $connection_num + 1`
+	fi
+
     current_epoc=`date +%s`
     elapse_epoc=`expr $current_epoc - $start_epoc`
 
-- 
1.8.1.4


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

             reply	other threads:[~2013-06-25  7:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-25  7:48 Hangbin Liu [this message]
2013-06-27 16:25 ` [LTP] [PATCH] networking/stress/tcp: make sure we will kill the test case after timeout Jan Stancek
     [not found]   ` <CAPwn2JTuF3EVb8_XoWkFk=qZc61FhNHenNDmdR7b6xrZFf9x1g@mail.gmail.com>
2013-06-28  7:13     ` Jan Stancek
     [not found]       ` <CAPwn2JRYRWDEvn090NdtM1K178R=yQSasmBX3ZoKymVtcRWPXw@mail.gmail.com>
2013-06-28 11:06         ` Jan Stancek
2013-07-01  8:31           ` Hangbin Liu
2013-07-01 10:56             ` Jan Stancek
2013-07-04  1:03               ` Hangbin Liu
2013-07-01 12:56             ` KUMAR, BHUSHAN

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1372146532-3182-1-git-send-email-liuhangbin@gmail.com \
    --to=liuhangbin@gmail.com \
    --cc=ltp-list@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox