JMeter:如何使用正文数据发送GET请求?

时间:2016-11-09 18:51:05

标签: jmeter

我想在我的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>

3 个答案:

答案 0 :(得分:1)

我记得answering similar question here

很快:您不能使用JMeter的HTTP Request采样器,但可以通过脚本编写。我建议在实施上述答案的解决方案之前熟悉How to Use BeanShell: JMeter's Favorite Built-in Component文章。

答案 1 :(得分:1)

它修复了最新的jMeter ver. 3.1。见bugzilla #60358

答案 2 :(得分:0)

关于JMeter + ElasticSearch,对/index-name/_search POST GET 请求是等效的。

至少对我来说。

以下是失眠的屏幕截图:

enter image description here

相关问题