Issue with maximum number of command line arguments in JMeter

时间:2016-05-19 08:16:05

标签: python jmeter

I'm passing a couple of command line arguments from my python script to JMeter like this:

    command = [jmeter_command_line, jmeter_test_file,
               '-JTHREADS={threads_limit}'.format(threads_limit=threads_limit),
               '-JDURATION={0}'.format(duration_seconds_all_tests),
               '-JTEST_URL="{0}"'.format(test_url),
               '-JTEST_NAME="{0}"'.format(test_name),
               '-JTEST_OUTPUT_DIR="{0}"'.format(output_dir),
               '-p', jmeter_properties]
    call(command)

Everytime I run the script the two last two arguments are not being read by JMeter. Here's a sample of log file:

2016/05/19 09:41:51 INFO  - jmeter.JMeter: Loading system properties from: C:\Users\user\Downloads\apache-jmeter-2.13\bin\system.properties 
2016/05/19 09:41:51 INFO  - jmeter.JMeter: Setting JMeter property: THREADS=5 
2016/05/19 09:41:51 INFO  - jmeter.JMeter: Setting JMeter property: DURATION=15 
2016/05/19 09:41:51 INFO  - jmeter.JMeter: Setting JMeter property: TEST_URL="some/path" 
2016/05/19 09:41:51 INFO  - jmeter.JMeter: Setting JMeter property: TEST_NAME="testname"  

But when I switch the order of the last two arguments like this:

command = [jmeter_command_line, jmeter_test_file,
               '-JTHREADS={threads_limit}'.format(threads_limit=threads_limit),
               '-JDURATION={0}'.format(duration_seconds_all_tests),
               '-JTEST_URL="{0}"'.format(test_url),
               '-JTEST_OUTPUT_DIR="{0}"'.format(output_dir), <-- lines changed
               '-JTEST_NAME="{0}"'.format(test_name),        <-- lines changed
               '-p', jmeter_properties]
    logger.debug(' '.join(command))
    call(command)

It's the same, the last arguments are dropped:

2016/05/19 10:08:30 INFO  - jmeter.JMeter: Loading system properties from: C:\Users\user\Downloads\apache-jmeter-2.13\bin\system.properties 
2016/05/19 10:08:30 INFO  - jmeter.JMeter: Setting JMeter property: THREADS=5 
2016/05/19 10:08:30 INFO  - jmeter.JMeter: Setting JMeter property: DURATION=15 
2016/05/19 10:08:30 INFO  - jmeter.JMeter: Setting JMeter property: TEST_URL="test/url" 
2016/05/19 10:08:30 INFO  - jmeter.JMeter: Setting JMeter property: TEST_OUTPUT_DIR="path/to/results" 

So it seems to me that there is a limit to how many arguments I can provide to JMeter. Is there something I am missing? I was looking for an answer in the JMeter docs, but I haven't found anything indicating that there is such a limit. I don't think it's a fault of Python code because I checked that it calls all of the arguments.

2 个答案:

答案 0 :(得分:1)

问题是我通过调用jmeter-n.cmd脚本在Windows上以非GUI模式运行jmeter。该脚本包含以下行:

rem use same directory to find jmeter script
call "%~dp0"jmeter -n -t "%~nx1" -j "%~n1.log" -l "%~n1.jtl" %2 %3 %4 %5 %6 %7 %8 %9

所以它的编写方式不能超过10个参数。

解决方案是使用jmeter -n -t script_name.jmx脚本直接运行它。

答案 1 :(得分:0)

jmeter应该基于你来的服务器jvm的最大数量,而你和脚本本身没有直接关系,参考http://performancewebautoamtionother.blogspot.sg/2015/12/jmeter-and-javavisualvm.html希望能帮到你