zoukankan      html  css  js  c++  java
  • jmeter no-gui模式动态传递场景参数

    jmeter进行性能压测时,有时候需要在linux上no-gui模式下运行,为了在no-gui模式下更方便的设置脚本的运行的场景,

    将脚本的线程数,运行时间设置为动态参数,可以在脚本运行时动态设置“线程数”和“场景运行时间”;详情如下:

    #!/bin/bash
    
    ## JthreadCount:定义运行的线程数,在脚本中引用“${__P(threadCount,)}”
    ## JDurationTime:定义场景的运行时间(单位秒S),在脚本中引用“${__P(DurationTime,)}”
    ## --h:使用方法demo
    ## --r:运行脚本同时输出报告和日志文件
    ## --n:运行脚本不输出报告和日志文件
    
    
    if [ $1 == "--h" ]; then
        ##使用的demo
        echo "./runTest.sh 运行指令(--r) JthreadCount(线程数) JDurationTime(场景运行时间) ScriptName(脚本)"
    elif [ $1 == "--r" ]; then
        ##运行脚本,输出报告和日志文件
        ./jmeter.sh -n -JthreadCount=$2 -JDurationTime=$3 -t $4 -j $PWD/result/$(date +%y%m%d%H%M%S)_test_log.log -l $PWD/result/$(date +%y%m%d%H%M%S)_test_result.jtl
    elif [ $1 == "--n" ]; then
        #运行脚本不输出报告和日志文件
        ./jmeter.sh -n -JthreadCount=$2 -JDurationTime=$3 -t $4
    fi

    使用demo:

    #在jmeter的bin目录下执行:
    ./runTest.sh --n 2 30 performanceScript/testScript/demo.jmx
    
    # 2 :线程数
    # 30 :场景运行时间
    # demo.jmx :要运行的脚本

    在脚本中的设置:

  • 相关阅读:
    领域建模
    中科院
    开放搜索服务OpenSearch
    GUIForDebug
    java: org.luaj.vm2.LuaError:XXX module not found lua脚本初始化出错(转)
    new TimerTask(robot)(转)
    lua-TestMore(转)
    Lua 数据库访问(转)
    推荐谈论高并发柱
    查看文章strncpy()功能更好的文章
  • 原文地址:https://www.cnblogs.com/veitch-623/p/7082214.html
Copyright © 2011-2022 走看看