【问题标题】:Visual Studio Team services - load testing - JMeter - path to supporting filesVisual Studio Team services - 负载测试 - JMeter - 支持文件的路径
【发布时间】:2016-05-23 16:59:55
【问题描述】:

我想使用 Visual Studio Team Services 在云中运行用 JMeter 编写的负载测试计划。在我的测试中,我必须上传文件。 我想我应该将此文件附加到“支持文件”字段,但我不知道该文件的路径是什么。有错误提示:

HttpError Non HTTP response code: java.io.FileNotFoundException Agent000 | Thread Group | Upload | Non HTTP response message: test.xml (The system cannot find the file specified)

我尝试了一些在日志中找到的路径,例如:E:\approot\JMeterLoadTest\,但还是有错误。

添加到“支持文件”的文件路径是什么?有没有人遇到过类似的问题?

【问题讨论】:

  • 您是否在使用像 BeanShell 这样的采样器来读取测试中的 xml 文件?
  • 没有。 test.xml是上传的示例文件,我不看这个文件,只是通过Http put方法发送。在 JMeter 中,我使用 Http 请求采样器,在“文件上传”选项卡上,我将文件路径写入本地驱动器中。当测试在云中执行时,我需要知道文件的路径。

标签: jmeter azure-devops load-testing


【解决方案1】:

您可以定义“用户定义的变量”并使用 BeanShell。

  <Arguments guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
    <collectionProp name="Arguments.arguments">
      <elementProp name="testURL" elementType="Argument">
        <stringProp name="Argument.name">testURL</stringProp>
        <stringProp name="Argument.value">www.datafilehost.com</stringProp>
        <stringProp name="Argument.metadata">=</stringProp>
      </elementProp>
      <elementProp name="testFile" elementType="Argument">
        <stringProp name="Argument.name">testFile</stringProp>
        <stringProp name="Argument.value">upload.txt</stringProp>
        <stringProp name="Argument.metadata">=</stringProp>
      </elementProp>
      <elementProp name="scriptPath" elementType="Argument">
        <stringProp name="Argument.name">scriptPath</stringProp>
        <stringProp name="Argument.value">${__BeanShell(import org.apache.jmeter.services.FileServer; FileServer.getFileServer().getBaseDir();)}${__BeanShell(File.separator,)}</stringProp>
        <stringProp name="Argument.metadata">=</stringProp>
      </elementProp>
    </collectionProp>
  </Arguments>

你可以从你的基本目录加载文件:

      <elementProp name="HTTPsampler.Files" elementType="HTTPFileArgs">
        <collectionProp name="HTTPFileArgs.files">
          <elementProp name="${scriptPath}${testFile}" elementType="HTTPFileArg">
            <stringProp name="File.path">${scriptPath}${testFile}</stringProp>
            <stringProp name="File.paramname">upfile</stringProp>
            <stringProp name="File.mimetype">text/plain</stringProp>
          </elementProp>
        </collectionProp>
      </elementProp>

完整样本: https://github.com/aliesbelik/jmx/blob/master/so/2015-04-15_file-upload-download.jmx

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-01
    • 2017-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多