【问题标题】:JMeter: How to send GET request with body data?JMeter:如何发送带有正文数据的 GET 请求?
【发布时间】:2023-04-07 15:06:01
【问题描述】:

我想对我的 Elasticsearch 部署执行负载测试。 _search Elasticsearch 的 API 需要带有搜索请求的正文数据,如记录的 here。

但是,当我发送 GET 请求时,我看到正文数据是空的。我可以从“查看结果树”以及服务器上的日志中验证它。是不允许在 GET 任务中发送身体数据还是我做错了什么?我正在使用 JMeter 3.0 r1743807。 Screenshot 也附上。

<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="One-Dimension aggregation" enabled="true">
  <boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
  <elementProp name="HTTPsampler.Arguments" elementType="Arguments">
    <collectionProp name="Arguments.arguments">
      <elementProp name="" elementType="HTTPArgument">
        <boolProp name="HTTPArgument.always_encode">false</boolProp>
        <stringProp name="Argument.value">{&#xd;
    &quot;query&quot;: {&#xd;
      &quot;filtered&quot;: {&#xd;
        &quot;query&quot;: {&#xd;
          &quot;query_string&quot;: {&#xd;
            &quot;query&quot;: &quot;+_exists_:category_list&quot;,&#xd;
            &quot;analyze_wildcard&quot;: true&#xd;
          }&#xd;
        }&#xd;
      }&#xd;
    },&#xd;
    &quot;size&quot;: 0,&#xd;
    &quot;aggs&quot;: {&#xd;
      &quot;2&quot;: {&#xd;
        &quot;terms&quot;: {&#xd;
          &quot;field&quot;: &quot;category_list.raw&quot;,&#xd;
          &quot;size&quot;: 20,&#xd;
          &quot;order&quot;: {&#xd;
            &quot;_count&quot;: &quot;desc&quot;&#xd;
          }&#xd;
        }&#xd;
      }&#xd;
    }&#xd;
  }</stringProp>
        <stringProp name="Argument.metadata">=</stringProp>
      </elementProp>
    </collectionProp>
  </elementProp>
  <stringProp name="HTTPSampler.domain"></stringProp>
  <stringProp name="HTTPSampler.port"></stringProp>
  <stringProp name="HTTPSampler.connect_timeout"></stringProp>
  <stringProp name="HTTPSampler.response_timeout"></stringProp>
  <stringProp name="HTTPSampler.protocol"></stringProp>
  <stringProp name="HTTPSampler.contentEncoding"></stringProp>
  <stringProp name="HTTPSampler.path">/-*kibana*/_search/</stringProp>
  <stringProp name="HTTPSampler.method">GET</stringProp>
  <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
  <boolProp name="HTTPSampler.auto_redirects">false</boolProp>
  <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
  <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
  <boolProp name="HTTPSampler.monitor">false</boolProp>
  <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
</HTTPSamplerProxy>

【问题讨论】:

    标签: jmeter


    【解决方案1】:

    我记得answering similar question here

    简而言之:您无法使用 JMeter 的 HTTP Request 采样器来实现,但可以通过脚本来实现。我建议在实施上述答案的解决方案之前先熟悉How to Use BeanShell: JMeter's Favorite Built-in Component 文章。

    【讨论】:

    【解决方案2】:

    它已在最新的jMeter ver. 3.1 中修复。见bugzilla #60358

    【讨论】:

      【解决方案3】:

      当谈到 JMeter+ElasticSearch 时,/index-name/_search 上的 POST 和 GET 请求是等效的。

      至少对我来说。

      下面是 Insomnia 的截图:

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-10-18
        • 1970-01-01
        • 1970-01-01
        • 2020-08-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多