Home | History | Annotate | Download | only in ssh
      1 #!/bin/sh
      2 
      3 # Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
      4 # Copyright (c) International Business Machines  Corp., 2005
      5 #
      6 # This program is free software; you can redistribute it and/or
      7 # modify it under the terms of the GNU General Public License as
      8 # published by the Free Software Foundation; either version 2 of
      9 # the License, or (at your option) any later version.
     10 #
     11 # This program is distributed in the hope that it would be useful,
     12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 # GNU General Public License for more details.
     15 #
     16 # You should have received a copy of the GNU General Public License
     17 # along with this program; if not, write the Free Software Foundation,
     18 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     19 #
     20 # Author: Mitsuru Chinen <mitch (at] jp.ibm.com>
     21 #
     22 
     23 TCID="ssh_stress01_rmt"
     24 TST_TOTAL=1
     25 
     26 . test.sh
     27 
     28 if [ $# -ne 4 ]; then
     29 	tst_brkm TBROK "Usage: $0 ipver rhost config connections"
     30 fi
     31 
     32 ip_ver="$1"
     33 server_ipaddr="$2"
     34 ssh_config="$3"
     35 connections="$4"
     36 
     37 ssh -$ip_ver -F $ssh_config $server_ipaddr \
     38 	"true < /dev/null > /dev/null 2>&1" > /dev/null
     39 
     40 [ $? -ne 0 ] && tst_brkm TBROK "Can't connect to '$server_ipaddr'"
     41 
     42 # Make ssh connections
     43 num=0
     44 while [ $num -lt $connections ]; do
     45 	ssh -$ip_ver -f -N -F $ssh_config $server_ipaddr
     46 	if [ $? -ne 0 ]; then
     47 		tst_resm TINFO "'$num' seems the max num of ssh conn"
     48 		break
     49 	fi
     50 	num=$(($num + 1))
     51 done
     52 
     53 # Disconnect all ssh connection
     54 all_conn=$(ps auxw | grep -Fv grep | \
     55 	grep "ssh[[:blank:]].*${ssh_config}" | awk '{print $2}')
     56 kill $all_conn
     57 
     58 # Check the connectivity again
     59 ssh -$ip_ver -F $ssh_config $server_ipaddr \
     60 	"true < /dev/null > /dev/null 2>&1" > /dev/null
     61 if [ $? -ne 0 ]; then
     62 	tst_brkm TBROK "Failed to connect $server_ipaddr"
     63 fi
     64 
     65 tst_exit
     66