DCSIMG
SQL Load Testing - Shai Raiten

Shai Raiten

 Subscribe

SQL Load Testing

SQL Load Testing

Introduction  - SQL Load Test  image

This tool generates a Visual Studio 2005/2008 Unit Test from a SQL Server Profiler trace. The tool extracts all the SQL statements and stored procedure calls from the trace and turns them into a single Visual Studio Unit Test, which can then be configured as a Visual Studio Load Test.
The tool does not interact with the database itself when it generates the test code and so it can be used “offline”.

Requirements:

  • SQL Server 2005 SDK and the SQL Server 2005 Management Tools are installed.
  • Visual Studio 2005/2008 Team Edition for Software Testers.

Demo - Create SQL Load Test

Download SQL Load Test and copy the packaged assemblies to a convenient location.

For this Demo I used "The Beer House" CMS & e-commerce site.
I installed SQL Server and "The Beer House" on my computer.

First let's create new SQL profiler trace file (Template)

Create New Trace File

The trace passed to the parser must contain the following columns, each required event class must include these columns:

  1. EventClass
  2. TextData
  3. DatabaseName - if this is omitted then the trace is assumed to be all for the same database
  4. SPID

Default Configuration 

After you finish configure the trace file press "Run" to start recording.

Open the "The Beer House" site and start perform the actions you like to record.

(Login etc..).

image

When you done with the test scenario stop profiler recording and save the trace file.

Recording

Copy the trace file into the same folder where the packaged assemblies are.

Copy Trace File

Now when you have the trace file ready use the command line tool called DbLoadTestGen to generate Visual Studio Unit Test.
Run it using a command with the following syntax:

DbLoadTestGen.exe <Scenario Name> <Trace File Name> [<Configuration File Name>]

1. Scenario Name. A simple name for the scenario. This must be a valid C# identifier as it is used in the generated code. Avoid using the name of a type or operation in the services under test.

2. Trace file name. The path to the file containing the SQL trace to be processed.

3.Configuration file name. This is optional and it is the path to the file containing the configuration information. If the file is not present a default configuration is used.

For more information read "Database Load Test Tool Usage Notes.doc"

image

When the code generation is done you will see two new files:

SQLTEST.cs - Unit Test
SQLTEST.stubs - Connection String

The stubs file will need to be renamed to a .cs file.
*** The connection string will need to be put into the stubs file.

image

Now we almost ready to run our SQL Load Test.

Just open Visual Studio Tester Edition and create new Test project, Add "SQLTEST.cs" and "SQLTEST.stubs.cs" into the project.

Add SQLTEST.cs Unit Test

Edit "SQLTEST.stubs.cs" and add the connection string and save.

image

Before you create the Load test let's us check that  everything is working properly.

From the "Test View" run the SQLTEST unit test and watch the profiler...

image

Working!!!
Now when everything is working you can add SQLTEST unit test into a new Load Test.

 image

Enjoy. 

Comments

virender said:

its good topic for testing

# September 18, 2008 5:32 AM

Vinay Agarwal said:

Hi,

after creating the trace,while I am trying to generate the Visual Studio Unit Test using the command line tool called DbLoadTestGen..

I am getting the following error message:

D:\SQL Load Test- Codeplex\Release20080709CodePlex>DbLoadTestGen.exe SampleScenario test.trc SampleConfig.xml

Cannot read the trace file test.trc, please ensure it is a valid SQL Profiler trace file.

Failed to initialize object as reader.

Could not load file or assembly 'file:///d:\Program Files\Microsoft SQL Server\90\Tools\Binn\pfclnt90.dll' or one of its dependencies. The system cannot find th

e file specified.

Can someone help??

is test.trc not a valid SQL Profiler trace file??

# December 18, 2009 2:34 AM

Vinay Agarwal said:

well i got it guys..

it was problem with SQL server 2008!!

# December 19, 2009 1:39 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: