Using BizUnit and LoadGen to Automate Performance and Stability Testing

This topic provides information about how to use the Microsoft BizTalk LoadGen 2007 tool with BizUnit to automate performance and stability testing of a BizTalk Server solution.

BizTalk Server performance testing, step-by-step

Before investigating how to automate BizTalk Server performance testing, it is useful to know what steps are typically performed in a performance test. The following steps are representative of a “typical” BizTalk Server performance testing process:

  1. Create a test results directory to store results and data collected, for example, event logs, trace logs, Performance Monitor data.

  2. Clear the event logs on all servers within the test environment.

  3. Stop all BizTalk host instances.

  4. Stop any IIS instances that are running isolated BizTalk hosts such as the SOAP and HTTP receive adapter handlers.

  5. Restart all instances of SQL Server used by the computers running BizTalk Server.

  6. Clean up the MessageBox database to ensure that there is no leftover data from previous tests runs. This is important because any leftover data could skew test results.

  7. Start the BizTalk host instances.

  8. Start the relevant Performance Monitor counters on all servers in the test environment.

  9. Send “priming” messages through the system to initialize the system caches.

  10. After the priming messages have been processed, track the test start time in a SQL Server test results database.

  11. Start the performance test by starting all of the LoadGen test agents.

  12. Wait for the test to complete – often this can be done systematically by measuring the value of a Performance Monitor counter such as host queue length.

  13. Track test end time in a SQL test results database.

  14. Stop the relevant Performance Monitor counters on all servers in the test environment.

  15. Save the test data to the test results directory that was created earlier.

  16. Perform any necessary cleanup for the next test run.

    Each and every one of the steps just listed can be automated using BizUnit. By utilizing the existing test step assets that BizUnit provides, you can quickly and easily generate an automated performance test for a BizTalk Server solution. One of the primary benefits of automating performance testing by using BizUnit is the flexibility to run tests overnight – meaning that the results are ready for analysis in the morning. This greatly reduces the burden of performance testing on a project team.

The Microsoft BizTalk LoadGen 2007 tool

The BizTalk LoadGen 2007 tool (LoadGen) is a load testing tool that was developed by the Stress and Performance Testing team in the BizTalk Server 2006 product group. LoadGen was designed to quickly, easily, and reliably define load tests that simulate production level message volumes. LoadGen is multi-threaded, configuration-driven, and supports multiple transports. The BizTalk product group uses LoadGen on a daily basis; therefore you can have a high degree of confidence that the tool is durable, fit for the purpose, and able to simulate a wide variety of BizTalk scenarios.

LoadGen employs a modular design that consists of three layers: presentation, framework and component. The presentation layer consists of a command-line driver, which is responsible for driving the framework. The framework layer reads a configuration file and then executes the components specified therein. The component layer consists of three types of components: load generators, message creators and throttle controllers. Each of these components is extensible, so you can create your own and plug them into LoadGen to address the needs of your scenario. Because LoadGen was developed by the BizTalk Server product group, you should find that the out-of-the-box components will fulfill most of your load testing requirements. Each of these components is described in greater detail here.

  • Load generators are responsible for transmitting messages via a particular transport. Load generators are provided for the following transports:

    • File

    • HTTP

    • MQSeries

    • MSMQLarge

    • MSMQ

    • SOAP

    • Web Services Enhancements (WSE)

    • Windows SharePoint Services (WSS)

    • Windows Communication Foundation (WCF)

  • Message creators are an optional component that can be used when you need to generate messages that contain unique data. Message creators use one of two modes of creation; synchronous and asynchronous. If the synchronous message creation mode is specified, LoadGen uses only a single thread to create messages to ensure that each message contains a unique payload. While the synchronous mode guarantees unique data within each message, this mode also limits scalability. LoadGen also provides asynchronous message creators that use multiple execution threads; this enables LoadGen to meet the target message rate (because it can simply create more threads). In asynchronous mode, the message creator may be configured to randomly modify data for each individual message. However, because it uses multiple threads, it does not guarantee that all message generated during the test will contain a unique payload.

  • Throttle controllers ensure that messages are transmitted at a steady rate by governing the load generators while the test is running. LoadGen also exposes custom throttling, which enables you to control the flow of messages based on criteria including:

    • Number of files in a folder

    • Number of rows in a database table

    • Depth of an MSMQ or MQSeries message queue

    The Microsoft BizTalk LoadGen 2007 tool is available for download.

