• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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@jp.ibm.com>
21#
22
23TCID="ssh_stress01_rmt"
24TST_TOTAL=1
25
26. test.sh
27
28if [ $# -ne 4 ]; then
29	tst_brkm TBROK "Usage: $0 ipver rhost config connections"
30fi
31
32ip_ver="$1"
33server_ipaddr="$2"
34ssh_config="$3"
35connections="$4"
36
37ssh -$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
43num=0
44while [ $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))
51done
52
53# Disconnect all ssh connection
54all_conn=$(ps auxw | grep -Fv grep | \
55	grep "ssh[[:blank:]].*${ssh_config}" | awk '{print $2}')
56
57for ssh_pid in "$all_conn"; do
58	kill $ssh_pid
59done
60
61# Check the connectivity again
62ssh -$ip_ver -F $ssh_config $server_ipaddr \
63	"true < /dev/null > /dev/null 2>&1" > /dev/null
64if [ $? -ne 0 ]; then
65	tst_brkm TBROK "Failed to connect $server_ipaddr"
66fi
67
68tst_exit
69