【问题标题】:Jmeter-How can I extract a value in response header and get count of thatJmeter-如何在响应标头中提取值并获取该值
【发布时间】:2019-01-24 18:04:11
【问题描述】:

如何在 jmeter 采样器结果的响应头中提取一个值并获取计数。

我正在运行负载测试,例如 100 个线程。我的请求将通过负载均衡器到达 4 台服务器。

我需要获取到 ABCHeader 的请求计数:Staging 01,Staging 02,Staging 03,Staging 04。(我从每个请求的响应头中获取)

检查请求是否被平均分配到每个服务器。有什么可能的方法?

我尝试使用正则表达式提取器并提取了值。但我不确定如何获得计数

请检查下面的响应标头:检查 ABCHeader: Staging 04

>     HTTP/1.1 200 OK
>     Date: Thu, 24 Jan 2019 17:13:29 GMT
>     Server: Apache
>     Cache-Control: no-cache, max-age=0
>     Vary: Accept-Encoding
>     Expires: Thu, 24 Jan 2019 17:13:29 GMT
>     X-Content-Type-Options: nosniff
>     X-XSS-Protection: 1; mode=block
>     Strict-Transport-Security: max-age=31536000
>     Set-Cookie: XSRF-TOKEN=fd; expires=Thu, 24-Jan-2019 19:13:29 GMT; Max-Age=7200; path=/;HttpOnly;Secure
>     Set-Cookie: laravelsession=df; expires=Thu, 24-Jan-2019 19:13:29 GMT; Max-Age=7200; path=/; HttpOnly;HttpOnly;Secure
>     ABCHeader: Staging 04
>     Keep-Alive: timeout=5, max=100
>     Connection: Keep-Alive
>     Content-Type: text/html; charset=UTF-8
>     Set-Cookie: abcLB-Staging=df; path=/; Httponly; Secure
>     Content-Length: 2193
>     Content-Encoding: gzip

【问题讨论】:

    标签: jmeter


    【解决方案1】:

    最正确的方法是使用sample_variables property

    1. 将下一行添加到 user.properties 文件:

      sample_variables=ABCHeader
      

      用您在正则表达式提取器中定义的实际 JMeter 变量引用替换 ABCHeader

    2. 下次你run your JMeter test in command-line non-GUI mode点赞:

      jmeter -n -t test.jmx -l result.csv
      

      result.csv 文件将包含一个名为 ABCHeader 的额外列,其中包含相关的 JMeter 变量值,因此您将能够区分哪个请求将发送到哪个后端服务器

    3. 如果您正在测试负载均衡器后面的应用程序,请确保将DNS Cache Manager 添加到您的测试计划中,否则您可能会遇到所有线程只访问一台后端服务器的情况。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-08-10
      • 2016-07-25
      • 1970-01-01
      • 2021-01-27
      • 2019-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多