Geeks With Blogs

News View Michael Stephenson's profile on BizTalk Blog Doc View Michael Stephenson's profile on LinkedIn
Michael Stephenson keeping your feet on premise while your heads in the cloud

I have been setting up some performance tests using LoadGen today and was having a couple of problems where the message sent by LoadGen wasnt working properly and it was a bit of a pain trying to workout the cause of the problem.

After 10 minutes I thought hang on ive got BizUnit tests which do exactly what I want except that I just want to run them a lot of times.  This made me think back to something Ewan Fairweather said back at TechEd Barcelona about potentially integrating LoadGen and BizUnit.  A bit of a google didnt bring up many results so I have a look at writing my own transport provider for LoadGen.

This was very easy.

I started off by creating a new C# project and added the following references:

  • Microsoft.Services.BizTalkApplicationFramework.BizUnit
  • LoadGen.dll

I then created a class called BizUnitTransport and implemented the following interfaces from LoadGen:

  • ITransport
  • IConfigurable

IConfigurable basically accepts the information from the LoadGen file to configure the transport with its required parameters.  I basically wanted 1 parameter which is the path to the BizUnit configuration file containing the information about what my test should do.

ITransport is where the work of the class is done.  The main method to be executed is SendSmallMessage within which I will call BizUnit passing in the path to the test config file.

The code snippet for my task is as follows:

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Xml;
using Microsoft.Services.BizTalkApplicationFramework.BizUnit;
using System.Diagnostics;

namespace LoadGen.BizUnitTransport
{
    /// <summary>
    /// Class to implement BizUnit as a transport type for LoadGen
    /// </summary>
    public class BizUnitTransport : ITransport, IConfigurable
    {
        private string _BizUnitTestCasePath;       
       
        #region ITransport Members
        /// <summary>
        /// Cleanup
        /// </summary>
        /// <param name="sCleanup"></param>
        public void Cleanup(string sCleanup)
        {
           
        }
        /// <summary>
        /// DSTLocation
        /// </summary>
        public string[] DstLocation
        {
            get
            {
                return null;
            }
            set
            {
               
            }
        }
        /// <summary>
        /// Init
        /// </summary>
        /// <param name="sInitialize"></param>
        public void Initialize(string sInitialize)
        {
           
        }
        /// <summary>
        /// Message to be sent
        /// </summary>
        public Message MessageToBeSent
        {
            get
            {
                return null;
            }
            set
            {
               
            }
        }
        /// <summary>
        /// Send large message
        /// </summary>
        /// <param name="UniqueDestFileName"></param>
        public void SendLargeMessage(string UniqueDestFileName)
        {
            SendSmallMessage(UniqueDestFileName);
        }
        /// <summary>
        /// Send small message
        /// </summary>
        /// <param name="UniqueDestFileName"></param>
        public void SendSmallMessage(string UniqueDestFileName)
        {
            try
            {
                BizUnit bu = new BizUnit(this._BizUnitTestCasePath);
                bu.RunTest();
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry("LoadGen", "BizUnitTransport - SendSmallMessage() encountered the following exception and it will retry: " + ex.ToString(), EventLogEntryType.Error);
                throw;
            }
        }

        #endregion

       
        #region IConfigurable Members
        /// <summary>
        /// The parameters for the transport
        /// </summary>
        public string ConfigParameters
        {
            get
            {
                return "<Parameters><BizUnitTestCasePath/></Parameters>";
            }
            set
            {               
                StringReader txtReader = new StringReader(value);
                XmlDocument document = new XmlDocument();
                document.Load(txtReader);
                if (document.SelectSingleNode("/Parameters/BizUnitTestCasePath") == null)
                {
                    throw new ConfigException("<BizUnitTestCasePath/> Missing!" + Environment.NewLine);
                }
                this._BizUnitTestCasePath = document.SelectSingleNode("/Parameters/BizUnitTestCasePath").InnerText;               
                txtReader.Dispose();
            }
        }

        #endregion
    }
}

 

When I compiled my new transport assembly I copied it and its references to the Bin folder where the LoadGen assemblies are.  The next step is to create the LoadGen file to run my performance test.  The following code snippet shows a basic file:

<LoadGenFramework>

<CommonSection>
  <LoadGenVersion>2</LoadGenVersion>
  <OptimizeLimitFileSize>204800</OptimizeLimitFileSize>
  <NumThreadsPerSection>50</NumThreadsPerSection>
  <SleepInterval>200</SleepInterval>
  <LotSizePerInterval>20</LotSizePerInterval>
  <RetryInterval>10000</RetryInterval>

  <StopMode Mode="Files">
   <NumFiles>100000</NumFiles>
   <TotalTime>3600</TotalTime>
  </StopMode>

  <Transport Name="BizUnit">
   <Assembly>LoadGen.BizUnitTransport.dll/LoadGen.BizUnitTransport.BizUnitTransport</Assembly>
  </Transport>
 

 </CommonSection>

 <Section Name="BizUnitSection">
  <SrcFilePath>C:\LoadGen\PathToaFile.xml</SrcFilePath>
  <DstLocation>
   <Parameters>
    <BizUnitTestCasePath>BizUnitTests.Cases.GetCommonDocumentTemplates.GreenPath.xml</BizUnitTestCasePath>
   </Parameters>
  </DstLocation>
</Section>
</LoadGenFramework>

I have highlighted 3 sections in the above snippet. 

  • The blue section is where I have told LoadGen to use my new transport type assembly. 
  • The green bit within my custom section is interesting in that it seems to be required but because I dont use LoadGen to create the message (i do it in the BizUnit test) I have just put in the path to a file which exists.  This seems to work but I may revisit this at somepoint to see if there is a way to not have to specify it.  I did not specify the bizunit file here as this property seems to become a message passed to the transport.
  • The yellow section is a custom property relating to my implementation of IConfigurable.  This is where I specify the path to my BizUnit Test

When I was ready to run my test i needed to ensure the BizUnit files were in the correct location where I expected them to be ran from then I ran the following command:

cd "C:\Program Files\LoadGen\Bins"
LoadGenConsole.exe C:\LoadGen\BizUnitGetAdhocData.xml"

This then ran LoadGen to use my BizUnit test in a performance test. 

I could then monitor the BizTalk performance counters to monitor how my BizTalk environment performed when running this test under load.

Posted on Monday, December 10, 2007 9:35 PM BizTalk , BizTalk Testing | Back to top


Comments on this post: Integrating BizUnit & LoadGen

# re: Integrating BizUnit & LoadGen
Requesting Gravatar...
[url=https://liteblueuspsgov.org/]liteblue[/url] is the usps employee portal.
Left by lite20 on Oct 27, 2017 12:42 AM

Your comment:
 (will show your gravatar)


Copyright © Michael Stephenson | Powered by: GeeksWithBlogs.net