Return to PerformanceTestingGuidance



How To: Step Through Creating a Load Test in VS.NET 2005

J.D. Meier, Prashant Bansode, Carlos Farre, Larry Brader


Applies To

* VS .NET 2005

Summary

This how to, shows you how to create a Load Test using Visual Studio 2005. To create a load test in VS 2005, you first create a Test Project. Then you create individual Web tests that simulate user scenarios. You then create a Load Test, to which you will add your Web tests. While creating Load Test you can set many runtime properties to generate desired load simulation, for example you can specify the load pattern, browser and the network types and add the performance counters to be monitored.


Contents

* Objectives
* Overview
* Before You Begin
* Scenario
* Summary of Steps
* Step 1 – Create a Test Project
* Step 2 – Create a Web Test
* Step 3 – Record Your Web Test
* Step 4 – Replay Your Web Test
* Step 5 – Add Your Load Test
* Step 6 – Specify Your Scenario Settings
* Step 7 – Specify Your Load Pattern Settings
* Step 8 – Add Your Web Test to Your Load Test
* Step 9 – Specify Your Browser Mix
* Step 10 – Add Your Network Mix
* Step 11 – Specify Your Computers and Counter Settings
* Step 12 – Specify Your Run Settings
* Step 13 – Run Your Load Test

Objectives

* Learn the end-to-end steps for creating a Load Test using VS.NET 2005.
* Learn how to configure the various Load Test runtime properties.

Overview

Use load testing to verify application behavior under normal and peak load conditions. This allows you to verify that your application can meet your desired performance objectives. Use load testing to measure response times, throughput rates, resource utilization levels, and to identify your application's breaking point.

This how to walks you through a simplified example of creating a load test using VS 2005. The purpose is to familiarize you with the end-to-end steps of creating a load test using VS 2005. Once you are familiar with the steps, you can then focus on specific parts of load testing. For example, you can then focus on modeling the user experience to match your specific context and produce better test results.

Before You Begin

You will need an application to run your load test against. In this example, we use the Small Business Starter Kit. You can download and install the starter kit from the following location:
* Small Business Starter Kit: http://www.asp.net/downloads/starterkits/default.aspx?tabid=62

Note: The small business starter kit will install a template that can be access in the following steps:
* Select New -> New Web Site
* Under 'My Templates' select Small Business Starter Kit
* This will create the Small Business Web Site
* Publish this site to the local machine

Scenario

For this How to we will be using the Small Business Starter kit, assuming this is a Small Business web site, it will be an internet facing web site.

From application point of view the performance critical area is users accessing the Items page and then drilling down to a specific item. Hence we need to Load test the catalog browsing scenario.


Summary of Steps

* Step 1. Create a Test Project
* Step 2. Add a Web Test
* Step 3. Record Your Web Test
* Step 4. Replay Your Web Test
* Step 5. Add Your Load Test
* Step 6. Specify Your Scenario Settings
* Step 7. Specify Your Load Pattern Settings
* Step 8. Add Your Web Test to Your Load Test
* Step 9. Specify Your Browser Mix
* Step 10. Add Your Network Mix
* Step 11. Specify Your Computers and Counter Settings
* Step 12. Specify Your Run Settings
* Step 13. Run Your Load Test

Step 1. Create a Test Project

Create a test project called TestProject1, by default it will have an empty unit test. We will add Web Test and Load Test to this project in later steps.

Note – The language you choose for your Test Project affects the language used when coded Web tests are generated.

Create a Web Service Project

  1. Open a Microsoft Visual Studio 2005 instance.
  2. Select New -> New Web Site
  3. Under 'My Templates' select Small Business Starter Kit
  4. This will create the Small Business Web Site
  5. Build and Publish this site to the local machine

Creating a Test Project

  1. Right Click the Solution, then click Add, and then click New Project.
  2. In the New Project dialog box, in the left hand pane, expand the Visual C# node, and select Test.
  3. In the right hand pane select the option Test Project, name your test project TestProject1, and then click OK.

Note – The TestProject1 created test project will by default have an empty unit test. We will add Web Test to it later steps.

http://farm1.static.flickr.com/164/3361415937dfe9fc0afo.jpg

Step 2. Add a Web Test

In this step, you create a Web test. The Web test will be used in your Load Test. The Web test simulates how an end user will interact with the Web application.

Creating a Web Test

* In Solution Explorer, right-click TestProject1, select Add, and then select Web Test.
http://farm1.static.flickr.com/146/33614159468dcf7ab56o.jpg

* The Web Test Recorder opens inside a new instance of Internet Explorer.


Step 3. Record Your Web Test

For this How to we are creating Web test by recording HTTP requests using the Web Test Recorder in a browser session, but you can also build Web tests manually using the Web Test Editor.

Recording Your Web Test

* In the Address bar, replace about:blank with the URL address of the Small Business Starter Kit web site for which you want to run the Load Test, for example it might be http://localhost:1380/SmallBusiness/ and press Enter.
* When you press Enter, the page is processed and rendered in the browser window. The actions are recorded for subsequent playback when you run the test.

http://farm1.static.flickr.com/146/33614159468dcf7ab56o.jpg

* Go through various steps for accessing item detail as follows.
* Click the Items link available on the default page.
* Then click the Amet hyperlink (First category level).
* Then click the Sed eget Magna hyperlink (Second category level).
* Then click the Proin Vitae hyperlink taking it to the item details page. .
* Click Stop on the Web Test Recorder to stop recording and return to the project. You now have a Web test that contains a list of recorded actions in the Web Test Editor as a list of URLs.

Coded Web Tests

For scenarios where you need to add looping and branching constructs or dynamically change the number of requests in the test or dynamically generate the set of URLs that the test hits, you may need to create coded Web Tests. Coded Web test is a .NET class that generates a sequence of WebTestRequests. A coded Web test is typically created by converting an existing, recorded Web test into a coded Web test.

For more information see "How to: Create a Coded Web Test" at http://msdn2.microsoft.com/en-us/library/ms182550(VS.80).aspx

Step 4. Replay Your Web Test

Replay your Web test to make sure it works. Fix the failure, if it occurs, before you add the Web test to the Load test, since it’s simpler to debug here, debugging from load test is painful process.

Replaying Your Web Test

  1. In the main window of Web test click the Run Test button in the left hand corner. Or you can right click the Web test and choose the option Run Web Test.
  2. The Web test will be run for a single user, and result displayed in the main window as shown in the figure.
  3. Analyze and make sure there are no errors in any of the requests.

http://farm1.static.flickr.com/150/336142896aa85ac9460o.jpg

More Information

The purpose of replaying your Web test is not merely to ascertain if the Web Test passes or fails. Here are the things you might want to check before adding the web test to a Load Test.
* Check if any of the top request or dependent request has failed, the failure reasons could be Authentication, redirection etc. If so fix the failure before you add the Load test. This is important because debugging from load test is painful process.
* Verify that the response time for each request meets the requirements for single user. If yes, then only go ahead with adding your Load test step. If not, try and fix the underlying issue.
* Verify that the file sizes of top requests and dependent requests meet the requirements. If yes, then only go ahead with adding your load test step. If not, try and fix the underlying issue.


Step 5. Add Your Load Test

In this step, you add the Load Test to the TestProject1 project. Subsequently we will add the Web Test to the Load Test, which will simulate the load while executing the Web test. You will then set various properties of your Load Test in subsequent steps.

Adding Your Load Test

* In Solution Explorer, right-click the TestProject1 project node. Select Add, and then click Load Test.

http://farm1.static.flickr.com/134/33614158913ac58b319o.jpg

* The New Load Test Wizard starts.
* The Welcome page of the New Load Test Wizard is the first page.
* Click Next.

http://farm1.static.flickr.com/85/336141587cb0b09bee6o.jpg

Step 6. Specify your scenario settings

In this step, you specify the details for the user scenario, for which we are developing the Load Test.