Sample LoadGen configuration file

All LoadGen configuration information is stored in an xml file. The LoadGen configuration file contains a <CommonSection> element that configures the default settings for all LoadGen tasks in the LoadGen scenario. The LoadGen configuration file can also contain one or more <Section> elements that provide configuration settings for a specific LoadGen task. Entries in a <Section> element supersede any default values specified in the <CommonSection> element.

The sample LoadGen configuration file that follows is a slightly modified version of the FileToFileLG.xml sample configuration file that is included in the \ConfigFiles\ConsoleConfigFiles subdirectory of the LoadGen installation directory. This test sends 25 messages <LotSizePerInterval> every 200 milliseconds <SleepInterval>, 5 threads per load generator <NumThreadsperSection>and will stop the load test after 5000 messages <NumFiles> have been sent.

The file throttle controller is specified in the <ThrottleController> section. The value for <ThresholdRange> is set to 1000-2000, which means that if the file location C:\Scenarios\FileToFile\Receive (Parameters) has less than 1000 or more than 2000 files, the throttle controller will throttle the file generator and increase/decrease load as appropriate. The number of files in the file location will be checked every 1000 milliseconds <SleepInterval>. The <FileSection> element defines the properties for the messages to be sent by the load generators. The FileToFileLG.xml file <SrcFilePath> will be copied by LoadGen to the filedrop C:\Scenarios\FileToFile\Receive <DstFilePath>. The file transport is used here because this is the default transport specified in the <Transport Name> element within the <CommonSection> element.

Caution

This example or guidance references sensitive information, such as a connection string or a username and password. Never hardcode these values in your code, and make sure that you protect confidential data by using the most secure authentication available. For more information, see the following documentation:

<LoadGenFramework>
   <CommonSection>
      <LoadGenVersion>2</LoadGenVersion>
      <OptimizeLimitFileSize>204800</OptimizeLimitFileSize>
      <NumThreadsPerSection>5</NumThreadsPerSection>
      <SleepInterval>200</SleepInterval>
      <LotSizePerInterval>25</LotSizePerInterval>
      <RetryInterval>10000</RetryInterval>
      <StopMode Mode="Files">
         <NumFiles>5000</NumFiles>
      </StopMode>
      <Transport Name="FILE">
         <Assembly>FileTransport.dll/FileTransport.FileTransport</Assembly>
      </Transport>
      <ThrottleController Mode="Custom">
         <Monitor Name="File">
            <Assembly>FileMonitor.dll/DropLocationFileMonitor.DropLocationFileMonitor</Assembly>
            <ThresholdRange>1000-2000</ThresholdRange>
            <SleepInterval>1000</SleepInterval>
            <Parameters>C:\Scenarios\FileToFile\Receive</Parameters>
         </Monitor>
         <ThrottleCondition>File</ThrottleCondition>
      </ThrottleController>
   </CommonSection>
   <Section Name="FileSection">
      <SrcFilePath>C:\LoadGen\ConfigFiles\ConsoleConfigFiles\FileToFileLG.xml</SrcFilePath>
      <DstLocation>
         <Parameters>
            <DstFilePath>C:\Scenarios\FileToFile\Receive</DstFilePath>
         </Parameters>
      </DstLocation>
   </Section>
</LoadGenFramework>

Using BizUnit to drive LoadGen

BizUnit provides the LoadGenExecuteStep to facilitate automated performance and stability testing. The TestExecution stage of a sample BizUnit configuration file that uses LoadGenExecuteStep is shown in the following code example. Note that this step accepts a single configuration parameter, which is the location of the LoadGen configuration file.

