JMeter学习-027-JMeter参数文件(脚本分发)路径问题:jmeter.threads.JMeterThread: Test failed! java.lang.IllegalArgumen

JMeter学习-027-JMeter参数文件(脚本分发)路径问题:jmeter.threads.JMeterThread: Test failed! java.lang.IllegalArgumentException: File distributed.csv must exist and be readable解决方法
 
http://www.cnblogs.com/fengpingfan/p/5600709.html
 

前些天,在进行分布式参数化测试的时候,出现了如题所示的错误报错信息。此文,针对此做一个简略的重现及分析说明。

JMX脚本线程组参数配置如下所示:

JMeter学习-027-JMeter参数文件(脚本分发)路径问题:jmeter.threads.JMeterThread: Test failed! java.lang.IllegalArgumen_第1张图片

参数文件路径配置如下所示:

JMeter学习-027-JMeter参数文件(脚本分发)路径问题:jmeter.threads.JMeterThread: Test failed! java.lang.IllegalArgumen_第2张图片

JMeter学习-027-JMeter参数文件(脚本分发)路径问题:jmeter.threads.JMeterThread: Test failed! java.lang.IllegalArgumen_第3张图片

执行JMX脚本后,服务器对应日志错误信息(部分)输出如下所示:

?
2016 / 06 / 17 23 : 06 : 59 INFO  - jmeter.services.FileServer: Stored: E:\ 026 \distributed.csv
2016 / 06 / 17 11 : 06 : 59 ERROR - jmeter.threads.JMeterThread: Test failed! java.lang.IllegalArgumentException: File distributed.csv must exist and be readable
    at org.apache.jmeter.services.FileServer.createBufferedReader(FileServer.java: 422 )
    at org.apache.jmeter.services.FileServer.readLine(FileServer.java: 347 )
    at org.apache.jmeter.config.CSVDataSet.iterationStart(CSVDataSet.java: 198 )
    at org.apache.jmeter.control.GenericController.fireIterationStart(GenericController.java: 405 )
    at org.apache.jmeter.control.GenericController.fireIterEvents(GenericController.java: 397 )
    at org.apache.jmeter.control.GenericController.next(GenericController.java: 158 )
    at org.apache.jmeter.control.LoopController.next(LoopController.java: 123 )
    at org.apache.jmeter.threads.AbstractThreadGroup.next(AbstractThreadGroup.java: 87 )
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java: 239 )
    at java.lang.Thread.run(Unknown Source)
或者
2016 / 06 / 17 23 : 13 : 05 INFO  - jmeter.threads.JMeterThread: Thread started: 文章详情 1 - 1
2016 / 06 / 17 23 : 13 : 05 INFO  - jmeter.services.FileServer: Stored: ./distributed.csv
2016 / 06 / 17 11 : 13 : 05 ERROR - jmeter.threads.JMeterThread: Test failed! java.lang.IllegalArgumentException: File distributed.csv must exist and be readable
    at org.apache.jmeter.services.FileServer.createBufferedReader(FileServer.java: 422 )
    at org.apache.jmeter.services.FileServer.readLine(FileServer.java: 347 )
    at org.apache.jmeter.config.CSVDataSet.iterationStart(CSVDataSet.java: 198 )
    at org.apache.jmeter.control.GenericController.fireIterationStart(GenericController.java: 405 )
    at org.apache.jmeter.control.GenericController.fireIterEvents(GenericController.java: 397 )
    at org.apache.jmeter.control.GenericController.next(GenericController.java: 158 )
    at org.apache.jmeter.control.LoopController.next(LoopController.java: 123 )
    at org.apache.jmeter.threads.AbstractThreadGroup.next(AbstractThreadGroup.java: 87 )
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java: 239 )
    at java.lang.Thread.run(Unknown Source)

