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 22TCID="http-stress02-rmt" 23TST_TOTAL=1 24 25. test.sh 26 27tst_require_cmds awk curl 28 29if [ $# -ne 5 ]; then 30 tst_brkm TBROK "Usage: $0 server_addr fname fsize duration connections" 31fi 32 33server_ipaddr="$1" 34filename="$2" 35filesize="$3" 36duration="$4" 37connections="$5" 38 39echo $server_ipaddr | grep -F ':' > /dev/null 40if [ $? -eq 0 ]; then 41 server_ipaddr='['$server_ipaddr']' 42fi 43 44start_epoc=$(date +%s) 45while true ; do 46 # Exit when the specified seconds have passed. 47 current_epoc=$(date +%s) 48 elapse_epoc=$(($current_epoc - $start_epoc)) 49 50 [ $elapse_epoc -ge $duration ] && break 51 52 # Do not request the file over the specified quantity 53 http_num=$(jobs | wc -l) 54 if [ $http_num -ge $connections ]; then 55 sleep 1 56 continue; 57 fi 58 59 curl --noproxy '*' -s -g "http://$server_ipaddr/$filename" \ 60 -o /dev/null & 61done 62 63killall -qw -s SIGPIPE curl 64 65out=$(curl --noproxy '*' -sS -g "http://$server_ipaddr/$filename" -o /dev/null \ 66 -w "time=%{time_total} size=%{size_download} speed=%{speed_download}") 67 68tst_resm TINFO "stat: $out" 69recv_filesize=$(echo "$out" | awk '{print $2}') 70 71if [ $recv_filesize != "size=$filesize" ]; then 72 tst_resm TINFO "expected file size '$filesize'" 73 tst_brkm TBROK "Failed to get http://$server_ipaddr/$filename" 74fi 75 76tst_exit 77