<TestCase testName="Test_LoadGen">
   <TestSetup>
   </TestSetup>
   <TestExecution>
      <TestStep assemblyPath="" typeName="BizUnit.LoadGenExecuteStep, BizUnit.LoadGenSteps">
         <LoadGenTestConfig>..\..\..\PerfGuideFiletoFile.xml</LoadGenTestConfig>
      </TestStep>
   </TestExecution>
   <!-- Test cleanup: test cases should always leave the system in the state they found it -->
   <TestCleanup>
   </TestCleanup>
</TestCase>

The remainder of this topic describes the configuration file for a BizUnit test case that automates performance testing with LoadGen.

Note

This configuration file can be used as a template to quickly integrate BizUnit and LoadGen as part of your performance testing. Before running this test case, you will need to customize the configuration file for your environment. Sections of the configuration file that must be customized are indicated accordingly.

To begin with, specify a value for the testName parameter that is appropriate for the BizTalk solution.

<TestCase testName="Performance-Guide-Sample-Loadgen-Test">

Then add context variables to the TestSetup stage. These context variables will be referenced throughout the duration of the test case. To use this configuration file, modify the values specified for TestCaseResultsDir (C:\Dev Work\Perf Guide Demos\PerfResults\) and Machine (BIZTALKADMIN01) to match your environment.

<TestSetup>
   <!-- Context property: name of test run -->
   <TestStep assemblyPath="" typeName="BizUnit.ContextManipulatorStep">
      <ContextItem contextKey="TestRunName">
         <ItemTest takeFromCtx="BizUnitTestCaseName"></ItemTest>
         <ItemTest>_%DateTime%</ItemTest>
      </ContextItem>
   </TestStep>
   <!-- Context property: name of test directory to store results -->
   <TestStep assemblyPath="" typeName="BizUnit.ContextManipulatorStep">
      <ContextItem contextKey="TestCaseResultsDir">
         <ItemTest>C:\Dev Work\Perf Guide Demos\PerfResults\</ItemTest>
         <ItemTest takeFromCtx="TestRunName"></ItemTest>
      </ContextItem>
   </TestStep>
   <!-- Context property: perfmon log file -->
   <TestStep assemblyPath="" typeName="BizUnit.ContextManipulatorStep">
      <ContextItem contextKey="PerfMonFilePath">
         <ItemTest takeFromCtx="TestCaseResultsDir"></ItemTest>
         <ItemTest>\PerfCounters.blg</ItemTest>
      </ContextItem>
   </TestStep>
   <!-- Context property: destintation for app event log on test computer -->
   <TestStep assemblyPath="" typeName="BizUnit.ContextManipulatorStep">
      <ContextItem contextKey="DestPath- BIZTALKADMIN01-AppEventLog">
         <ItemTest takeFromCtx="TestCaseResultsDir"></ItemTest>
         <ItemTest> BIZTALKADMIN01_ApplicationLog.evt</ItemTest>
      </ContextItem>
   </TestStep>
   <!-- Clear the application event log on test computer -->
   <TestStep assemblyPath="" typeName="BizUnit.EventLogClearStep">
      <Machine>BIZTALKADMIN01</Machine>
      <EventLog>Application</EventLog>
   </TestStep>
   <!-- Create the directory to save all the test results -->
   <TestStep assemblyPath="" typeName="BizUnit.CreateDirectory">
      <DirectoryName takeFromCtx="TestCaseResultsDir" ></DirectoryName>
   </TestStep>
</TestSetup>

After completing the TestSetup stage, we enter the TestExecution stage. The first step is to stop the BizTalk host instances. A separate BizUnit.HostConductorStep section must be added for each distinct host instance. If you are using this configuration file in your environment, you will also need to enter the appropriate values for HostInstanceName, Server, Logon, and Password.