Specifying Your Scenario Settings

  1. Specify name of your scenario. We are performing Load Test for browsing catalog scenario, so the scenario name could be "Browsing Catalog."
  2. Set the Time Profile Think to Use normal distribution centered on recorded think times. This will use the recorded times from Step 3. Record Your Web Test. Think times represent the time that a user would ponder a Web page before going on to the next page. For this exercise, the think time will be the time spent by user to read the catalog and choose a category and narrow down to an item.

http://farm1.static.flickr.com/139/3361438857fb63c0853o.jpg

More Information

By choosing normal distribution, think times are used, but varied on a normal curve. Provides a more realistic simulation of virtual users by slightly varying the think time between requests.


Step 7. Specify your load pattern settings

In this step, you set the load pattern. In this case, you use the Step Load pattern. This pattern increases the user load until you reach the Maximum user count.

Using a Step Load

  1. Set Start user count to a value which you perceive your minimum user count will be. For this exercise set it to 10 users.
  2. Step duration is time interval in seconds, between opening the minimum number of user connections and opening additional user connections. For our scenario set it 10 seconds.
  3. Step user count is the number of additionally user connection opened during each step. For our scenario set it to 10 users per step.
  4. Maximum user count is the maximum number of users for which you are load testing. For our scenario set it to 200 users.

Note – The total test duration specified in Step 11 should be more than the total step time to reach the maximum user count. If not the Load test will stop after the elapsed time and will not reach the Maximum user count

http://farm1.static.flickr.com/133/336142887ab9f24133do.jpg

More Information

The information regarding the loading pattern and specific inputs can be obtained from service level agreement of your application or the performance objectives set.


Step 8. Add Your Web Test to Your Load Test

In this step you, add web tests to the Load Test and also set the work distribution for each web test.

Adding Your Web Test to Your Load Test

* In the Add tests to a load test scenario and edit test mix screen Click Add… button.
* It opens a Add Tests dialog box, click the web test created in previous steps from the Available tests: list box and using the arrow move it to the Selected tests: list box
* Then click OK button on Add Tests dialog box.

http://farm1.static.flickr.com/128/33614388614e605f771o.jpg

* In the test mix, you can use the sliders to adjust the test distribution, but in our case as we are running only 1 web test, the distribution will be 100%.
* Click Next.

The Load Test will use the Web Test to simulate the actual user interaction with the Web Application and would make concurrent HTTP requests, to simulate real time environment.

If you have more then one web tests added, to your Load test, you can adjust the test distribution using the sliders, in terms of %. The Load Test would run the various Web tests in the ratio of the test distribution.


Step 9. Specify your browser mix

In this step, you add the browser mix by specifying types of browsers being used and distribution ratio for each type of browser.

Specifying Your Browser Mix

  1. From the drop-down list of browser types, select the IE6 browser to add to the mix.
  2. As our web site is internet facing web site we would be adding Netscape 6.0 as well, Click Add button from the drop down select Netscape 6.0.
  3. Adjust the distribution of IE user and Netscape as 88% IE and 12% Netscape (based on industry trends).
  4. Then click Next.

http://farm1.static.flickr.com/145/336141590f127fb74deo.jpg

More Information

The browser mix is a combination of two factors. The first factor is browser types. The second factor is the distribution. The types of browser which are being supported can be determined from the requirement specs or service level agreement.

Depending upon the requirements or industry trends the browser mix distribution can be decided and set in terms of percentage.


Step 10. Add your network mix

In this step, you add the network mix by specifying types of network, on which the application is accessed and distribution ratio for each type of network.

Specifying Your Network Mix

  1. As our Web Site is internet facing and users from various location are expected to use the Web site, it will be mix of DSL and dial-up connection.
  2. From the Network Type drop down, select the Cable / DSL 1.5 Mbps connection type.
  3. Click Add button and select the Dial-up 56K.
  4. Let the distribution be 50% each.
  5. Then click Next.

http://farm1.static.flickr.com/143/336142890f11cdb14c0o.jpg

More Information

Network mix, is a combination of two factors. The first factor is network types. The second factor is the distribution of network types. The types of network which are being supported can be determined from the requirement specs or service level agreement. Depending upon the requirements or industry trends the network mix distribution can be decided and set in terms of percentage.

