atlanta mercury users group how to performance test.net and.net web services february 18, 2003 caleb...

32
Atlanta Mercury Users Group How to Performance Test .NET and .NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Upload: dinah-franklin

Post on 26-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Atlanta Mercury Users Group

How to Performance Test .NET and .NET Web

ServicesFebruary 18, 2003Caleb BillingsleyOrasi Software

Page 2: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Agenda

Introduction to .NET How will .NET Impact Testing Mercury .NET Support Load Testing Windows Forms Introduction to Web Services Load Testing Web Services with .NET

Page 3: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

.NET and Mercury Products

Page 4: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

What is .NET?The .NET Framework is a new computing platform that simplifies application development in the highly distributed environment of the

Internet. Objectives of .NET:

*To provide a consistent object-oriented programming environment whether object code is stored and executed locally, executed locally but Internet-distributed, or executed remotely. *To provide a code-execution environment that minimizes software deployment and versioning conflicts. *To provide a code-execution environment that guarantees safe execution of code, including code created by an unknown or semi-trusted third party. *To provide a code-execution environment that eliminates the performance problems of scripted or interpreted environments. *To make the developer experience consistent across widely varying types of applications, such as Windows-based applications and Web-based applications. *To build all communication on industry standards to ensure that code based on the .NET Framework can integrate with any other code.

Page 5: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

.NET Framework

Page 6: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Uses of .NET Applications

Windows Forms Windows Forms is the new platform for Microsoft Windows application development, based on the .NET Framework. This framework provides a clear, object-oriented, extensible set of classes that enables you to develop rich Windows applications.

Web Services Web Services provide an easy to use ‘API’ that is web based to query and retrieve information such as stock quotes, airline schedules, weather, etc.

ASP.NETASP.NET is the next generation of ASP applications for Microsoft. The single biggest advantage is compiled vs. interpreted. Resulting in greater scalability.

Web FormsWeb Forms are an ASP.NET technology that you use to create programmable Web pages.

Traditional Application (CS, Web, etc)

Page 7: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

What Does .NET mean to Testing

.NET creates some new challenges. Systems are more distributed than ever and often you can’t load test every piece. You might have to build Web Service Stubs or have a developer do this to load test an application.

New correlation techniques are required for Web / browser based .NET applications

Given how distributed .NET can become, the ability to Load Test individual pieces will be essential and that will require the .NET LR Add-in

Some .NET Web Applications will require very little change in techniques to test.

Page 8: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

How Does LoadRunner Support .NET

.NET Web apps can be tested in the Normal Web Manner with a few extra correlations.

To Test .NET applications that aren’t based on a web page you will need LoadRunner .NET support. To install the add-in download from

http://www-heva.mercuryinteractive.com/solutions/technologies/net/

Page 9: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Mercury’s .NET Web Page

Page 10: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Supported .NET Environments

Includes:*Data and XML Classes (ADO.NET, SQL, Xpath, XML, etc.) *Framework Base Classes (IO, strong, net security, threading, text, reflection, collections, etc.) *Common Language Runtime (debug, exception, type checking, JIT compilers) *Core Windows Platform (Windows XP, .Net Server, Windows DataCenter)

Mercury Interactive's solutions provide support for the following configurations for Microsoft .NET Platform:

Page 11: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Load Testing .NET Windows Forms

Page 12: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Steps for Load Testing .NET Applications

that don’t have Web Interface Install MS Visual Studio .NET before

LoadRunner Add-in Install LR .NET Add-in Create a New Project of type Add code to call .NET Applications either with

GUI or without Add LR transaction and other LR statements Compile and Test Create a Vuser with compiled binary and run in

Controller

Page 13: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Components of Visual Studio .NET Vuser ProjectVuser Menu

Init, Action,

End Sections

Solution Explorer

Debug Output

Page 14: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Accessing LoadRunner .NET

a) VB.NET Vuser

The VB.NET virtual user is defined by the VuserClass interface. This interface is COM-compliant, and contains three public functions characterizing initialization, execution, and termination.