<TestExecution>
   <!-- Step 1: Stop BizTalk Hosts -->
   <TestStep assemblyPath="" typeName="BizUnit.HostConductorStep, BizUnit.BizTalkSteps">
      <Action>stop</Action>
      <HostInstanceName>BizTalkServerApplication</HostInstanceName>
      <Server>BizTalkAdmin01</Server>
      <Logon>ServerName\Administrator</Logon>
      <PassWord>Pass@word1</PassWord>
      <GrantLogOnAsService>true</GrantLogOnAsService>
   </TestStep>

After stopping all of the host instances, we clean up the BizTalk MessageBox database using the bts_CleanupMsgBox stored procedure. To use this step you must modify the value for ConnectionString to match your environment.

<!-- Step 2: Clean Up MessageBox -->
<TestStep assemblyPath="" typeName="BizUnit.DBExecuteNonQueryStep">
   <DelayBeforeExecution>1</DelayBeforeExecution>
   <ConnectionString>Persist Security Info=False;Integrated Security=SSPI;database=BizTalkMsgBoxDb;server=BIZTALKADMIN01;Connect Timeout=30</ConnectionString>
   <SQLQuery>
      <RawSQLQuery>[dbo].[bts_CleanupMsgbox]</RawSQLQuery>
   </SQLQuery>
</TestStep>

Step 3 of the TestExecution stage starts Performance Monitor (PerfMon) counters that are specified in a template file. A sample template file is listed underneath the sample BizUnit.PerfmonCountersStep below. To use the template file, you must modify the value specified for CountersListFilePath to match your environment. Modify the sample performance monitor counter template file to include any PerfMon counters that you would like to monitor or remove any that are not relevant to your scenario.

<!-- Step 3: Start Perfmon counters -->
<TestStep assemblyPath="" typeName="BizUnit.PerfmonCountersStep">
   <PerfmonAction>Start</PerfmonAction>
   <CounterSetName>PerfGuidePerfmonCounters</CounterSetName>
   <CountersListFilePath>C:\Dev Work\Perf Guide Demos\Test_06_PerfCounters.txt</CountersListFilePath>
   <SampleInterval>5</SampleInterval>
   <PerfmonLogFilePath takeFromCtx="PerfMonFilePath"></PerfmonLogFilePath>
</TestStep>

Sample Performance Monitor counter template file (Test_06_PerfCounters.txt referenced by the BizUnit.PerfmonCountersStep):

\Processor(*)\*
\Process(*)\*
\Memory\*
\PhysicalDisk(*)\*
\System\Context Switches/sec
\System\Processor Queue Length
\BizTalk:FILE Receive Adapter(*)\*
\BizTalk:File Send Adapter(*)\*
\BizTalk:FTP Receive Adapter(*)\*
\BizTalk:FTP Send Adapter(*)\*
\BizTalk:HTTP Receive Adapter(*)\*
\BizTalk:HTTP Send Adapter(*)\*
\BizTalk:Message Agent(*)\*
\BizTalk:Messaging(*)\*
\BizTalk:Message Box:General Counters(*)\*
\BizTalk:Message Box:Host Counters(*)\*
\BizTalk:Messaging Latency(*)\*
\BizTalk:SOAP Receive Adapter(*)\*
\BizTalk:SOAP Send Adapter(*)\*
\BizTalk:TDDS(*)\*
\XLANG/s Orchestrations(*)\*

Now we start the BizTalk Server host instances. A separate BizUnit.HostConductorStep section must be added for each distinct host instance (distinct includes multiple instances of a host across servers). If you are using this configuration file in your environment, you will also need to enter the appropriate values for HostInstanceName, Server, Logon, and Password.

<!-- Step 4: Start BizTalk Hosts -->
<TestStep assemblyPath="" typeName="BizUnit.BizTalkSteps.HostConductorStep, BizUnit.BizTalkSteps, Version=3.0.0.0, Culture=neutral, PublicKeyToken=7eb7d82981ae5162">
   <Action>start</Action>
   <HostInstanceName>BizTalkServerApplication</HostInstanceName>
   <Server>BizTalkAdmin01</Server>
   <Logon>ServerName\Administrator</Logon>
   <PassWord>Pass@word1</PassWord>
   <GrantLogOnAsService>true</GrantLogOnAsService>