Step 11. Specify your computers and counter sets to monitor

In this step you specify the performance counters to be used for capturing Load test results to gauge the performance of the application.

Specifying Your Computers and Counter Sets

  1. In our scenario as the Web Site is deployed on the local machine we will use the default counter set.
  2. Click Next.

http://farm1.static.flickr.com/126/3361415927d53e366f5o.jpg

More Information

The Performance counters are organized by technologies that are useful to monitor during a load test run. Counter sets are part of the load test and apply to all the scenarios in it. The counter sets include Load Test, IIS, ASP.NET, and SQL.

When you create a load test with the Load Test Wizard, you add an initial set of counters. These offer you a set of predefined and important counter sets for your load test. These sets are useful when you are analyzing a server running IIS, ASP.NET, or SQL Server.

If the Web Application and database is hosted on remote machine, click Add Computer… button and enter the names of the computer. Once you have added computers, there will be nodes below the new entry that you can select. For example ADO.NET, IIS, SQL and others. Select the check boxes in front of the nodes you want to select. The new counters appear in preview selections pane.

Note – You should have user permissions to run performance monitors for remote servers.


Step 12. Specify Your Run Settings

In this step, specify set of properties which determine how the Load test runs. The run settings determine the length of the test, warm-up duration, maximum number of error details reported, sampling rate, validation level etc.
By default the Warm-up duration is 0, Run duration is 10 minutes, Sampling rate is 5 seconds, Maximum error details is 100 and Validation level is Low.

Specifying Your Settings

  1. On the Run Settings page choose your initial settings.
  2. Specify the Warm-up duration in hh:mm:ss format. This is the period between the beginning of the test and when the data samples start being recorded.
  3. Specify Run duration in hh:mm:ss format. This is the actual length of the test.
  4. Specify Sampling rate in seconds. This is the interval at which to capture performance counter values
  5. In the Description edit box specify the description of the Run Settings.
  6. Specify the Maximum error details, this is the maximum number of request and response details of failed requests that are stored. This is important because detailed error results can consume a large amount of database storage. If you do not want to record error details, use a value of 0.
  7. Specify the Validation level. This defines the highest level of validation rule that will run in a load test. Validation rules are associated with Web test requests. Each validation rule has an associated validation level; high, medium, or low. This load test running setting will specify which validation rules will run while the Web test is run in the load test. For example, if this run setting is set to Medium, all validation rules marked as medium or low will be run.
  8. Click Finish. Your Load test is opened in the Load Test Editor.

http://farm1.static.flickr.com/128/336142897e2f79a2551o.jpg

More Information

The defaults cause the Load test to run for the duration of 10 minutes while recording the sample data every 5 seconds from the start of the test. If there any failed requests, maximum 100 requests and response details are stored.

Validation rules help verify that a Web application is working correctly by validating the existence of text, tags, or attributes on the page returned by a Web request. The default setting, Low executes the fewest rules and can be used for heavy load test and stress runs.

Note – The Run duration specified should be more than the time required to reach the Maximum user count specified in the Load Pattern (Step 4), to ensure that the test does not stop before the reaching the maximum user count.


Step 13. Run Your Load Test

In this step you run the Load test to see, how the Web application responds to the web test, under the load simulation.

Running Your Load Test

  1. In the Load Test Editor right click on the Load Test and select Run Test option.
  2. Click View menu in main window then select Full Screen, this will maximize the viewable area.
  3. Once the Load test is complete, it displays a message, "Load Test 'LoadTest1' is complete. The test data currently displayed only represents a portion of the available results. Would you like to view the detailed results from the load test result store?"
  4. Click Yes on the message.

http://farm1.static.flickr.com/165/3361429006651a66a1fo.jpg

More Information

The threshold violation, errors, warnings are displayed with different colors and icons. Counters violating thresholds can be dragged onto the graph, to generate the violation graph. This can be done while the test is running.

Additional Resources

<<TBD>>
* Walkthrough: Creating and Running a Load Test




Return to PerformanceTestingGuidance
Microsoft Communities