zoukankan      html  css  js  c++  java
  • Linux shell 批量运行jmeter脚本

    第一版,这些代码有点问题,需要继续更改

    #!/bin/bash
    
    jmxpath=
    reportpath=
    
    timestamp=$(date +%Y%m%d_%H%M%S)
    echo timestamp
    function readfile ()
    {
      for file in `ls $1`
      do
        if [ -d $1"/"$file ]
        then
          readfile $1"/"$file
        else
        if [ "${file##*.}" == "jmx" ];
            then
               echo $jmxpath"/"$file
               filename="${file%.*}"
               run_jmeter $jmxpath"/"$file $filename $reportpath
            fi
        echo `basename $file`
        fi
      done
    }
    
    function run_jmeter () {
      echo $1 $2 $3
     # mkdir -p $3"/out/"$2$timestamp"/"
      jmeter.sh -n -t $1 -f -l $3"/"jtl"/"$2"/"$2$timestamp".jtl" -e -o $3"/"html"/"$2"/"$2$timestamp
    }
    
    if  [ ! -n "$1" ] ;then
        echo "Please input the target test case jmx path"
        read jmxpath
    else
        jmxpath=$1
        
    fi
    
    if  [ ! -n "$2" ] ;then
        echo "Please input the test results out path"
        read outputpath
    else
        outputpath=$2
        
    fi
    
    readfile $1 $2

    第二版,这些代码有点问题,需要继续更改

    #!/bin/bash
    
    jmxpath=$1
    reportpath=$2
    
    function readfile ()
    {
      for file in `ls $1`
      do
        if [ -d $1"/"$file ]
        then
          readfile $1"/"$file
        else
            if [ "${file##*.}" == "jmx" ];
            then
               echo $jmxpath"/"$file
               filename="${file%.*}"
               run_jmeter $jmxpath"/"$file $filename $reportpath
            fi
        echo `basename $file`
        fi
      done
    }
    
    function run_jmeter () {
      echo $1 $2 $3
      timestamp=$(date +%Y%m%d_%H%M%S)
      echo timestamp
      mkdir -p $3"/html/"$2"/"$2$timestamp"/"
      mkdir -p $3"/jtl/"$2"/"
      jmeter.sh -n -t $1 -f -l $3"/jtl/"$2"/"$2$timestamp".jtl" -e -o $3"/html/"$2"/"$2$timestamp
    }
    
    if  [ ! -n "$1" ] ;then
        echo "Please input the target test case jmx path"
        read jmxpath
    else
        jmxpath=$1
    
    fi
    
    if  [ ! -n "$2" ] ;then
        echo "Please input the test results out path"
        read reportpath
    else
        reportpath=$2
    
    fi
    
    readfile $jmxpath $reportpath
  • 相关阅读:
    放假归来
    用ObjectSpaces重建IBuySpy的数据访问层
    在SPS中加入自定义WebService
    AnnouncementOSD.xml
    Delphi8 is out !
    ASP.NET PreCompilation and KeepAlive
    ScottGu回答了Whidbey发布的时间问题
    DiskBased Caching in Whidbey, Longhorn…
    AnnouncementRSD.xml
    忙着满足客户的需求...
  • 原文地址:https://www.cnblogs.com/majestyking/p/10747888.html
Copyright © 2011-2022 走看看