軟件測試常用shell腳本

一 循環(huán)

#!/bin/bash

mv perf.log perf.log_bak

while (( "1"=="1" ))

do

java -cp 'conf/:apps/*:lib/*' org.bcos.channel.test.db.PerfomanceOk trans 50000 100? >>? perf.log

sleep 550

done

二 預(yù)期輸入

#!/bin/bash

set -x

set -e

ethconsole ${node_path}/nodedata-1/data/geth.ipc <<EOF

web3.admin.getPeers(console.log);web3.eth.getBlock(2,console.log)

EOF

/usr/bin/expect << EOF

set timeout 500

spawn ./install_node.sh install

expect "gavin:"

send "Aa12345!\r"

expect "Installing eth environment success"

EOF

三 函數(shù)調(diào)用

running(){

? sleep 1

? old_count=`grep +++++? ${host_path}/build/nodedir$1/log/info*|wc -l`

? sleep 7

? new_count=`grep +++++? ${host_path}/build/nodedir$1/log/info*|wc -l`

? if((${old_count}<${new_count}))

? then

? ? echo "****** success, node$1 is running normally ******"

? ? #return true

? else

? ? echo "****** fail,node$1 is not running ******"

? ? #return false

? fi

}

running 3

四 curl命令借口測試

curl?-X?POST?--data?'{"jsonrpc":"2.0","method":"admin_nodeInfo","params":[],"id":83}'?127.0.0.1:8545

curl -s -l -H "Content-type: application/json" -X POST -d '{"seqNo":"1067","orgNo":"123","chainId":"100120043","chainName":"he43","chainContent":"test43","extId":"ex43"}'http://10.107.105.143:9000/api/chain/new

五 根據(jù)日志統(tǒng)計

grep?'2018-09-06?19:1'?appmonitor.log|grep?New?|awk?-F?'"'?'{a+=$8;b+=1}?END?{print?a,b,a/b}'??統(tǒng)計19:10-19:19分,所有上鏈的次數(shù)和平均耗時

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容