Public Function Initialize() As Long Public Function Actions() As Long Public Function Terminate() As Long

The above functions may be modified, as required. Make sure that the action names in the [CustomActions] section of the project’s .USR file match the actual names. In similar manner, the virtual user interface's name can be customized, as long as it matches the PROGID attribute in the Project's .USR file.

b) C#.NET Vuser

The C#.NET virtual user is defined by the VuserClass interface. This interface is COM-compliant (AutoDual interface), and contains three public functions characterizing initialization, execution, and termination.

public int Initialize()public int Actions()public int Terminate()

The above functions may be modified, as required. Make sure that the action names in the [CustomActions] section of the project’s .USR file match the actual names. In similar manner, the virtual user interface's name can be customized, as long as it matches the PROGID attribute in the Project's .USR file.

c) C++.NET Vuser

The C++ virtual user is defined by three C functions characterizing initialization, execution, and termination.

int Initialize()int Actions()int Terminate()

Page 15: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Accessing the LoadRunner API

Accessing the LoadRunner API in .NET Virtual User Projects

The LoadRunner API for tracking transactions and data-points, displaying log or error messages, etc. may be accessed through either the LoadRunner COM or C interface depending on the project. A VB.NET and C#.NET virtual user should use the "lr" object to access all LoadRunner functionality. This functionality exists in Astra LoadTest as well. For example:

In VB.NET Project:lr.start_transaction "QueryAccount"lr.end_transaction "QueryAccount", lr.PASS

In C#.NET Project:lr.start_transaction("QueryAccount");lr.end_transaction("QueryAccount",lr.PASS);

a C++.NET virtual user should use the lr_* C api to access all the LoadRunner functionality. For example:

In C++ Project:lr_start_transaction("QueryAccount);lr_end_transaction("QueryAccount,LR_PASS);

IMPORTANT: LoadRunner/Astra LoadTest C++ projects must include the lrun.h header file, and lrun50.lib library. To include the lrun.h header file, use the #include <lrun.h> directive. The header file is in LoadRunner's (or Astra LoadTest’s) include directory. The lrun50.lib library is in LoadRunner's (or Astra LoadTest’s) lib directory.

Page 16: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Tips: LoadRunner API in .NET

You can type lr. And the auto-completion will show you all the valid syntax.

Remember you can record users in VBA using the Vugen multi-protocol option. The resulting scripts could then be moved to a .NET user with minimal effort.

Page 17: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Exercise 1: Building your First .NET

User Install LR .NET Add-in from

http://www-heva.mercuryinteractive.com/solutions/technologies/net

Start MS Visual Studio .NET and create a new LoadRunner Virtual User Project

Add a log message to the script that prints out “Hello World, I’m load testing .NET.”.

Execute the script and view the output log file for correctness.

Page 18: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Testing .NET Web Services

Page 19: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

What is .NET Web Services?

What is a Web Service? Simply put, a Web service is an application that

exposes a programmatic interface using standard, Internet-friendly protocols.

Web services are designed to be used by other programs or applications rather than by humans. Programs invoking a Web service are called clients. SOAP over HTTP is the most commonly used protocol for invoking Web services.

Source: http://www.vbws.com/faq/default.aspx

Page 20: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Diagram of Client Invoking Web Service

Source: http://www.vbws.com/tutors/wsdl/wsdl.aspx

Page 21: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Sample .NET Web Service

To view the WSDL (Web Service Description Language) for a Web Service type in the URI with a ?WSDL at the end. Example: http://localhost/Weather/Service1.asmx?WSDL

To try a sample Web Service, open a web browser and type: http://samples.gotdotnet.com/quickstart/aspplus/samples/services/MathService/VB/MathService.asmx

ORhttp://airforceone/Duwamish7vb/service/catalogservice.asmx

Page 22: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Sample WSDL

Page 23: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Sample Web Service Test Page

Page 24: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Testing .NET Web Services