</TestStep>

Step 5 “primes” the system by sending a couple of messages to BizTalk Server using BizUnit.LoadGenExecuteStep; change the value of the LoadGenTestConfig parameter to match your environment.

<!-- Step 5: Send Priming messages -->
<TestStep assemblyPath="" typeName="BizUnit.LoadGenExecuteStep, BizUnit.LoadGenSteps">
   <LoadGenTestConfig>C:\Program Files\LoadGen\ConfigFiles\ConsoleConfigFiles\PerfGuideFiletoFile.xml</LoadGenTestConfig>
</TestStep>

Step 6 writes the LoadGen configuration file to memory so that it can then be written to the test results database when the test is complete.


      <!-- Step 6: Read loadgen file into context variable -->
<TestStep assemblyPath="" typeName="BizUnit.FileReadAndLoadToContext">
   <FilePath>C:\Program Files\LoadGen\ConfigFiles\ConsoleConfigFiles\PerfGuideFiletoFile.xml</FilePath>
   <ContextPropertyName>LoadGenFileContent</ContextPropertyName>
</TestStep>

Now we write the test start time to a test results database. Modify the ConnectionString and RawSQLQuery parameters to match your environment.

<!-- Step 7: Update test results DB with test start time -->
<TestStep assemblyPath="" typeName="BizUnit.DBExecuteNonQueryStep">
   <DelayBeforeExecution>1</DelayBeforeExecution>
   <ConnectionString>Persist Security Info=False;Integrated Security=SSPI;database=TestResults;server=BizTalkAdmin01;Connect Timeout=30</ConnectionString>
   <SQLQuery>
      <RawSQLQuery>INSERT INTO tblPerformanceResults (Test_ID, StartTime,LoadGenFile) VALUES ('{0}',GetDate(),'{1}' )</RawSQLQuery>
      <SQLQueryParams>
         <SQLQueryParam takeFromCtx="TestRunName"></SQLQueryParam>
         <SQLQueryParam takeFromCtx="LoadGenFileContent"></SQLQueryParam>
      </SQLQueryParams>
   </SQLQuery>
</TestStep>

Step 8 is where the actual performance test is initiated using BizUnit.LoadGenExecuteStep. This step specifies the same LoadGen configuration file that was used in step 5, but you can specify any valid LoadGen configuration file here. BizUnit.DelayStep is used in step 9 to impose a 5-second delay to allow time for messages to start flowing through the system. Host queue length is calculated using BizUnit.PerMonCounterMonitorStep. When this parameter reaches a value of 1 as specified in step 10, the test is concluded. Change the values for the InstanceName and Server parameters to match the name of the host instance and server that you would like to monitor in your environment.

<!-- Step 8: LoadGen: Load actual perf test -->
<TestStep assemblyPath="" typeName="BizUnit.LoadGenSteps.LoadGenExecuteStep, BizUnit.LoadGenSteps , Version=3.0.0.0, Culture=neutral, PublicKeyToken=7eb7d82981ae5162">
   <LoadGenTestConfig>C:\Program Files\LoadGen\ConfigFiles\ConsoleConfigFiles\PerfGuideFiletoFile.xml</LoadGenTestConfig>
</TestStep>
<!-- Step 9: Delay for 5 secs to allow msgs to start flowing -->
<TestStep assemblyPath="" typeName="BizUnit.DelayStep">
   <Delay>5000</Delay>
</TestStep>
<!-- Step 10: Wait for Orch Host Queue depth to reach one -->
<TestStep assemblyPath="" typeName="BizUnit.PerfMonCounterMonitorStep">
   <CategoryName>BizTalk:Message Box:Host Counters</CategoryName>
   <CounterName>Host Queue - Length</CounterName>
   <InstanceName>BizTalkServerApplication:biztalkmsgboxdb:BizTalkAdmin01</InstanceName>
   <Server>BizTalkAdmin01</Server>
   <CounterTargetValue>1</CounterTargetValue>
