Export (0) Print
Expand All

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 2010 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.

NoteNote

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.

Open solution

To modify the Red.aspx.cs code to demonstrate threshold violations and errors

  1. In Solution Explorer, expand the ColorWebApp ASP.NET Web application project folder and then expand the Red.aspx node.

  2. Right-click the Red.aspx.cs file and select View Code.

  3. 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.

To start the New Load Test Wizard

  1. In Solution Explorer, right-click the ColorWebAppTest test project node.

  2. Click Add, and then click 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.

  3. Click Next.

To edit settings for the load test scenario

  1. The Edit settings for a load test scenario page is displayed.

  2. 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.

  3. 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.

  4. Click Next.

To edit load pattern setting for the test scenario

  1. The Edit load pattern settings for a load test scenario page is displayed.

  2. 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.

  3. Click Next.

To select test mix model for the scenario

  1. The Select a test mix model for the load test page is displayed.

  2. 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 Test Mix Models to Specify the Probability of a Virtual User Running a Test.

  3. Click Next.

To add the ColorWebTest.webtest Web performance test to the scenario

  1. The Add tests to a load test scenario and edit the test mix page is displayed.

  2. Click Add to select tests.

    The Add Tests dialog box appears.

  3. In the Available Tests pane, select the ColorWebTest Web performance test and click the arrow to add it to the Selected Tests pane.

  4. Click 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 How to: Create a Test Mix in the New Load Test Wizard.

  5. Click Next.

To select network mix for test scenario

  1. The Add network types to a load test scenario and edit the network mix page is displayed.

  2. 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 click 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.

  3. Click Next.

To select browser mix for test scenario

  1. The Add browser types to a load test scenario and edit the browser mix page is displayed.

  2. 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 click the drop-down arrow next to each row under Browser Type. If you configure the browser mix to use more that one browser type, you can use the sliders to specify the browser type distribution.

    For more information, see Specifying Web Browsers Types in a Load Test Scenario.

  3. Click Next.

To specify computers to monitor with counter sets during load test run

  1. The Specify computers to monitor with counter sets during load test run page is displayed.

  2. 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 clicking 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.

    NoteNote

    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 for Computers in a Load Test and Walkthrough: Using a Test Controller and Test Agents in a Load Test.

  3. Click Next.

To edit run setting for load test

  1. The Review and edit run settings for a load test page is displayed.

  2. 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.

  3. Click Finish. Your Load test is opened in the Load Test Editor.

To add a threshold rule to the load test

  1. In the Counter Sets node, expand the LoadTest counter set node and then expand the Counter Categories folder node.

  2. Expand the LoadTestPage counter category node and then expand the Counters folder node.

  3. Right-click the Avg Page Time counter node and select Add Threshold Rule.

  4. The Add Threshold Rule dialog box is displayed.

  5. Under Select a rule, leave the Compare Constant rule selected.

  6. Under Properties for selected rule, in the Options category, set Alert If Over to True.

  7. Under the Threshold Values category, set the Warning Threshold Value to 3 and the Critical Threshold Value to 4.

  8. Click OK.

  9. The Avg Page Time counter has a Threshold Rules folder added under it with the new rule.

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

  1. With a Load test open in the Load Test Editor, click the green Run button. Your load test starts to run in the Load Test Analyzer in the Graphs view.

  2. While the test is running, click 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.

  3. When you see a threshold violation icon appear on the Graphs view's Page Response Time graph, in the Load Test Analyzer's toolbar, click Add Analysis Notes.

    The Analysis dialog box is displayed.

  4. In the Description text box, type Threshold violation.

  5. 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.

  6. 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.

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

  1. In the Summary view, scroll down to the table titled Errors and click either the Http Error or the Validation Rule Error.

  2. The Load Test Analyzer changes to the Tables view with the Errors table displayed and the rule type that you clicked is selected.

  3. 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.

  4. 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.
            }
    
  5. Under the Count column, click the link the number for the Validation Rule Error rule type.

    The Load Test Errors dialog box is displayed.

  6. Scroll to the right and under the Details column, click the TestLog link.

  7. The Web Performance Test Viewer opens in a separate tab displaying the ColorWebTest associated with the error.

  8. Click Close on the Load Test Errors dialog box.

  9. Select the LoadTest[time] tab to go back to the Load Test Analyzer that displays the load test results.

  10. In the Counters panel, observe that the Scenaro1 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.

  11. In the Graphs view, notice that the threshold violation icons are also displayed for the threshold violations appearing in the Page Response Time graph.

  12. Click the plot line that has the violation icon on it.

  13. 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.

  14. Notice that the Max column for the Avg Page Time counter exceeds the threshold you specified.

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.

Community Additions

ADD
Show:
© 2014 Microsoft