<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.microsoft.co.il/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Shai Raiten&amp;#39;s Blog : Performance, CodePlex</title><link>http://blogs.microsoft.co.il/blogs/shair/archive/tags/Performance/CodePlex/default.aspx</link><description>Tags: Performance, CodePlex</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>SQL Load Testing</title><link>http://blogs.microsoft.co.il/blogs/shair/archive/2008/07/24/sql-load-testing.aspx</link><pubDate>Thu, 24 Jul 2008 16:06:58 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:125851</guid><dc:creator>Shai Raiten</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/shair/rsscomments.aspx?PostID=125851</wfw:commentRss><comments>http://blogs.microsoft.co.il/blogs/shair/archive/2008/07/24/sql-load-testing.aspx#comments</comments><description>&lt;h1&gt;SQL Load Testing&lt;/h1&gt; &lt;h3&gt;Introduction&amp;nbsp; - &lt;a href="http://www.codeplex.com/SQLLoadTest" target="_blank"&gt;SQL Load Test&lt;/a&gt;&amp;nbsp; &lt;a href="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/image_18.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="147" alt="image" src="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/image_thumb_8.png" width="244" align="right" border="0" /&gt;&lt;/a&gt;&lt;/h3&gt; &lt;p&gt;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. &lt;br /&gt;The tool does not interact with the database itself when it generates the test code and so it can be used “offline”. &lt;h4&gt;Requirements:&lt;/h4&gt;&lt;strong&gt;&lt;/strong&gt; &lt;ul&gt; &lt;li&gt;SQL Server 2005 SDK and the SQL Server 2005 Management Tools are installed.&lt;/li&gt; &lt;li&gt;Visual Studio 2005/2008 Team Edition for Software Testers.&lt;/li&gt;&lt;/ul&gt; &lt;h2&gt;Demo - Create SQL Load Test&lt;/h2&gt; &lt;p&gt;Download &lt;a href="http://www.codeplex.com/SQLLoadTest" target="_blank"&gt;SQL Load Test&lt;/a&gt; and copy the packaged assemblies to a convenient location.&lt;/p&gt; &lt;p&gt;For this Demo I used &amp;quot;&lt;a href="http://www.codeplex.com/TheBeerHouse" target="_blank"&gt;The Beer House&lt;/a&gt;&amp;quot; CMS &amp;amp; e-commerce site.&lt;br /&gt;&lt;em&gt;I installed SQL Server and &amp;quot;The Beer House&amp;quot; on my computer.&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;First let&amp;#39;s create new SQL profiler trace file (&lt;a href="http://blogs.microsoft.co.il/blogs/shair/SQLLoadTestTemplate.zip" target="_blank"&gt;Template&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/Create%20New%20Trace%20File.jpg"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="363" alt="Create New Trace File" src="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/Create%20New%20Trace%20File_thumb.jpg" width="579" border="0" /&gt;&lt;/a&gt;  &lt;p&gt;The trace passed to the parser must contain the following columns, each required event class must include these columns:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;EventClass&lt;/li&gt; &lt;li&gt;TextData&lt;/li&gt; &lt;li&gt;DatabaseName - if this is omitted then the trace is assumed to be all for the same database&lt;/li&gt; &lt;li&gt;SPID&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/Default%20Configuration.jpg"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="366" alt="Default Configuration" src="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/Default%20Configuration_thumb.jpg" width="583" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;After you finish configure the trace file press &amp;quot;Run&amp;quot; to start recording.&lt;/p&gt; &lt;p&gt;Open the &amp;quot;The Beer House&amp;quot; site and start perform the actions you like to record.&lt;/p&gt; &lt;p&gt;(Login etc..).&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/image_2.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="444" alt="image" src="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/image_thumb.png" width="590" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;When you done with the test scenario stop profiler recording and save the trace file. &lt;br /&gt;&lt;br /&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/Recording.jpg"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="463" alt="Recording" src="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/Recording_thumb.jpg" width="593" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Copy the trace file into the same folder where the packaged assemblies are.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/Copy%20Trace%20File.jpg"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="286" alt="Copy Trace File" src="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/Copy%20Trace%20File_thumb.jpg" width="598" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Now when you have the trace file ready use the command line tool called DbLoadTestGen to generate &lt;strong&gt;&lt;u&gt;Visual Studio Unit Test.&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;Run it using a command with the following syntax:&lt;/p&gt; &lt;p&gt;&lt;font color="#0000ff"&gt;DbLoadTestGen.exe &amp;lt;&lt;u&gt;Scenario Name&lt;/u&gt;&amp;gt; &amp;lt;&lt;u&gt;Trace File Name&lt;/u&gt;&amp;gt; [&amp;lt;&lt;u&gt;Configuration File Name&lt;/u&gt;&amp;gt;]&lt;/font&gt; &lt;blockquote&gt; &lt;p&gt;1. &lt;strong&gt;Scenario Name&lt;/strong&gt;. 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.&lt;/p&gt;&lt;/blockquote&gt; &lt;blockquote&gt; &lt;p&gt;2. &lt;strong&gt;Trace file name&lt;/strong&gt;. The path to the file containing the SQL trace to be processed.&lt;/p&gt;&lt;/blockquote&gt; &lt;blockquote&gt; &lt;p&gt;3.&lt;strong&gt;Configuration file name&lt;/strong&gt;. 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. &lt;p&gt;&lt;u&gt;For more information read &amp;quot;Database Load Test Tool Usage Notes.doc&amp;quot;&lt;/u&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/image_4.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="471" alt="image" src="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/image_thumb_1.png" width="606" border="0" /&gt;&lt;/a&gt;  &lt;p&gt;When the code generation is done you will see two new files:&lt;/p&gt; &lt;p&gt;SQLTEST.cs - Unit Test&lt;br /&gt;SQLTEST.stubs - Connection String&lt;/p&gt; &lt;p&gt;&lt;strong&gt;The stubs file will need to be renamed to a .cs file. &lt;br /&gt;&lt;/strong&gt;*** The connection string will need to be put into the stubs file.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/image_6.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="292" alt="image" src="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/image_thumb_2.png" width="615" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Now we almost ready to run our SQL Load Test.&lt;/p&gt; &lt;p&gt;Just open Visual Studio Tester Edition and create new Test project, Add &amp;quot;&lt;strong&gt;SQLTEST.cs&lt;/strong&gt;&amp;quot; and &amp;quot;&lt;strong&gt;SQLTEST.stubs.cs&lt;/strong&gt;&amp;quot; into the project.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/Add%20SQLTEST.cs%20Unit%20Test.jpg"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="276" alt="Add SQLTEST.cs Unit Test" src="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/Add%20SQLTEST.cs%20Unit%20Test_thumb.jpg" width="281" border="0" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Edit &amp;quot;&lt;strong&gt;SQLTEST.stubs.cs&lt;/strong&gt;&amp;quot; and add the connection string and save.&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/image_8.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="78" alt="image" src="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/image_thumb_3.png" width="613" border="0" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt; Before you create the Load test let&amp;#39;s us check that&amp;nbsp; everything is working properly.&lt;/p&gt; &lt;p&gt;From the &amp;quot;&lt;strong&gt;Test View&lt;/strong&gt;&amp;quot; run the SQLTEST unit test and watch the profiler...&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/image_10.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="410" alt="image" src="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/image_thumb_4.png" width="621" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&lt;u&gt;&lt;strong&gt;Working!!!&lt;/strong&gt;&lt;/u&gt;&lt;br /&gt;Now when everything is working you can add SQLTEST unit test into a new Load Test.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/image_14.png"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px;" height="503" alt="image" src="http://blogs.microsoft.co.il/blogs/shair/WindowsLiveWriter/SQLLoadTesting_8714/image_thumb_6.png" width="631" border="0" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Enjoy.&amp;nbsp; &lt;/p&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=125851" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/shair/archive/tags/Team+System/default.aspx">Team System</category><category domain="http://blogs.microsoft.co.il/blogs/shair/archive/tags/Performance/default.aspx">Performance</category><category domain="http://blogs.microsoft.co.il/blogs/shair/archive/tags/Testing/default.aspx">Testing</category><category domain="http://blogs.microsoft.co.il/blogs/shair/archive/tags/Load/default.aspx">Load</category><category domain="http://blogs.microsoft.co.il/blogs/shair/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://blogs.microsoft.co.il/blogs/shair/archive/tags/CodePlex/default.aspx">CodePlex</category><category domain="http://blogs.microsoft.co.il/blogs/shair/archive/tags/SQL/default.aspx">SQL</category></item></channel></rss>