You can record Web Services if you application calls them by using the SOAP or Web Recording Protocol.

You can record a Web Service call by using your Web Browser

You can programmatically Load Test Using a LoadRunner .NET Project by using the LoadRunner .NET Add-in

Page 25: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Testing a Web Service with LR .NET Add-in

Steps:1. Install Visual Studio .NET2. Install LR & .NET Add-in from www.merc-int.com3. Create a new project that is type LoadRunner VB .NET4. Add a Web Reference to .NET Project4. Add a Web Reference to .NET Project5. Add Code in Visual Studio .NET to call Web 5. Add Code in Visual Studio .NET to call Web

ReferenceReference6. Run User & Check Output in window (Extra: Look in 6. Run User & Check Output in window (Extra: Look in

source code directory. Which file will have the output source code directory. Which file will have the output from the Vuser?)from the Vuser?)

7. Compile, put together in a Vuser script and run in controller.

Page 26: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Step 4: Adding a Reference

Select ‘Project -> Add Web Reference’ inside Visual Studio

Paste into the Address Field: http://samples.gotdotnet.com/quickstart/aspplus/samples/services/MathService/VB/MathService.asmx

Press Enter Click ‘Add Reference’

Page 27: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Step 4 Explanation: Using LR .NET Add-in to Test

Web Services Use VS.NET's Project -> Add Web References menu option to access Web services and execute in .NET virtual user projects. VS.NET provides both UDDI auto-discovery capabilities, and direct WSDL parsers for including Web service interfaces and objects. This capability allows developers and tester to quickly test their Web service components and business units as they are being developed or deployed.

The following examples illustrate Trading Web-service access for each project type.

VB.NET Project:Dim trader As New WebReference1.Tradertrader.BuyStocks 1000, "MERQ", "Acc#1234567890", "JohnDoe", "letmein"trader.BuyStocks 5000, "MSFT", "Acc#1234567890", "JohnDoe", "letmein"

C#.NET Project:WebReference1.Trader trader = new WebReference1.Trader();trader.BuyStocks(1000, "MERQ", "Acc#1234567890", "JohnDoe", "letmein");trader.BuyStocks(5000, "MSFT", "Acc#1234567890", "JohnDoe", "letmein");

C++ Project:OnlineInvest.Trader trader;...hrc = trader.BuyStocks(1000, L"MERQ", L"Acc#1234567890", L"JohnDoe", L"letmein");...

VS.NET provides full IntelliSense support for Web Service references included within LoadRunner/Astra LoadTest VB.NET, C#.NET, and C++ Virtual User projects.

Page 28: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Step 5: Add Code to Script

In our sample we were working with a math service. Open the Solution Explorer (toolbar)

Add the following code inside the vuser_init section (the sample should occupy one line)

Dim ws As New LoadRunnerNETClass_Sample1.com.gotdotnet.samples.MathService()

VS Project Name

URI (Locator

for Service)

Method / Service

Page 29: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Step 6: Running your Vuser

Select ‘Build -> Build Solution’ from the menu

Run the Vuser using the ‘Vuser-> Run Vuser’ menu

After the user runs, you can check your output in the Visual Studio .NET output window or the LoadRunner Vugen log file.

Page 30: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

TIP: Web Based .NET Recording Modes in Order

of Preference HTML Mode

User Actions (first choice) Explicit URLs (second choice)

(Non HTML – Do no record unless have correlation data)

URL Mode (create concurrent preference) Web_custom_request MultiProtocol Recorder Programatic Solution with .NET Adding Winsock (Very difficult maybe impossible.)

Page 31: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Resources

http://www.w3.org/ www.merc-int.com Msdn.microsoft.com Learn Web Services http://www.vbws.com/ Great Tutorial http://www.gotdotnet.com/ LoadRunner .NET Readme

Page 32: Atlanta Mercury Users Group How to Performance Test.NET and.NET Web Services February 18, 2003 Caleb Billingsley Orasi Software

Wrap-up!

Questions?

My Contact Information:[email protected]