【问题标题】:JMeter - View currrent request before getting responseJMeter - 在获得响应之前查看当前请求
【发布时间】:2018-11-01 22:12:58
【问题描述】:

在 GUI 模式下运行 JMeter 时,有时请求卡住或需要很长时间(一分钟或更长时间)才能获得响应

有没有办法在收到响应之前查看请求?

很明显Listeners是在Sampler完成后因为Scoping规则而执行的,但是还有其他方法吗?

【问题讨论】:

    标签: jmeter


    【解决方案1】:
    1. 最简单和最明显的选择是将请求发送到其他地方,即localhostexample.com,无论在哪里。您将立即得到响应,因此可以使用View Results Tree listener 检查请求详细信息
    2. 稍微复杂一点的选项是使用JSR223 PreProcessorGroovy 将请求详细信息打印到jmeter.log 文件,这将查询sampler 实例,这是HTTPSamplerProxy 类的简写喜欢:

      log.info('URL: ' + (sampler.getUrl() as String) + sampler.getQueryString())
      log.info('Parameters: ')
      sampler.getArguments().each {arg -> 
          log.info(arg.getObjectValue() as String)
      } 
      if (sampler.getCookieManager() != null) {
          log.info('Cookies: ') 
          sampler.getCookieManager().getCookies().each { cookie ->
              log.info(cookie.getObjectValue() as String)
           }
      }
      
      if (sampler.getHeaderManager() != null) {
          log.info('Headers:')
          sampler.getHeaderManager().getHeaders().each {header -> 
              log.info(header.getObjectValue() as String)
          }
      }
      //etc
      

      演示:

    【讨论】:

      【解决方案2】:

      按照 Apache JMeter 大师的书,填写超时可以防止此类问题:

      填写 HTTP Request 的 Timeouts (milliseconds) 选项可以让你不用等待 无限期的 SUT 响应。

      这将提供以下好处:

      • 允许 JMeter 在测试结束时停止,而无需无限期等待 挂起的请求。默认情况下,HTTP 请求中的超时时间是无限的

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-03-03
        • 2021-09-24
        • 1970-01-01
        • 1970-01-01
        • 2022-01-19
        • 1970-01-01
        相关资源
        最近更新 更多