test-definitions/blob/master/auto-test/httperf-client/httperf.sh

#!/bin/sh
#回显执行的命令和参数
set -x

cd ../../utils

 . ./sys_info.sh

cd -
#检查是否是root用户
if [ `whoami` != 'root' ] ; then
    echo "You must be the superuser to run this script" >&2
    exit 1
fi
#distro=`cat /etc/redhat-release | cut -b 1-6`
#看起来centos 会通过源码编译httpperf
case $distro in
"centos")
     yum install make -y
     wget ftp://ftp.hpl.hp.com/pub/httperf/httperf-0.9.0.tar.gz
     tar -zxvf httperf-0.9.0.tar.gz
     cd httperf-0.9.0
     ./configure --build=arm-linux
     make
     make install
     print_info $? install-package
     ;;
 "ubuntu")
     apt-get install httperf -y
     print_info $? install-package
     ;;
esac
#Test ' httperf server'
#执行httperf测试,并加log输出到文件中
httperf --server sina.com.cn --num-conn 300 --rate 30 2>&1 | tee httperf.log
print_info $? httper-test
$TCID="httperf-test"
#在文件中查找关键字符串,后面会根据这个字符串是否为null,来判断是否执行成功
str=`grep -Po "total 0" httperf.log`

if [ "$str" != "" ] ; then
    lava-test-case $TCID --result pass
else
    lava-test-case $TCID --result faile
fi
#根据进程名杀掉进程
pkill httperf
删除log
rm httperf.log
#删除包
case $distro in
    "centos")
        yum remove make -y
        rm -f httperf-0.9.0.tar.gz
        rm -rf httperf-0.9.0
        print_info $? remove-httperf
        ;;
    "ubuntu")
        apt-get remove httperf -y
        print_info $? remove-httperf
        ;;
esac

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值