说明: 1、本地链接已经手动配置固定IP地址,并在高级中配置2个空闲IP地址,在运行中输入cmd命令后,用ipconfig命令确实显示3个IP地址,如下图: 2、用Badboy录制脚本并导入Jmeter
3、设置一个用作IP参数化的的txt文档,内容如下: 4、在Jmeter中添加CSV Data Set Config,如下图:
5、在脚本的每一个请求中,修改http请求的方式为HttpClient4 6、同样在HTTP请求的Advanced标签中,Source address下选择IPHostnameqie 写上变量名为${ipadress} 7、添加查看结果树并运行查看结果时取样器报错 取样器结果显示如下: Thread Name: Thread Group 1-1
Sample Start: 2017-06-01 13:52:21 CST
Load time: 1
Connect Time: 1
Latency: 0
Size in bytes: 2355
Headers size in bytes: 0
Body size in bytes: 2355
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): text
Response code: Non HTTP response code: java.net.ConnectException
Response message: Non HTTP response message: connect: Address is invalid onlocal machine, or port is not valid on remote machine Response headers:
HTTPSampleResult fields:
ContentType:
DataEncoding: null
响应数据报错如下: java.net.ConnectException: connect:Address is invalid on local machine, or port is not valid on remote machine
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
atjava.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
atjava.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
atjava.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
atjava.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
atorg.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:120)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:179)
atorg.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:328)
at org.apache.jmeter.protocol.http.sampler.MeasuringConnectionManager$MeasuredConnection.open(MeasuringConnectionManager.java:114)
atorg.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:612)
atorg.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:447)
atorg.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:884)
atorg.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
atorg.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:619)
atorg.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:379)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
atorg.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1146)
atorg.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1135)
atorg.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:465)
atorg.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:410)
atorg.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:241)
at java.lang.Thread.run(Thread.java:745)
在学课程: JMeter性能测试
|