MSTest - 运行 "LoadTests" 并将结果写入 SQL 服务器数据库

MSTest - Run "LoadTests" and Write Results to SQL Server Database

如果要配置 VS "Load Tests" 将结果写入数据库服务器,请使用 following instructions.

如果你想 运行 你的 "Load Tests" 在另一台机器上通过 powershell(), you use the following instructions.

我想在多台机器上以自动方式同时执行这两项操作,但是没有大量关于此的文档,我可以 运行 我的测试是这样的:

.\mstest /testcontainer:"C:\XXX\ABC.loadtest"

但结果被踢出到 "TRX" 文件而不是放入数据库 (there is some discussion on this)。我如何将结果放入外部数据库,就像我在本地 运行 时一样(按照上面的说明)?

注意:@AdrianHHH 指出 "TRX" 文件只是一个摘要,大部分信息都存储在本地(MDF/LDF 文件)的用户文件夹中当前用户运行正在进行负载测试。

更新 1

嗯,我想知道这是在哪里保存的:

(好奇,也点一下"Manage Test Controller"框里的“?”图标,没什么...)

不在保存的XML:

<RunConfigurations>
    <RunConfiguration Name="Run Settings1" Description="" ResultsStoreType="Database" TimingDetailsStorage="AllIndividualDetails" SaveTestLogsOnError="true" SaveTestLogsFrequency="0" MaxErrorDetails="200" MaxErrorsPerType="1000" MaxThresholdViolations="1000" MaxRequestUrlsReported="1000" UseTestIterations="false" RunDuration="10" WarmupTime="0" CoolDownTime="0" TestIterations="100" WebTestConnectionModel="ConnectionPerUser" WebTestConnectionPoolSize="50" SampleRate="5" ValidationLevel="High" SqlTracingConnectString="" SqlTracingConnectStringDisplayValue="" SqlTracingDirectory="" SqlTracingEnabled="false" SqlTracingFileCount="2" SqlTracingRolloverEnabled="true" SqlTracingMinimumDuration="500" RunUnitTestsInAppDomain="true" CoreCount="0" ResourcesRetentionTimeInMinutes="0" AgentDiagnosticsLevel="Warning">
      <CounterSetMappings>
        <CounterSetMapping ComputerName="[CONTROLLER MACHINE]">
          <CounterSetReferences>
            <CounterSetReference CounterSetName="LoadTest" />
            <CounterSetReference CounterSetName="Controller" />
          </CounterSetReferences>
        </CounterSetMapping>
        <CounterSetMapping ComputerName="[AGENT MACHINES]">
          <CounterSetReferences>
            <CounterSetReference CounterSetName="Agent" />
          </CounterSetReferences>
        </CounterSetMapping>
      </CounterSetMappings>
      <LoadGeneratorLocations>
        <GeoLocation Location="Default" Percentage="100" />
      </LoadGeneratorLocations>
    </RunConfiguration>
  </RunConfigurations>

它们也没有保存在我的默认 "testsettings" 文件中:

<?xml version="1.0" encoding="UTF-8"?>
<TestSettings name="Local" id="02cad612-043b-447d-993e-a9b9b0547c9d" 
     xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
  <Description>These are default test settings for a local test run.</Description>
  <Deployment enabled="false" />
  <Execution hostProcessPlatform="MSIL">
    <TestTypeSpecific />
    <AgentRule name="Execution Agents">
    </AgentRule>
  </Execution>
  <Properties>
    <Property name="TestSettingsUIType" value="UnitTest" />
  </Properties>
</TestSettings>

所以我需要找到保存此配置信息的位置,然后也许我可以找到一种方法将其提供给 MSTest。还有其他人了解这是如何工作的吗?

更新 2

我的 但我不认为它是我的数据库,我的数据库是空的,在 运行 上通过 powershell 它完成了,但我只看到 "TRX"文件。

更新 3

这个有点棘手,我一直在尝试各种方法来确定这个 "Manage Test Configuration" data/credentials 的存储位置。我这样做的方法之一是使用 Microsoft 的 Process Monitor。您实际上可以看到它最初是从哪里填充的:

它来自 Application Hive,当然这回避了 "Application Hive" 从哪里填充的问题,这就是事情变得有点模糊的地方,对许多文件有不同的调用。一个普遍的趋势是经常引用 "Temp\Local" 文件夹。

我为我的用户帐户删除了整个 "Temp" 文件夹(在此过程中丢失了我所有的 VS 配置),并且在重新打开我的解决方案时,它似乎产生了效果。当我打开 "LoadTest" 文件时,"Load test results store" 行现在是空的。事实上整个 "Manage Test Controller" window 已经恢复到默认值(空)。

我知道 "Manage Test Controller" window 的配置保存在临时文件夹中。但是,我还没有找到 and/or 如何 change/automatically 使用 powershell 脚本填充该信息的位置。

终于明白了。基本上我使用了几个工具来检查当我更改连接字符串时哪些文件被修改了,结果很明显:

privateregistry.bin

一旦我发现这一点,很明显 VS 正在维护它自己的小注册表配置单元。按照文中描述的方式在this post, so I opened it中写的很清楚,找到了连接字符串:

这表明:

"The SQL Connection String is NOT stored in the loadtest files. The setting seems to be PC specific so I had to change it on the build server - in one loadtest file (address.loadtest) as shown, then all the other loadtests adopt the same connection string."

这基本上就是我所做的,我登录到每个构建服务器并配置它们,以便它们将所有结果写入我的数据库而不是本地。

负载测试显然不是为了简化这个过程而设计的,我认为没有多少人尝试过我所做的事情。所有的文章都只是告诉你 use their cloud service. I'm pretty sure that only covers web tests. If your using load testing to test unit tests 你很倒霉(没有这个解决方法)。我真的希望这在未来能得到官方支持,这对 run/view 来自 TFS 的所有类型的负载测试都非常好。虽然现在我将不得不继续使用这个变通方法。