How to make a Load Testing with Visual Studio 2012

Preview:

Citation preview

OUTLINE

About Load Testing Performance testing Stress testing Load testing

Create Visual Studio Load Testing Solution Add Web Perfomance Testing

Create by Wizard(record action) Create by Code

Add Load Testing Configure Scenario setting Configuration Run setting

Open Load Testing Report

Tips for setting

One more thing about Load Testing

PERFORMANCE TESTING

效能測試(Performance testing)

效能測試的目標不是要找缺陷(bug),而是要消除瓶頸和替未來的回歸測試(regression tests)建立一個底線,執行效能測試的進行是在一個謹慎控制的量測和分析流程內,理想上軟體是在夠穩定的情況下進行測試,因此測試的過程可以很順利的進行。定義期望組對有意義的效能測試而言是必要的。

Concurrent user

在線的使用者或HTTP連線的期望負荷

Response time

允許的回應時間

壓力測試(Stress testing)

藉由超出系統資源或拿走系統資源(有時被稱為「負面測試」(negative

testing))的情況下測試以嘗試中斷系統,主要的目的在確保系統失效和正常地回復。

效能測試需要一個受控制的環境和重覆量測,壓力測試則隨興地引發混亂和不可預測,如:

倍數的單位數目(Base Amount)的在線的使用者/HTTP連線數量

隨機地關閉和重啟網路上連接到伺服器的交換機/路由器的埠(例如透過SNMP命令)

關閉資料庫再開啟

在系統執行時重建RAID陣列

執行消耗網頁/資料庫伺服器資源(CPU、記憶體、磁碟、網路)的程序並確保程式可以正常執行

LOAD TESTING

負載測試(Load testing)

負載測試是效能測試與調校的一部份,在這個前題下,這意味藉由自動工具不斷地增加負載到系統,對網頁程式而言,負載被定義成在線使用者或HTTP連線。

定義成提供系統所能執行最大工作量下運作測試的流程,負載測試通常被稱為「容量測試」、或「壽命(longevity)/耐力(endurance)測試」。

負載測試的目標

揭露粗略測試的缺陷,如:記憶體控制的缺陷、記憶體洩露(leaks)、緩衝區溢位(buffer overflows)等

當效能測試時確保應用程式滿足效能建立的底線,這個是藉由執行回歸測試完成以確保應用程式的特定最大負載。

TEST CONTROLLER AND TEST AGENT

CREATE VISUAL STUDIO LOAD TESTING SOLUTION – PROCESS STEP

1. Install Visual Studio 2012(need install SQL Server 2008 Express or higher)

2. Create Web Performance and Load Test solution

3. Modify and complete Web Performance Test Record action by browser Remove unnecessary request item Add necessary Validation Rule Add Data Source and bind data to input Add Context Parameters to binding URL Configure response time goal, think time and other setting on each request item

4. Added Load Test to project and added existing Web Performance Test Added New Load Test to project Set Test Mix, Browser Mix, Network Mix Set Load Pattern Configure Run Settings

5. Added Counter(optional)

CREATE VISUAL STUDIO LOAD TESTING SOLUTION – STEP 1

CREATE VISUAL STUDIO LOAD TESTING SOLUTION – STEP 2

MODIFY AND COMPLETE WEB PERFORMANCE TEST – STEP 1

MODIFY AND COMPLETE WEB PERFORMANCE TEST – STEP 2

MODIFY AND COMPLETE WEB PERFORMANCE TEST – STEP 3

MODIFY AND COMPLETE WEB PERFORMANCE TEST – STEP4

MODIFY AND COMPLETE WEB PERFORMANCE TEST – STEP 5

MODIFY AND COMPLETE WEB PERFORMANCE TEST – STEP 6

MODIFY AND COMPLETE WEB PERFORMANCE TEST – STEP 7

MODIFY AND COMPLETE WEB PERFORMANCE TEST BY CODE

*.webtest file can generate to

code, but code can’t revert

to .webtest file

ADD .LOADTEST FILE TO PROJECT

CONFIGURE .LOADTEST FILE TO PROJECT – SCENARIO

• Once you create .loadtest file, it will added default scenario and you can

add more with UI(right click to add).MSDN:Load Test Scenario Properties

CONFIGURE .LOADTEST FILE TO PROJECT – SCENARIO - 1

From Wizard Configure setting

Think times are used to simulate human behavior that causes people to wait between interactions with a Web site.

The think profile is a setting that applies to a scenario in a load test. The setting determines whether the think times that are saved in the individual Web performance tests are used during the load test.

If you want to use think times in some Web performance tests but not in others, you must place them in different scenarios. MSDN:Editing Think Times to Simulate Website Human Interaction Delays in Load Tests Scenarios

CONFIGURE .LOADTEST FILE TO PROJECT – SCENARIO - 2

The load pattern properties specify how the simulated user load is adjusted during a load test.