综上,如下两种情况下,测试脚本参数化均无法按照预期正确执行:

  1. 参数文件路径为绝对路径,但对应路径下不存在
  2. 参数文件路径为相对路径,但对应执行机(Slave)服务分发路径下不存在

那么,调度机(Controller)分发脚本到执行机(Slave)的路径是什么呢?查看脚本分发路径有如下两种方式:

一、通过执行机服务日志,user.dir 目录即为分发路径(推荐)

+ View Code ?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2016 / 06 / 20 15 : 01 : 47 INFO  - jmeter.util.JMeterUtils: Setting Locale to zh_CN
2016 / 06 / 20 15 : 01 : 47 INFO  - jmeter.JMeter: Loading user properties from: D:\DevTool\apache-jmeter- 3.0 \bin\user.properties
2016 / 06 / 20 15 : 01 : 47 INFO  - jmeter.JMeter: Loading system properties from: D:\DevTool\apache-jmeter- 3.0 \bin\system.properties
2016 / 06 / 20 15 : 01 : 47 INFO  - jmeter.JMeter: Copyright (c) 1998 - 2016 The Apache Software Foundation
2016 / 06 / 20 15 : 01 : 47 INFO  - jmeter.JMeter: Version 3.0 r1743807
2016 / 06 / 20 15 : 01 : 47 INFO  - jmeter.JMeter: java.version= 1.8 .0_66
2016 / 06 / 20 15 : 01 : 47 INFO  - jmeter.JMeter: java.vm.name=Java HotSpot(TM) 64 -Bit Server VM
2016 / 06 / 20 15 : 01 : 47 INFO  - jmeter.JMeter: os.name=Windows 7
2016 / 06 / 20 15 : 01 : 47 INFO  - jmeter.JMeter: os.arch=amd64
2016 / 06 / 20 15 : 01 : 47 INFO  - jmeter.JMeter: os.version= 6.1
2016 / 06 / 20 15 : 01 : 47 INFO  - jmeter.JMeter: file.encoding=GBK
2016 / 06 / 20 15 : 01 : 47 INFO  - jmeter.JMeter: Max memory     = 523763712
2016 / 06 / 20 15 : 01 : 47 INFO  - jmeter.JMeter: Available Processors = 4
2016 / 06 / 20 15 : 01 : 47 INFO  - jmeter.JMeter: Default Locale=中文 (中国)
2016 / 06 / 20 15 : 01 : 47 INFO  - jmeter.JMeter: JMeter  Locale=中文 (中国)
2016 / 06 / 20 15 : 01 : 47 INFO  - jmeter.JMeter: JMeterHome=D:\DevTool\apache-jmeter- 3.0
2016 / 06 / 20 15 : 01 : 47 INFO  - jmeter.JMeter: user.dir  =D:\DevTool\apache-jmeter- 3.0 \bin
2016 / 06 / 20 15 : 01 : 47 INFO  - jmeter.JMeter: PWD       =D:\DevTool\apache-jmeter- 3.0 \bin

二、分发jmx脚本目录即为执行机服务启动目录,例如执行机服务启动命令行如下所示:

JMeter学习-027-JMeter参数文件(脚本分发)路径问题:jmeter.threads.JMeterThread: Test failed! java.lang.IllegalArgumen_第4张图片

那么,此执行机对应的jmx脚本分发目录为:D:\DevTool\apache-jmeter-3.0\bin

执行JMX测试脚本

    • 第一次,对应分发路径无对应参数文件
    • 第二次,对应分发路径有对应参数文件

执行机(Slave)端控制台输出如下所示:

JMeter学习-027-JMeter参数文件(脚本分发)路径问题:jmeter.threads.JMeterThread: Test failed! java.lang.IllegalArgumen_第5张图片

JMX脚本两次执行结果如下所示:

JMeter学习-027-JMeter参数文件(脚本分发)路径问题:jmeter.threads.JMeterThread: Test failed! java.lang.IllegalArgumen_第6张图片

