start time和end time本身就在index.html文件里。
而下方的类似聚合报告在哪里呢?通过Linux命令检索:find .
|xargs grep -iR
"statisticsTable",看到是在js文件里存储的数据。
使用shell命令提取文件数据,使用shell将结果插入数据库中。
dir=${WORKSPACE}/test_report
startTime=`grep "Start Time:" -A1 $dir/index.html|tail -n
1|awk -F'"' '{print $2}'`
endTime=`grep "End Time:" -A1 $dir/index.html|tail -n 1|awk
-F'"' '{print $2}'`
resLine=`grep "statisticsTable"
$dir/content/js/dashboard.js`
resLine=`echo ${resLine#*,}`
resLine=`echo ${resLine%, function*}`
label=`echo $resLine|jq .items[0].data[0]|tr -d '"'`
samples=`echo $resLine|jq .items[0].data[1]`
ko=`echo $resLine|jq .items[0].data[2]`
errRate=`echo $resLine|jq .items[0].data[3]`
avgRt=`echo $resLine|jq .items[0].data[4]`
minRt=`echo $resLine|jq .items[0].data[5]`
maxRt=`echo $resLine|jq .items[0].data[6]`
NinetyRt=`echo $resLine|jq .items[0].data[7]`
NinetyFineRt=`echo $resLine|jq .items[0].data[8]`
NinetyNineRt=`echo $resLine|jq .items[0].data[9]`
throughput=`echo $resLine|jq .items[0].data[10]`
received=`echo $resLine|jq .items[0].data[11]`
sent=`echo $resLine|jq .items[0].data[12]`
mysql -h db-ip -P db-port -u username -ppassword dbname -se
"insert into
qqqq(label,samples,ko,errRate,avgRt,minRt,maxRt,90Rt,95Rt,99Rt,throughput,received,sent,startTime,endTime,createTime)
values('$label','$samples','$ko','$errRate','$avgRt','$minRt','$maxRt','$NinetyRt','$NinetyFineRt','$NinetyNineRt','$throughput','$received','$sent',str_to_date('$startTime',
'%m/%d/%y %h:%i %p'),str_to_date('$endTime', '%m/%d/%y %h:%i
%p'),now())"