Walkthrough: Creating and Running a Load Test Containing Web Performance Tests
In this walkthrough you create a load test that contains a Web performance test.
This walkthrough steps you through creating and then running a load test by using Visual Studio Ultimate. A load test is a container of Web performance tests and unit tests. You create load tests with the New Load Test Wizard. For more information about load tests, see Creating and Editing Load Tests. For more information about Web performance tests, see Creating and Editing Web Performance Tests. For information about unit tests, see Verifying Code by Using Unit Tests.
Note
Although a load test can contain both Web performance tests and unit tests, this walkthrough focuses on a load test that contains a Web performance test. To learn how to add a unit test to a load test, see Walkthrough: Creating and Running a Load Test Containing Unit Tests.
A load test exposes many run-time properties that can be modified to generate the desired load simulation. In this walkthrough, you use the New Load Test Wizard to add a Web performance test to a load test.
This walkthrough requires an existing a Web performance test that you can add to a load test.
In this walkthrough, you will complete the following tasks:
Create a load test.
Add a Web performance test to the load test.
Change some load test settings.
Run the load test.
Prerequisites
Visual Studio Ultimate.
Complete the steps to create a Web application in Walkthrough: Creating a Simple Web App.
Complete the steps to create a Web performance test. See Walkthrough: Recording and Running a Web Performance Test.
Open the ColorWebApp Solution Created in Previous Walkthroughs
Open solution
Open the ColorWebApp solution that contains the ColorWebApp ASP.NET Web Application and the Web performance test ColorWebTest.webtest.
For more information, see Walkthrough: Creating a Simple Web App and Walkthrough: Recording and Running a Web Performance Test.
Modify the Code in Red.aspx.cs ASP.NET Page to Demonstrate Threshold Violations and Errors
To modify the Red.aspx.cs code to demonstrate threshold violations and errors
In Solution Explorer, expand the ColorWebApp ASP.NET Web application project folder and then expand the Red.aspx node.
Right-click the Red.aspx.cs file and select View Code.
In the Code Editor, add the following highlighted code in the Page_Load method:
protected void Page_Load(object sender, EventArgs e) { Random rnd = new Random(); int result = rnd.Next(5000); //To emmulate various page times up to 5 seconds. Thread.Sleep(result); if (result < 500) Response.Redirect("NOWHERE"); //10% chance to cause an HTTP 404 error. }
This additional code is so that you can view mock threshold violations and errors in the Load Test Analyzer. You will view these violations later in this walkthrough.
Creating the Load Test Using the New Load Test Wizard
To start the New Load Test Wizard
In Solution Explorer, right-click the ColorWebAppTest Web performance and load test project node.
Choose Add, and then choose Load Test.
The New Load Test Wizard starts.
The Welcome to the Create New Load Test Wizard page of the New Load Test Wizard is the first page.
Choose Next.
To edit settings for the load test scenario
The Edit settings for a load test scenario page is displayed.
In the text box under Enter a name for the load test scenario, type Scenario basic stress.
A scenario is a grouping mechanism. It consists of a set of tests and the properties for running those tests under load.
Set the Time Profile Think to Use normal distribution centered on recorded think times.
Think times represent the time that a user would ponder a Web page before going on to the next page.
For more information, see How to: Set Think Times to Simulate Human Pausing in a Web Performance Test.
Choose Next.
To edit load pattern setting for the test scenario
The Edit load pattern settings for a load test scenario page is displayed.
Select Constant Load.
The load pattern properties specify how the simulated user load is adjusted during a load test.
For more information, see Editing Load Patterns to Model Virtual User Activities.
Choose Next.
To select test mix model for the scenario
The Select a test mix model for the load test page is displayed.
Under How should the test mix be modeled, select Based on the total number of tests.
The test mix model specifies the probability of a virtual user running a given test in a load test scenario.
For more information, see Editing Text Mix Models to Specify the Probability of a Virtual User Running a Test.
Choose Next.
To add the ColorWebTest.webtest Web performance test to the scenario
The Add tests to a load test scenario and edit the test mix page is displayed.
Choose Add to select tests.
The Add Tests dialog box appears.
In the Available Tests pane, select the ColorWebTest Web performance test and choose the arrow to add it to the Selected Tests pane.
Choose OK.
You are presented with the test mix. If the load test contains multiple Web performance and unit tests, you could use the sliders to adjust the test distribution.
The test mix of a scenario is a combination of various factors, such as the selection of tests that are contained within the scenario and the distribution of those tests within the scenario. The test mix should reflect the objectives of your test for a particular scenario.
For more information, see Editing Text Mix Models to Specify the Probability of a Virtual User Running a Test.
Choose Next.
To select network mix for test scenario
The Add network types to a load test scenario and edit the network mix page is displayed.
Leave the default settings of LAN at 100%.
The network mix gives you a way to simulate load more realistically in a load test scenario.
To specify the type of networks that you want to emulate in the load test scenario, you can choose the drop-down arrow next to each row under Network Types. If you configure the network mix to use more than one network type, you can use the sliders to specify the network type distribution.
For more information, see Specifying Virtual Network Types in a Load Test Scenario.
Choose Next.
To select browser mix for test scenario
The Add browser types to a load test scenario and edit the browser mix page is displayed.
Leave the default setting of Internet Explorer 7.0, or specify the browser type that you are currently using.
To specify the types of browsers that you want to test the Web application with in the load test scenario, you can choose the drop-down arrow next to each row under Browser Type. If you configure the browser mix to use more than one browser type, you can use the sliders to specify the browser type distribution.
For more information, see Editing the Test Mix to Specify Which Web Browsers Types in a Load Test Scenario.
Choose Next.
To specify computers to monitor with counter sets during load test run
The Specify computers to monitor with counter sets during load test run page is displayed.
Leave the default settings.
Counter sets are gathered on computers that you specify. The association between a counter set and a computer that is used during a load test is a counter set map. For example, the Web server that you are testing might have ASP.NET, IIS, and .NET application counter set mappings.
You can select the computers to monitor during test runs by choosing Add Computer and typing the name of the server that hosts the non-production Web site that you targeted earlier. By adding the host computer name, you gather performance information that is important in your load test.
Note
On each server that you monitor, you must have sufficient user permissions to run performance monitors. Otherwise, errors are generated.
You can add a separate entry for a computer that hosts the SQL database for the site. If you choose not to add any computers, only local load counters are added to your tests.
You can then select the counter sets that you want to monitor. A set of predefined counter sets that add specific performance monitors to your load test are displayed which includes Application, ASP.NET, .NET Application, IIS and SQL.
For more information, see Specifying the Counter Sets and Threshold Rules for Computers in a Load Test and Walkthrough: Using a Test Controller and Test Agents in a Load Test.
Choose Next.
To edit run setting for load test
The Review and edit run settings for a load test page is displayed.
Select Load test duration and then set Run Duration to 2 minutes in order to smoke test your load test.
When you build your Web performance tests and load tests, it is a good practice to validate that everything is configured correctly and running as expected by running a short, light load test. This process is known as smoke testing.
Run settings are a set of properties that affect an entire load test. The run settings determine the length of the test, warm-up duration, maximum number of error details reported, sampling rate, description, whether to save the log on a load test failure, and the validation level. The run settings should reflect the goals of your load test.
For more information, see Configuring Load Test Run Settings.
Choose Finish. Your Load test is opened in the Load Test Editor.
Using the Load Test Editor to Add a Threshold Rule to the Load Test
To add a threshold rule to the load test
In the Counter Sets node, expand the LoadTest counter set node and then expand the Counter Categories folder node.
Expand the LoadTestPage counter category node and then expand the Counters folder node.
Right-click the Avg Page Time counter node and select Add Threshold Rule.
The Add Threshold Rule dialog box is displayed.
Under Select a rule, leave the Compare Constant rule selected.
Under Properties for selected rule, in the Options category, set Alert If Over to True.
Under the Threshold Values category, set the Warning Threshold Value to 3 and the Critical Threshold Value to 4.
Choose OK.
The Avg Page Time counter has a Threshold Rules folder added under it with the new rule.
Running the Load Test and Enable Threshold Violations on the Graph
After you have created the Load test, run it to view how your Web site responds to the load simulation. While the load test is running, you can start some initial analysis in the Load Test Analyzer window.
To run the load test
With a Load test open in the Load Test Editor, choose the green Run button. Your load test starts to run in the Load Test Analyzer in the Graphs view.
While the test is running, choose the Show Legend drop-down list button on the toolbar and select Show Threshold Violations On Graph.
If your test simulation exceeds any thresholds, icons appear in the tree control nodes to indicate a threshold violation. Errors have a red circle overlay and warnings have a yellow triangle overlay.
When you see a threshold violation icon appear on the Graphs view's Page Response Time graph, in the Load Test Analyzer's toolbar, choose Add Analysis Notes.
The Analysis dialog box is displayed.
In the Description text box, type Threshold violation.
In the Analysis test box, type Suspected code defect in Red.aspx.cs file.
The comment will be permanently saved with the load test results.
After the load test is finished running, the load test results are presented in a separate tab displaying LoadTest1[time] in the Summary view in the Load Test Analyzer.
Analyzing the Load Test
After the load test is finished, you can continue further analysis of the load test results. For more information, see Load Test Analyzer Overview.
To analyze the load test using the Load Test Analyzer
In the Summary view, scroll down to the table titled Errors and choose either the Http Error or the Validation Rule Error.
The Load Test Analyzer changes to the Tables view with the Errors table displayed and the rule type that you clicked is selected.
In the row for the Validation Rule Error rule type, notice the ValidateResponseurl listed under the SubType error column. This threshold violation was caused by the following highlighted code that you added to the Red.aspx.cs file which randomly causes a mock page delay for up to five seconds:
protected void Page_Load(object sender, EventArgs e) { Random rnd = new Random(); int result = rnd.Next(5000); //To emmulate various page times up to 5 seconds. Thread.Sleep(result); if (result < 500) Response.Redirect("NOWHERE"); //10% chance to cause an HTTP 404 error. }
This mock delay can potentially violate both the Warning Threshold Value of 3 and the Critical Threshold Value of 4 you specified earlier in the walkthrough. The warning icons are displayed as yellow triangles with an exclamation point in them and the critical violation icons are displayed as red circles with an X in them.
In the row for the Http Error error type, notice the 404 - NotFound under the SubType error column. This was caused by the following highlighted code that you added to the Red.aspx.cs file. This code produces a ten per cent chance of redirecting to a nonexistent page, which causes the error:
protected void Page_Load(object sender, EventArgs e) { Random rnd = new Random(); int result = rnd.Next(5000); //To emmulate various page times up to 5 seconds. Thread.Sleep(result); if (result < 500) Response.Redirect("NOWHERE"); //10% chance to cause an HTTP 404 error. }
Under the Count column, choose the link the number for the Validation Rule Error rule type.
The Load Test Errors dialog box is displayed.
Scroll to the right and under the Details column, choose the TestLog link.
The Web Performance Test Viewer opens in a separate tab displaying the ColorWebTest associated with the error.
Choose Close on the Load Test Errors dialog box.
Select the LoadTest[time] tab to go back to the Load Test Analyzer that displays the load test results.
In the Counters panel, observe that the Scenario basic stress node has one of the threshold warning icons on it. Expand the node until you get to the Avg Page Time counter that was impacted by the code that caused the threshold violations.
In the Graphs view, notice that the threshold violation icons are also displayed for the threshold violations appearing in the Page Response Time graph.
Choose the plot line that has the violation icon on it.
The plot line is bolded and the Avg Page Time counter is highlighted in the Graphs view Legend for the Red (Reporting name added in previous walkthrough) request.
Notice that the Max column for the Avg Page Time counter exceeds the threshold you specified.
Next Steps
In this walkthrough, you created a load test using ColorWebApp Web Application and the Web performance test ColorWebTest.webtest and learned how to start some fundamental analysis practices.
To learn how to analyze the load test further by using the virtual user details chart, see Walkthrough: Using the Virtual User Activity Chart to Isolate Issues.
To learn how to distribute the load test across multiple machines using test controllers and test agents, see Walkthrough: Using a Test Controller and Test Agents in a Load Test.
See Also
Tasks
Walkthrough: Recording and Running a Web Performance Test
Walkthrough: Creating a Coded Web Performance Test
How to: View Web Page Response Time in a Load Test Using the Load Test Analyzer
Concepts
Specifying the Counter Sets and Threshold Rules for Computers in a Load Test
Load Test Results Summary Overview
Analyzing Threshold Rule Violations in Load Tests Using the Load Test Analyzer
Analyzing Load Test Results in the Graphs View of the Load Test Analyzer
Analyzing Load Test Results and Errors in the Tables View of the Load Test Analyzer
Other Resources
Step 4 - Specifying Run Settings in the New Load Test Wizard
Editing the Test Mix to Specify Which Web Browsers Types in a Load Test Scenario
Specifying Virtual Network Types in a Load Test Scenario
Editing Load Test Scenarios Using the Load Test Editor
Editing Load Patterns to Model Virtual User Activities
Editing Text Mix Models to Specify the Probability of a Virtual User Running a Test
Creating Load Tests Using the New Load Test Wizard
Editing Text Mix Models to Specify the Probability of a Virtual User Running a Test