本文介绍了MSTest-运行"LoadTests";并将结果写入SQL Server数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果要配置VS负载测试"以将结果写入数据库服务器,请使用按照说明.

If you want to configure your VS "Load Tests" to write the results to a database server, you use the following instructions.

如果要在单独的计算机上通过Powershell运行负载测试"(),则使用遵循说明.

If you want to run your "Load Tests" through powershell on a separate machine(think TFS 2018 release step), you use the following instructions.

我想在多台机器上以自动化的方式完成这两项工作,但是关于这方面没有大量的文档,我可以像这样运行我的测试:

I would like to do both, on multiple machines, in a automated manner, but there's not a great deal of documentation on this, I can run my tests like this:

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

但是结果被踢到"TRX"文件中,而不是被放入数据库中(对此有一些讨论).像在本地运行时一样,如何将结果放入外部数据库中(按照上述说明)?

But the results are kicked out to a "TRX" file rather than being placed into a database(there is some discussion on this). How do I put the results into a external database like when I run it locally(per instructions above)?

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

Note: @AdrianHHH points out that the "TRX" file is only a summary and that most of the info is stored locally(MDF/LDF file) in the user folder of current user running the load tests.

嗯,我想知道这在哪里持续下去

Hmm I wonder where this is persisted:

(很好奇,也单击管理测试控制器"框中的?"图标,什么也没有...)

(Curious, also click on the "?" icon in the "Manage Test Controller" box, nothing...)

它不在保存的XML中:

It's not in the saved 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"文件中:

They're not persisted in my default "testsettings" file either:

<?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的方法.还有其他人了解它的工作原理吗?

So I need to find where ever this configuration information is being persisted, then maybe I can find a way to feed it to MSTest. Does anyone else understand how this works?

我的 TRX文件确实包含连接字符串" ,但我认为它不属于我的数据库,也不属于我的数据库是空的,通过powershell运行就完成了,但是我所看到的只是"TRX"文件.

My TRX file does contains a "connection string" but I don't think it's to my database, my database is empty, on running via powershell it completes, but all I see is the "TRX" file.

这是一个棘手的问题,我一直在尝试各种方法来确定管理测试配置"数据/凭据的存储位置.我这样做的方法之一是使用Microsoft的 Process Monitor .您实际上可以从以下位置看到它的最初填充位置:

This one is tricky, I keep trying various ways to determine where this "Manage Test Configuration" data/credentials is being stored. One of the ways I did this was to use Microsoft's Process Monitor. You can actually see where it initially is being populated from:

它来自 Application Hive ,当然,这引出了一个问题,"Application Hive"是从哪里填充的,那里的事情变得有些模糊,分配了对许多文件的不同调用.一个普遍的趋势是经常引用"Temp \ Local"文件夹.

It's from a Application Hive, of course that's begs the question where did the "Application Hive" get populated from, that's where things get a bit murky, there's allot of different calls to many files. A common trend is that the "Temp\Local" folder is often referenced.

我删除了我的用户帐户的整个"Temp"文件夹(在此过程中丢失了我的所有VS配置),并且在重新打开解决方案后,好像已经生效了.当我拉起"LoadTest"文件时,负载测试结果存储"行现在为空.实际上,整个管理测试控制器"窗口都已恢复为默认值(空).

I deleted the entire "Temp" folder for my user account(in the process losing all my VS configuration) and upon reopening my solution it appears as though this had an effect. When I pull up my "LoadTest" file, the "Load test results store" line is now empty. In fact the entire "Manage Test Controller" window has been restored back to default(empty).

我知道,此管理测试控制器"窗口的配置将保留在temp文件夹中.但是,我还没有找到它的位置和/或如何使用powershell脚本更改/自动填充该信息.

I know believe that the configuration for this "Manage Test Controller" window is persisted in the temp folder. However, I've yet to locate where it is and/or how to change/automatically populate that information with a powershell script.

推荐答案

最后弄清楚了这一点.基本上,我使用几种工具来检查更改连接字符串时正在修改的文件,结果显而易见:

Finally figured this out. Basically I used several tools to check what files were being modified when I changed the connection string, the results made it obvious:

一旦我发现了这一点,很明显VS维护着它自己的小注册表配置单元. 这篇文章,所以我打开了它按照本文所述的方式,找到了连接字符串:

Once I found this it was pretty obvious that VS was maintaining it's own little registry hive. It's clearly stated in this post, so I opened it in the way described in the article and found the connection string:

这表明:

所以基本上就是我所做的,我登录了每个构建服务器并对其进行了配置,以便它们将所有结果写入我的数据库中,而不是本地.

So that's basically what I did, I logged into each build server and configured them so that they write all there results to my database rather than locally.

显然,负载测试并非旨在简化此过程,我认为很多人都没有尝试做我做过的事情.所有文章仅告诉您使用他们的云服务.我敢肯定,仅涵盖网络测试.如果您将负载测试用于测试单元测试,您几乎没有运气(没有解决方法).我真的希望这会在将来得到官方的支持,同时运行/查看来自TFS的所有类型的负载测试都非常好.目前,尽管如此,我将不得不继续使用此工作.

Load tests are clearly not designed to make this process easy, I don't think many people have attempted to do what I've done. All the articles just tell you to use their cloud service. I'm pretty sure that only covers web tests. If your using load testing to test unit tests you pretty much out of luck(without this work around). I really hope this gets official support in the future, it would be really nice to both run/view all types of load tests from TFS. For now though I'm going to have to keep using this work around.

这篇关于MSTest-运行"LoadTests";并将结果写入SQL Server数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 07:26