zoukankan      html  css  js  c++  java
  • 2、Jmeter测试

    一、测试流程

    1、添加本次测试计划 (右键-->添加-->Threads(Users)-->线程组)

     2、设置线程数 (所谓线程数就是并发用户数)

    3、在线程组内添加请求(右键-->添加-->取样器-->HTTP请求)

    4、添加协议及相关配置信息

    5、添加监听器-查看结果树

    6、启动测试

    二、模拟大量请求

    (设置线程数-(线程代表异步,同段时间内,同时运行的方式进行请求访问))

    报错的几种方式:

    //1、连接被关闭

    org.apache.http.ConnectionClosedException: Connection is closed
        at org.apache.http.impl.BHttpConnectionBase.ensureOpen(BHttpConnectionBase.java:130)
        at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseEntity(DefaultBHttpClientConnection.java:175)
        at org.apache.http.impl.conn.CPoolProxy.receiveResponseEntity(CPoolProxy.java:162)
        at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:279)
        at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
        at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
        at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
        at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:843)
        at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:574)
        at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:67)
        at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1231)
        at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1220)
        at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622)
        at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546)
        at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486)
        at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253)
        at java.lang.Thread.run(Unknown Source)

    //2、连接已停闭

    java.io.InterruptedIOException: Connection has been shut down
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:342)
        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
        at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
        at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
        at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:843)
        at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:574)
        at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:67)
        at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1231)
        at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1220)
        at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622)
        at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546)
        at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486)
        at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253)
        at java.lang.Thread.run(Unknown Source)
    Caused by: org.apache.http.impl.conn.ConnectionShutdownException
        at org.apache.http.impl.conn.CPoolProxy.getValidConnection(CPoolProxy.java:77)
        at org.apache.http.impl.conn.CPoolProxy.receiveResponseEntity(CPoolProxy.java:162)
        at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:279)
        at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
        ... 15 more

    //3、Socket 被停止连接

    java.net.SocketException: Socket operation on nonsocket: connect
        at java.net.DualStackPlainSocketImpl.connect0(Native Method)
        at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
        at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
        at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
        at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
        at java.net.PlainSocketImpl.connect(Unknown Source)
        at java.net.SocksSocketImpl.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
        at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
        at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl$JMeterDefaultHttpClientConnectionOperator.connect(HTTPHC4Impl.java:336)
        at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:374)
        at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
        at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
        at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
        at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
        at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:843)
        at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:574)
        at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:67)
        at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1231)
        at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1220)
        at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622)
        at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546)
        at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486)
        at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253)
        at java.lang.Thread.run(Unknown Source)

    //4、Socket 被关闭

    java.net.SocketException: Socket closed
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.socketRead(Unknown Source)
        at java.net.SocketInputStream.read(Unknown Source)
        at java.net.SocketInputStream.read(Unknown Source)
        at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137)
        at org.apache.http.impl.io.SessionInputBufferImpl.read(SessionInputBufferImpl.java:197)
        at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:188)
        at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:135)
        at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:148)
        at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.readResponse(HTTPSamplerBase.java:1850)
        at org.apache.jmeter.protocol.http.sampler.HTTPAbstractImpl.readResponse(HTTPAbstractImpl.java:477)
        at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:600)
        at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:67)
        at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1231)
        at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1220)
        at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622)
        at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546)
        at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486)
        at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253)
        at java.lang.Thread.run(Unknown Source)
  • 相关阅读:
    随机生成几位数
    文件下载
    动态SQL
    springmvc的xml版本和注解版本
    Hibernate与MyBatis
    关于过滤器!!
    jsp-EL表达式
    SpringMVC 自定义类型转换器
    Spring MVC 知识点记忆
    cmd的操作命令导出导入.dmp文件
  • 原文地址:https://www.cnblogs.com/fger/p/11353356.html
Copyright © 2011-2022 走看看