Visual Studio 团队服务 - 负载测试 - JMeter - 支持文件的路径

Visual Studio Team services - load testing - JMeter - path to supporting files

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

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\,但还是有错误。

添加到 'Supporting files' 的文件的路径是什么?有人遇到过类似的问题吗?

您可以定义 "User Defined Variables" 并使用 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