由执行结果可见,将 JMX 脚本对应参数文件放到正确的目录后,脚本成功执行。

附录:执行机(Slave)日志输出如下所示:

复制代码
  1 2016/06/20 15:01:47 INFO  - jmeter.util.JMeterUtils: Setting Locale to zh_CN 
  2 2016/06/20 15:01:47 INFO  - jmeter.JMeter: Loading user properties from: D:\DevTool\apache-jmeter-3.0\bin\user.properties 
  3 2016/06/20 15:01:47 INFO  - jmeter.JMeter: Loading system properties from: D:\DevTool\apache-jmeter-3.0\bin\system.properties 
  4 2016/06/20 15:01:47 INFO  - jmeter.JMeter: Copyright (c) 1998-2016 The Apache Software Foundation 
  5 2016/06/20 15:01:47 INFO  - jmeter.JMeter: Version 3.0 r1743807 
  6 2016/06/20 15:01:47 INFO  - jmeter.JMeter: java.version=1.8.0_66 
  7 2016/06/20 15:01:47 INFO  - jmeter.JMeter: java.vm.name=Java HotSpot(TM) 64-Bit Server VM 
  8 2016/06/20 15:01:47 INFO  - jmeter.JMeter: os.name=Windows 7 
  9 2016/06/20 15:01:47 INFO  - jmeter.JMeter: os.arch=amd64 
 10 2016/06/20 15:01:47 INFO  - jmeter.JMeter: os.version=6.1 
 11 2016/06/20 15:01:47 INFO  - jmeter.JMeter: file.encoding=GBK 
 12 2016/06/20 15:01:47 INFO  - jmeter.JMeter: Max memory     =523763712 
 13 2016/06/20 15:01:47 INFO  - jmeter.JMeter: Available Processors =4 
 14 2016/06/20 15:01:47 INFO  - jmeter.JMeter: Default Locale=中文 (中国) 
 15 2016/06/20 15:01:47 INFO  - jmeter.JMeter: JMeter  Locale=中文 (中国) 
 16 2016/06/20 15:01:47 INFO  - jmeter.JMeter: JMeterHome=D:\DevTool\apache-jmeter-3.0 
 17 2016/06/20 15:01:47 INFO  - jmeter.JMeter: user.dir  =D:\DevTool\apache-jmeter-3.0\bin 
 18 2016/06/20 15:01:47 INFO  - jmeter.JMeter: PWD       =D:\DevTool\apache-jmeter-3.0\bin 
 19 2016/06/20 15:01:47 INFO  - jmeter.JMeter: IP: 10.9.215.47 Name: TEST FullName: TEST.ffp.corp 
 20 2016/06/20 15:01:47 INFO  - jmeter.engine.RemoteJMeterEngineImpl: Starting backing engine on 1029 
 21 2016/06/20 15:01:47 INFO  - jmeter.engine.RemoteJMeterEngineImpl: System property 'java.rmi.server.hostname' is not defined, using localHost address 
 22 2016/06/20 15:01:47 INFO  - jmeter.engine.RemoteJMeterEngineImpl: Local IP address=10.9.215.47 
 23 2016/06/20 15:01:47 INFO  - jmeter.engine.RemoteJMeterEngineImpl: IP address is a site-local address; this may cause problems with remote access.
 24     Can be overridden by defining the system property 'java.rmi.server.hostname' - see jmeter-server script file 
 25 2016/06/20 15:01:47 INFO  - jmeter.engine.RemoteJMeterEngineImpl: Creating RMI registry (server.rmi.create=true) 
 26 2016/06/20 15:01:47 INFO  - jmeter.engine.RemoteJMeterEngineImpl: Bound to registry on port 1029 
 27 2016/06/20 15:05:55 INFO  - jmeter.samplers.SampleEvent: List of sample_variables: [] 
 28 2016/06/20 15:05:55 INFO  - jmeter.samplers.BatchSampleSender: Using batching for this run. Thresholds: num=100, time=60000 
 29 2016/06/20 15:05:55 INFO  - jmeter.samplers.DataStrippingSampleSender: Using DataStrippingSampleSender for this run 
 30 2016/06/20 15:05:55 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/html is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 
 31 2016/06/20 15:05:55 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for application/xhtml+xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 
 32 2016/06/20 15:05:55 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for application/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 
 33 2016/06/20 15:05:55 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 
 34 2016/06/20 15:05:55 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/vnd.wap.wml is org.apache.jmeter.protocol.http.parser.RegexpHTMLParser 
 35 2016/06/20 15:05:55 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/css is org.apache.jmeter.protocol.http.parser.CssParser 
 36 2016/06/20 15:05:56 INFO  - jmeter.engine.RemoteJMeterEngineImpl: Creating JMeter engine on host 10.9.215.47:1029 base '.' 
 37 2016/06/20 15:05:56 INFO  - jmeter.engine.RemoteJMeterEngineImpl: Remote client host: 10.9.215.49 
 38 2016/06/20 15:05:56 INFO  - jmeter.services.FileServer: Default base='D:\DevTool\apache-jmeter-3.0\bin' 
 39 2016/06/20 15:05:56 INFO  - jmeter.services.FileServer: Set new base='.' 
 40 2016/06/20 15:05:56 INFO  - jmeter.engine.StandardJMeterEngine: Applying properties {} 
 41 2016/06/20 15:05:56 INFO  - jmeter.engine.RemoteJMeterEngineImpl: Running test 
 42 2016/06/20 15:05:56 INFO  - jmeter.engine.StandardJMeterEngine: Running the test! 
 43 2016/06/20 15:05:56 INFO  - jmeter.samplers.SampleEvent: List of sample_variables: [] 
 44 2016/06/20 15:05:56 INFO  - jmeter.engine.util.CompoundVariable: Note: Function class names must contain the string: '.functions.' 
 45 2016/06/20 15:05:56 INFO  - jmeter.engine.util.CompoundVariable: Note: Function class names must not contain the string: '.gui.' 
 46 2016/06/20 15:05:56 INFO  - jmeter.engine.StandardJMeterEngine: Starting ThreadGroup: 1 : 文章详情 
 47 2016/06/20 15:05:56 INFO  - jmeter.engine.StandardJMeterEngine: Starting 2 threads for group 文章详情. 
 48 2016/06/20 15:05:56 INFO  - jmeter.engine.StandardJMeterEngine: Thread will continue on error 
 49 2016/06/20 15:05:56 INFO  - jmeter.threads.ThreadGroup: Starting thread group number 1 threads 2 ramp-up 2 perThread 1000.0 delayedStart=false 
 50 2016/06/20 15:05:56 INFO  - jmeter.threads.ThreadGroup: Started thread group number 1 
 51 2016/06/20 15:05:56 INFO  - jmeter.engine.StandardJMeterEngine: All thread groups have been started 
 52 2016/06/20 15:05:56 INFO  - jmeter.threads.JMeterThread: Thread started: 文章详情 1-1 
 53 2016/06/20 15:05:56 INFO  - jmeter.services.FileServer: Stored: ./distributed.csv 
 54 2016/06/20 15:05:56 ERROR - jmeter.threads.JMeterThread: Test failed! java.lang.IllegalArgumentException: File distributed.csv must exist and be readable
 55     at org.apache.jmeter.services.FileServer.createBufferedReader(FileServer.java:422)
 56     at org.apache.jmeter.services.FileServer.readLine(FileServer.java:347)
 57     at org.apache.jmeter.config.CSVDataSet.iterationStart(CSVDataSet.java:198)
 58     at org.apache.jmeter.control.GenericController.fireIterationStart(GenericController.java:405)
 59     at org.apache.jmeter.control.GenericController.fireIterEvents(GenericController.java:397)
 60     at org.apache.jmeter.control.GenericController.next(GenericController.java:158)
 61     at org.apache.jmeter.control.LoopController.next(LoopController.java:123)
 62     at org.apache.jmeter.threads.AbstractThreadGroup.next(AbstractThreadGroup.java:87)
 63     at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:239)
 64     at java.lang.Thread.run(Unknown Source)
 65 
 66 2016/06/20 15:05:56 INFO  - jmeter.threads.JMeterThread: Thread finished: 文章详情 1-1 
 67 2016/06/20 15:05:57 INFO  - jmeter.threads.JMeterThread: Thread started: 文章详情 1-2 
 68 2016/06/20 15:05:57 ERROR - jmeter.threads.JMeterThread: Test failed! java.lang.IllegalArgumentException: File distributed.csv must exist and be readable
 69     at org.apache.jmeter.services.FileServer.createBufferedReader(FileServer.java:422)
 70     at org.apache.jmeter.services.FileServer.readLine(FileServer.java:347)
 71     at org.apache.jmeter.config.CSVDataSet.iterationStart(CSVDataSet.java:198)
 72     at org.apache.jmeter.control.GenericController.fireIterationStart(GenericController.java:405)
 73     at org.apache.jmeter.control.GenericController.fireIterEvents(GenericController.java:397)
 74     at org.apache.jmeter.control.GenericController.next(GenericController.java:158)
 75     at org.apache.jmeter.control.LoopController.next(LoopController.java:123)
 76     at org.apache.jmeter.threads.AbstractThreadGroup.next(AbstractThreadGroup.java:87)
 77     at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:239)
 78     at java.lang.Thread.run(Unknown Source)
 79 
 80 2016/06/20 15:05:57 INFO  - jmeter.threads.JMeterThread: Thread finished: 文章详情 1-2 
 81 2016/06/20 15:05:57 INFO  - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test 
 82 2016/06/20 15:05:57 INFO  - jmeter.samplers.DataStrippingSampleSender: Test Ended on 10.9.215.47:1029 
 83 2016/06/20 15:05:57 INFO  - jmeter.samplers.BatchSampleSender: Test Ended on 10.9.215.47:1029 
 84 2016/06/20 15:05:57 INFO  - jmeter.engine.StandardJMeterEngine: Test has ended on host 10.9.215.47:1029 
 85 2016/06/20 15:07:51 INFO  - jmeter.samplers.BatchSampleSender: Using batching for this run. Thresholds: num=100, time=60000 
 86 2016/06/20 15:07:51 INFO  - jmeter.samplers.DataStrippingSampleSender: Using DataStrippingSampleSender for this run 
 87 2016/06/20 15:07:51 INFO  - jmeter.engine.RemoteJMeterEngineImpl: Creating JMeter engine on host 10.9.215.47:1029 base '.' 
 88 2016/06/20 15:07:51 INFO  - jmeter.engine.RemoteJMeterEngineImpl: Remote client host: 10.9.215.49 
 89 2016/06/20 15:07:51 INFO  - jmeter.services.FileServer: Set new base='.' 
 90 2016/06/20 15:07:51 INFO  - jmeter.engine.RemoteJMeterEngineImpl: Cleaning previously set properties {} 
 91 2016/06/20 15:07:51 INFO  - jmeter.engine.StandardJMeterEngine: Applying properties {} 
 92 2016/06/20 15:07:51 INFO  - jmeter.engine.RemoteJMeterEngineImpl: Running test 
 93 2016/06/20 15:07:51 INFO  - jmeter.engine.StandardJMeterEngine: Running the test! 
 94 2016/06/20 15:07:51 INFO  - jmeter.samplers.SampleEvent: List of sample_variables: [] 
 95 2016/06/20 15:07:51 INFO  - jmeter.engine.StandardJMeterEngine: Starting ThreadGroup: 1 : 文章详情 
 96 2016/06/20 15:07:51 INFO  - jmeter.engine.StandardJMeterEngine: Starting 2 threads for group 文章详情. 
 97 2016/06/20 15:07:51 INFO  - jmeter.engine.StandardJMeterEngine: Thread will continue on error 
 98 2016/06/20 15:07:51 INFO  - jmeter.threads.ThreadGroup: Starting thread group number 1 threads 2 ramp-up 2 perThread 1000.0 delayedStart=false 
 99 2016/06/20 15:07:51 INFO  - jmeter.threads.JMeterThread: Thread started: 文章详情 1-1 
