JMeter學習-027-JMeter參數文件(腳本分發)路徑問題:jmeter.threads.JMeterThread: Test failed! java.lang.IllegalArgumen

前些天,在進行分佈式參數化測試的時候,出現瞭如題所示的錯誤報錯信息。此文,針對此作一個簡略的重現及分析說明。css

 

JMX腳本線程組參數配置以下所示:html

參數文件路徑配置以下所示:java

執行JMX腳本後,服務器對應日誌錯誤信息(部分)輸出以下所示:apache

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)的路徑是什麼呢?查看腳本分發路徑有以下兩種方式:app

1、經過執行機服務日誌,user.dir 目錄即爲分發路徑(推薦) 分佈式

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 

2、分發jmx腳本目錄即爲執行機服務啓動目錄,例如執行機服務啓動命令行以下所示: ide

那麼,此執行機對應的jmx腳本分發目錄爲:D:\DevTool\apache-jmeter-3.0\binoop

 

執行JMX測試腳本測試

    • 第一次,對應分發路徑無對應參數文件
    • 第二次,對應分發路徑有對應參數文件

執行機(Slave)端控制檯輸出以下所示:

JMX腳本兩次執行結果以下所示:

由執行結果可見,將 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 的您一份參考。

最後,很是感謝親的駐足,但願此文能對親有所幫助。熱烈歡迎親一塊兒探討,共同進步。很是感謝! ^_^

相關文章
相關標籤/搜索