</TestStep>

At the conclusion of the test we use BizUnit.DBExecuteNonQueryStep to update the test results database. Completion of this step signifies the end of the test execution stage, as indicated by the closing </TestExecution> tag. Again, you must modify the ConnectionString and RawSQLQuery parameters to match your environment.

   <!-- Step 11: Update test results DB with test stop time -->
   <TestStep assemblyPath="" typeName="BizUnit.DBExecuteNonQueryStep">
      <DelayBeforeExecution>1</DelayBeforeExecution>
      <ConnectionString>Persist Security Info=False;Integrated Security=SSPI;database=TestResults;server=BIZTALKADMIN01;Connect Timeout=30</ConnectionString>
      <SQLQuery>
         <RawSQLQuery>UPDATE tblPerformanceResults SET EndTime = GetDate() WHERE Test_ID = '{0}'</RawSQLQuery>
         <SQLQueryParams>
            <SQLQueryParam takeFromCtx="TestRunName"></SQLQueryParam>
         </SQLQueryParams>
      </SQLQuery>
   </TestStep>
</TestExecution>

Upon concluding the execution stage we enter the test cleanup stage. This stage uses BizUnit.PerfmonCountersStep to stop the Performance Monitor counters that were started earlier (in Step 3).

<TestCleanup>
      <!-- Return system to state prior to test -->
      <!-- Stop perfmon counters -->
      <TestStep assemblyPath="" typeName="BizUnit.PerfmonCountersStep" failOnError="false">
         <PerfmonAction>Stop</PerfmonAction>
         <CounterSetName>PerfGuidePerfmonCounters</CounterSetName>
      </TestStep>
   </TestCleanup>
</TestCase>

This example illustrated how BizUnit can be combined with LoadGen to automate performance testing. The load test described by the BizUnit configuration file can be executed from Visual Studio’s testing tools in the same manner as the functional testing. Adopting this approach enables you to centrally manage, administer, and collect data for your performance testing.