100 2016/06/20 15:07:51 INFO  - jmeter.threads.ThreadGroup: Started thread group number 1 
101 2016/06/20 15:07:51 INFO  - jmeter.engine.StandardJMeterEngine: All thread groups have been started 
102 2016/06/20 15:07:51 INFO  - jmeter.services.FileServer: Stored: ./distributed.csv 
103 2016/06/20 15:07:52 INFO  - jmeter.threads.JMeterThread: Thread started: 文章详情 1-2 
104 2016/06/20 15:07:54 WARN  - jmeter.timers.SyncTimer: SyncTimer 集合点 timeouted waiting for users after:3000ms 
105 2016/06/20 15:07:54 INFO  - jmeter.protocol.http.sampler.HTTPHCAbstractImpl: Local host = TEST 
106 2016/06/20 15:07:54 INFO  - jmeter.protocol.http.sampler.HTTPHC4Impl: HTTP request retry count = 0 
107 2016/06/20 15:07:54 INFO  - jmeter.samplers.SampleResult: Note: Sample TimeStamps are START times 
108 2016/06/20 15:07:54 INFO  - jmeter.samplers.SampleResult: sampleresult.default.encoding is set to ISO-8859-1 
109 2016/06/20 15:07:54 INFO  - jmeter.samplers.SampleResult: sampleresult.useNanoTime=true 
110 2016/06/20 15:07:54 INFO  - jmeter.samplers.SampleResult: sampleresult.nanoThreadSleep=5000 
111 2016/06/20 15:07:55 INFO  - jmeter.threads.JMeterThread: Thread is done: 文章详情 1-1 
112 2016/06/20 15:07:55 INFO  - jmeter.threads.JMeterThread: Thread finished: 文章详情 1-1 
113 2016/06/20 15:07:55 INFO  - jmeter.threads.JMeterThread: Thread is done: 文章详情 1-2 
114 2016/06/20 15:07:55 INFO  - jmeter.threads.JMeterThread: Thread finished: 文章详情 1-2 
115 2016/06/20 15:07:55 INFO  - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test 
116 2016/06/20 15:07:55 INFO  - jmeter.services.FileServer: Close: ./distributed.csv 
117 2016/06/20 15:07:55 INFO  - jmeter.samplers.DataStrippingSampleSender: Test Ended on 10.9.215.47:1029 
118 2016/06/20 15:07:55 INFO  - jmeter.samplers.BatchSampleSender: Test Ended on 10.9.215.47:1029 
119 2016/06/20 15:07:55 INFO  - jmeter.engine.StandardJMeterEngine: Test has ended on host 10.9.215.47:1029 
复制代码
执行机(Slave)服务日志信息

至此,此文顺利完结,希望此文能够给初学 JMeter 的您一份参考。

最后,非常感谢亲的驻足,希望此文能对亲有所帮助。热烈欢迎亲一起探讨,共同进步。非常感谢! ^_^

我本渺小,但山峰,我一次次绝顶!


PS:若有错误,敬请告知,不胜感激!
Copyright @范丰平 版权所有,如需转载请标明本文原始链接出处,严禁商业用途! 我的个人博客链接地址:http://www.cnblogs.com/fengpingfan

你可能感兴趣的:(jmeter)