1f08c3bdfSopenharmony_ci#!/bin/sh 2f08c3bdfSopenharmony_ci 3f08c3bdfSopenharmony_ci# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. 4f08c3bdfSopenharmony_ci# Copyright (c) International Business Machines Corp., 2005 5f08c3bdfSopenharmony_ci# 6f08c3bdfSopenharmony_ci# This program is free software; you can redistribute it and/or 7f08c3bdfSopenharmony_ci# modify it under the terms of the GNU General Public License as 8f08c3bdfSopenharmony_ci# published by the Free Software Foundation; either version 2 of 9f08c3bdfSopenharmony_ci# the License, or (at your option) any later version. 10f08c3bdfSopenharmony_ci# 11f08c3bdfSopenharmony_ci# This program is distributed in the hope that it would be useful, 12f08c3bdfSopenharmony_ci# but WITHOUT ANY WARRANTY; without even the implied warranty of 13f08c3bdfSopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14f08c3bdfSopenharmony_ci# GNU General Public License for more details. 15f08c3bdfSopenharmony_ci# 16f08c3bdfSopenharmony_ci# You should have received a copy of the GNU General Public License 17f08c3bdfSopenharmony_ci# along with this program; if not, write the Free Software Foundation, 18f08c3bdfSopenharmony_ci# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19f08c3bdfSopenharmony_ci# 20f08c3bdfSopenharmony_ci# Author: Mitsuru Chinen <mitch@jp.ibm.com> 21f08c3bdfSopenharmony_ci 22f08c3bdfSopenharmony_ciTCID="http-stress02-rmt" 23f08c3bdfSopenharmony_ciTST_TOTAL=1 24f08c3bdfSopenharmony_ci 25f08c3bdfSopenharmony_ci. test.sh 26f08c3bdfSopenharmony_ci 27f08c3bdfSopenharmony_citst_require_cmds awk curl 28f08c3bdfSopenharmony_ci 29f08c3bdfSopenharmony_ciif [ $# -ne 5 ]; then 30f08c3bdfSopenharmony_ci tst_brkm TBROK "Usage: $0 server_addr fname fsize duration connections" 31f08c3bdfSopenharmony_cifi 32f08c3bdfSopenharmony_ci 33f08c3bdfSopenharmony_ciserver_ipaddr="$1" 34f08c3bdfSopenharmony_cifilename="$2" 35f08c3bdfSopenharmony_cifilesize="$3" 36f08c3bdfSopenharmony_ciduration="$4" 37f08c3bdfSopenharmony_ciconnections="$5" 38f08c3bdfSopenharmony_ci 39f08c3bdfSopenharmony_ciecho $server_ipaddr | grep -F ':' > /dev/null 40f08c3bdfSopenharmony_ciif [ $? -eq 0 ]; then 41f08c3bdfSopenharmony_ci server_ipaddr='['$server_ipaddr']' 42f08c3bdfSopenharmony_cifi 43f08c3bdfSopenharmony_ci 44f08c3bdfSopenharmony_cistart_epoc=$(date +%s) 45f08c3bdfSopenharmony_ciwhile true ; do 46f08c3bdfSopenharmony_ci # Exit when the specified seconds have passed. 47f08c3bdfSopenharmony_ci current_epoc=$(date +%s) 48f08c3bdfSopenharmony_ci elapse_epoc=$(($current_epoc - $start_epoc)) 49f08c3bdfSopenharmony_ci 50f08c3bdfSopenharmony_ci [ $elapse_epoc -ge $duration ] && break 51f08c3bdfSopenharmony_ci 52f08c3bdfSopenharmony_ci # Do not request the file over the specified quantity 53f08c3bdfSopenharmony_ci http_num=$(jobs | wc -l) 54f08c3bdfSopenharmony_ci if [ $http_num -ge $connections ]; then 55f08c3bdfSopenharmony_ci sleep 1 56f08c3bdfSopenharmony_ci continue; 57f08c3bdfSopenharmony_ci fi 58f08c3bdfSopenharmony_ci 59f08c3bdfSopenharmony_ci curl --noproxy '*' -s -g "http://$server_ipaddr/$filename" \ 60f08c3bdfSopenharmony_ci -o /dev/null & 61f08c3bdfSopenharmony_cidone 62f08c3bdfSopenharmony_ci 63f08c3bdfSopenharmony_cikillall -qw curl 64f08c3bdfSopenharmony_ci 65f08c3bdfSopenharmony_ciout=$(curl --noproxy '*' -sS -g "http://$server_ipaddr/$filename" -o /dev/null \ 66f08c3bdfSopenharmony_ci -w "time=%{time_total} size=%{size_download} speed=%{speed_download}") 67f08c3bdfSopenharmony_ci 68f08c3bdfSopenharmony_citst_resm TINFO "stat: $out" 69f08c3bdfSopenharmony_cirecv_filesize=$(echo "$out" | awk '{print $2}') 70f08c3bdfSopenharmony_ci 71f08c3bdfSopenharmony_ciif [ $recv_filesize != "size=$filesize" ]; then 72f08c3bdfSopenharmony_ci tst_resm TINFO "expected file size '$filesize'" 73f08c3bdfSopenharmony_ci tst_brkm TBROK "Failed to get http://$server_ipaddr/$filename" 74f08c3bdfSopenharmony_cifi 75f08c3bdfSopenharmony_ci 76f08c3bdfSopenharmony_citst_exit 77