在 Azure 负载测试基于 URL 的测试中未发送 Cookie 标头

问题描述 投票:0回答:1

我正在尝试 Azure 负载测试并遇到这样的问题:如果我使用

Cookie
标头设置基于 URL 的测试(设置负载测试的简单的基于 GUI 的方法),则该标头实际上并不是发送。其他标头已正确发送。

在下面的示例中,位于 https://example.org/requires_cookie 的服务器接收带有

OtherHeader
标头的调用,但没有
Cookie
标头。

没有验证错误,测试配置保存并正确运行,并且在编辑测试时,

Cookie
标头仍然显示在允许编辑请求的面板中。单击面板底部的 Copy as cURL 按钮复制正确的 cURL 命令,其中包括
Cookie
标题:

curl --request GET 'https://example.org/requires_cookie' --header 'Cookie: foo=bar' --header 'OtherHeader: baz'

切换到 Add cURL 命令 请求格式并粘贴此正确的 cURL 命令可以正确保存并运行,但仍然不发送

Cookie
标头。

azure cookies jmeter azure-load-testing
1个回答
0
投票

这似乎是基于 URL 的测试特有的问题。以下是 Azure 负载测试生成的底层 JMX (Apache JMeter) 测试文件的一部分,其中显示了缺少的

Cookie
标头:

<HTTPSamplerProxy guiclass="HttpTestSampleGui" testname="RequiresCookie">
  <elementProp name="HTTPsampler.Arguments" elementType="Arguments">
    <collectionProp name="Arguments.arguments"/>
  </elementProp>
  <stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
  <stringProp name="HTTPSampler.protocol">https</stringProp>
  <stringProp name="HTTPSampler.path">/requires_cookie</stringProp>
  <stringProp name="HTTPSampler.domain">example.org</stringProp>
  <boolProp name="HTTPSampler.use_keepalive">true</boolProp>
  <boolProp name="HTTPSampler.follow_redirects">true</boolProp>
  <stringProp name="HTTPSampler.method">GET</stringProp>
  <elementProp name="HTTPSampler.header_manager" elementType="HeaderManager" guiclass="HeaderPanel" testname="HTTP HeaderManager">
    <collectionProp name="HeaderManager.headers">
      <elementProp name="OtherHeader" elementType="Header">
        <stringProp name="Header.name">OtherHeader</stringProp>
        <stringProp name="Header.value">baz</stringProp>
      </elementProp>
    </collectionProp>
  </elementProp>
</HTTPSamplerProxy>

解决方法是设置基于 URL 的测试,单击按钮将其转换为 JMX (JMeter) 测试,下载 JMX 测试计划,对其进行编辑以添加到

Cookie
集合中的
HeaderManager.headers
标头中,然后删除并在 Azure 门户中重新上传编辑后的文件。

但是,您将无法再使用简单的 GUI。您可以考虑直接创建 JMeter 测试。

© www.soinside.com 2019 - 2024. All rights reserved.