By using BizUnit and LoadGen in an automated approach, it is very easy to schedule multiple test runs to occur during off hours, which will provide ample test results for analysis during normal working hours. When automating performance testing, consider using LoadGen scripts that model different loads through the system, for example you may wish to simulate varying degrees (75%, 100% and 125%) of the expected production message volume. When performing load testing, it is especially important to test the overload or “bad day” scenario. Before placing the system into production, you should know what the maximum sustainable throughput (MST) is for each test case in the BizTalk Server environment. For more information about maximum sustainable performance, see What Is Sustainable Performance? (https://go.microsoft.com/fwlink/?LinkID=132304) in the BizTalk Server 2009 documentation.

The complete BizUnit LoadGen sample configuration file

The following list contains the entire contents of the BizUnit configuration file referenced earlier.

<TestCase testName="Performance-Guide-Sample-Loadgen-Test">
   <TestSetup>
      <!-- Context property: name of test run -->
      <TestStep assemblyPath="" typeName="BizUnit.ContextManipulatorStep">
         <ContextItem contextKey="TestRunName">
            <ItemTest takeFromCtx="BizUnitTestCaseName"></ItemTest>
            <ItemTest>_%DateTime%</ItemTest>
         </ContextItem>
      </TestStep>
      <!-- Context property: name of test directory to store results -->
      <TestStep assemblyPath="" typeName="BizUnit.ContextManipulatorStep">
         <ContextItem contextKey="TestCaseResultsDir">
            <ItemTest>C:\Dev Work\Perf Guide Demos\PerfResults\</ItemTest>
            <ItemTest takeFromCtx="TestRunName"></ItemTest>
         </ContextItem>
      </TestStep>
      <!-- Context property: perfmon log file -->
      <TestStep assemblyPath="" typeName="BizUnit.ContextManipulatorStep">
         <ContextItem contextKey="PerfMonFilePath">
            <ItemTest takeFromCtx="TestCaseResultsDir"></ItemTest>
            <ItemTest>\PerfCounters.blg</ItemTest>
         </ContextItem>
      </TestStep>
      <!-- Context property: destintation for app event log on BTSSVR-001 -->
      <TestStep assemblyPath="" typeName="BizUnit.ContextManipulatorStep">
         <ContextItem contextKey="DestPath-BTSSVR-001-AppEventLog">
            <ItemTest takeFromCtx="TestCaseResultsDir"></ItemTest>
            <ItemTest>BTSSVR-001_ApplicationLog.evt</ItemTest>
         </ContextItem>
      </TestStep>
      <!-- Clear the application event log on BTSSVR-001 -->
      <TestStep assemblyPath="" typeName="BizUnit.EventLogClearStep">
         <Machine>BIZTALKADMIN01</Machine>
         <EventLog>Application</EventLog>
      </TestStep>
      <!-- Create the directory to save all the test results -->
      <TestStep assemblyPath="" typeName="BizUnit.CreateDirectory">
         <DirectoryName takeFromCtx="TestCaseResultsDir" ></DirectoryName>
      </TestStep>
   </TestSetup>

   <TestExecution>
      <!-- Step 1: Stop BizTalk Hosts -->
      <TestStep assemblyPath="" typeName="BizUnit.HostConductorStep, BizUnit.BizTalkSteps">
         <Action>stop</Action>
         <HostInstanceName>BizTalkServerApplication</HostInstanceName>
         <Server>BizTalkAdmin01</Server>
         <Logon>ServerName\Administrator</Logon>
         <PassWord>Pass@word1</PassWord>
         <GrantLogOnAsService>true</GrantLogOnAsService>
      </TestStep>
      <!-- Step 2: Clean Up MessageBox -->
      <TestStep assemblyPath="" typeName="BizUnit.DBExecuteNonQueryStep">
         <DelayBeforeExecution>1</DelayBeforeExecution>
         <ConnectionString>Persist Security Info=False;Integrated Security=SSPI;database=BizTalkMsgBoxDb;server=BIZTALKADMIN01;Connect Timeout=30</ConnectionString>
         <SQLQuery>
            <RawSQLQuery>[dbo].[bts_CleanupMsgbox]</RawSQLQuery>
         </SQLQuery>
      </TestStep>
      <!-- Step 3: Start Perfmon counters -->
      <TestStep assemblyPath="" typeName="BizUnit.PerfmonCountersStep">
         <PerfmonAction>Start</PerfmonAction>
         <CounterSetName>PerfGuidePerfmonCounters</CounterSetName>
         <CountersListFilePath>C:\Dev Work\Perf Guide Demos\Test_06_PerfCounters.txt</CountersListFilePath>
         <SampleInterval>5</SampleInterval>
         <PerfmonLogFilePath takeFromCtx="PerfMonFilePath"></PerfmonLogFilePath>
      </TestStep>
      <!-- Step 4: Start BizTalk Hosts -->
      <TestStep assemblyPath="" typeName="BizUnit.BizTalkSteps.HostConductorStep, BizUnit.BizTalkSteps, Version=3.0.0.0, Culture=neutral, PublicKeyToken=7eb7d82981ae5162">
         <Action>start</Action>
         <HostInstanceName>BizTalkServerApplication</HostInstanceName>
         <Server>BizTalkAdmin01</Server>
         <Logon>ServerName\Administrator</Logon>
         <PassWord>Pass@word1</PassWord>
         <GrantLogOnAsService>true</GrantLogOnAsService>
      </TestStep>
      <!-- Step 5: Send Priming messages -->
      <TestStep assemblyPath="" typeName="BizUnit.LoadGenExecuteStep, BizUnit.LoadGenSteps">
         <LoadGenTestConfig>C:\Program Files\LoadGen\ConfigFiles\ConsoleConfigFiles\PerfGuideFiletoFile.xml</LoadGenTestConfig>
      </TestStep>
      <!-- Step 6: Read loadgen file into context variable -->
      <TestStep assemblyPath="" typeName="BizUnit.FileReadAndLoadToContext">
         <FilePath>C:\Program Files\LoadGen\ConfigFiles\ConsoleConfigFiles\PerfGuideFiletoFile.xml</FilePath>
         <ContextPropertyName>LoadGenFileContent</ContextPropertyName>
      </TestStep>
      <!-- Step 7: Update test results DB with test start time -->
      <TestStep assemblyPath="" typeName="BizUnit.DBExecuteNonQueryStep">
         <DelayBeforeExecution>1</DelayBeforeExecution>
         <ConnectionString>Persist Security Info=False;Integrated Security=SSPI;database=TestResults;server=BizTalkAdmin01;Connect Timeout=30</ConnectionString>
         <SQLQuery>
            <RawSQLQuery>INSERT INTO tblPerformanceResults (Test_ID, StartTime,LoadGenFile) VALUES ('{0}',GetDate(),'{1}' )</RawSQLQuery>
            <SQLQueryParams>
               <SQLQueryParam takeFromCtx="TestRunName"></SQLQueryParam>
               <SQLQueryParam takeFromCtx="LoadGenFileContent"></SQLQueryParam>
            </SQLQueryParams>
         </SQLQuery>
      </TestStep>
      <!-- Step 8: LoadGen: Load actual perf test -->
      <TestStep assemblyPath="" typeName="BizUnit.LoadGenSteps.LoadGenExecuteStep, BizUnit.LoadGenSteps , Version=3.0.0.0, Culture=neutral, PublicKeyToken=7eb7d82981ae5162">
        <LoadGenTestConfig>C:\Program Files\LoadGen\ConfigFiles\ConsoleConfigFiles\PerfGuideFiletoFile.xml</LoadGenTestConfig>
      </TestStep>
      <!-- Step 9: Delay for 5 secs to allow msgs to start flowing -->
      <TestStep assemblyPath="" typeName="BizUnit.DelayStep">
         <Delay>5000</Delay>
      </TestStep>
      <!-- Step 10: Wait for Orch Host Queue depth to reach one -->
      <TestStep assemblyPath="" typeName="BizUnit.PerfMonCounterMonitorStep">
         <CategoryName>BizTalk:Message Box:Host Counters</CategoryName>
         <CounterName>Host Queue - Length</CounterName>
         <InstanceName>BizTalkServerApplication:biztalkmsgboxdb:BizTalkAdmin01</InstanceName>
         <Server>BizTalkAdmin01</Server>
         <CounterTargetValue>1</CounterTargetValue>
      </TestStep>
      <!-- Step 11: Update test results DB with test stop time -->
      <TestStep assemblyPath="" typeName="BizUnit.DBExecuteNonQueryStep">
         <DelayBeforeExecution>1</DelayBeforeExecution>
         <ConnectionString>Persist Security Info=False;Integrated Security=SSPI;database=TestResults;server=BIZTALKADMIN01;Connect Timeout=30</ConnectionString>
         <SQLQuery>
            <RawSQLQuery>UPDATE tblPerformanceResults SET EndTime = GetDate() WHERE Test_ID = '{0}'</RawSQLQuery>
            <SQLQueryParams>
               <SQLQueryParam takeFromCtx="TestRunName"></SQLQueryParam>
            </SQLQueryParams>
         </SQLQuery>
      </TestStep>
   </TestExecution>

   <TestCleanup>
      <!-- Return system to state prior to test -->
      <!-- Stop perfmon counters -->
      <TestStep assemblyPath="" typeName="BizUnit.PerfmonCountersStep" failOnError="false">
         <PerfmonAction>Stop</PerfmonAction>
         <CounterSetName>PerfGuidePerfmonCounters</CounterSetName>
      </TestStep>
   </TestCleanup>
</TestCase>

See Also

Using BizUnit to Facilitate Automated Testing