Visual Studio Ultimate provides three built-in load patterns: constant, step, and goal-based.

MSDN:Editing Load Patterns to Model Virtual User Activities

From Wizard Configure setting

CONFIGURE .LOADTEST FILE TO PROJECT – SCENARIO - 3

Specifies the test mix model that is used for the load test.

MSDN:Editing the Test Mix to Specify Which Web Browsers Types in a Load Test Scenario

MSDN:Editing Text Mix. Models to Specify the Probability of a Virtual User Running a Test.

From Wizard Configure setting

CONFIGURE .LOADTEST FILE TO PROJECT – SCENARIO - 4

Specifies the network mix for the load test. You can specify which network types to include and

their load distribution.

MSDN:Specifying Virtual Network Types in a Load Test Scenario.

From Wizard Configure setting

CONFIGURE .LOADTEST FILE TO PROJECT – SCENARIO - 5

Specifies the Web browser mix for the load test. You can specify different Web browser types

and their load distribution.

MSDN:Editing the Test Mix to Specify Which Web Browsers Types in a Load Test Scenario.

From Wizard Configure setting

CONFIGURATION RUN SETTING

OPEN LOAD TESTING REPORT

Open results of recently run tests

From the VIEW menu>Windows > Test Results> Select Run list>choose the test run you

want to open or choose Manage test runs to browse for a test from the Test Runs window.

(Optional) In the Result list, right-click a test and choose View Results to see more

information about that particular test.

(Optional) To view test result details, including any data and diagnostic adapter attachments,

choose Run Details in the toolbar.

(Optional) If you have Office excel 2010 or later, you can generate with excel add-in(guide)

TIP 1 – HOW TO SET USER LOAD WITH GRADUALLY INCREASED

Set it on .loadtest > Load Pattern

For example, to see how your server or servers perform as the user load

increasing to 2,000 users, you might run a 10-hour load test using a step load

pattern with the following properties:

Initial User Count: 100

Maximum User Count: 2000

Step Duration (seconds): 1800

Step Ramp Time (seconds): 20

Step User Count: 100

These settings have the load test running for 30 minutes (1800 seconds) at

user loads of 100, 200, 300, up to 2,000 users.

How to: Specify the Step Ramp Time Property for a Step Load Pattern

TIP 2 – HOW TO BINDING DATA WITH CSV, DB OR CONSTANT

Using {{}} to binding data to your content

CSV or DB

Add data source and select data type

Select "properties"

Set the property to the correct data source field, value is like

"{{DataSource1.Filename#csv.ColumnTitle}} "

Confirm the property binding(reference to page)

Constant

Using Content Text directly(reference to page)

MSDN: Walkthrough: Adding Data Binding to a Web Performance Test (CSV File)

TIP 3 – HOW TO PASS RESPONSE DATA TO NEXT REQUEST

Using Context parameters to store data and binding it to next.

TIP 4 – HOW TO MAKE BINDING DATA PICK UP RANDOM

If your source have grant data and you want pick up is random, you can

set it on data source directly.

TIPS 5 – BINDING DATA SOURCE WITH CSV FILE BUT EXECUTE

WITH ERROR

If your Data Source binding is setting correct by execute show with can

found existing Context Parameters, it might Visual Studio known bug

with binding data.

Solution is update your .csv file with another title to make binding with

correct encoding.

You can confirm encoding is correct by generate code on .webtest file

COWORK WITH TEST CONTROLLER AND TEST AGENT

REMOTE CONTROLLER TO DOING LOAD TESTING

LOAD TESTING IN THE CLOUD (WINDOWS AZURE) - GRAPHIC

LOAD TESTING IN THE CLOUND (WINDOWS AZURE) - FLOW

HOW TO LOAD TESTING IN THE CLOUD(USING AZURE) –

HANDS ON LAB

1. Download sample

2. From the Solution Explorer, open SampleWebTest.webtest

3. Select the URL listed in SampleWebTest.webtest file.

4. Go to the properties list and update the property labelled 'Url' to your

app's/website's URL.

5.From the team explorer, please connect to your Visual Studio Online

account(Register here).

6. Open the SampleLoadTest.loadtest file. From the 'Load Test' menu, select

'Run' -> 'Selected Test'

7. The Load test from the cloud will now start and show you graphs of how your

application is performing during the load test.

visual-studio-online

5 FREE Basic user licenses

FREE work item tracking for all users

FREE 60 minutes/month of build

FREE 15K virtual user minutes/month of load

testing

PREVIEW application monitoring and

analytics

REFERENCE

效能/負載/壓力測試的分別(Performance vs. load vs. stress testing)

Setting Up Test Machines to Run Tests or Collect Data

How to: Save and Open Web Performance and Load Test Results in Visual

Studio

Load testing in the cloud

Configure your project to run load tests in the cloud

Recommended