Posts Tagged ‘VuGen’

Question: Using standard web vusers to test web services

Friday, December 28th, 2007

Subject: HTML return value

Hi Stu, you probably know the answer,

what I need to know if there is an option in Vugen to run a url and to save the url content to a string, something like XML apis in Vugen.
Later I can parse the string to see if I got the right value.
There is surely an add-on to web_url to save the return value to a string.

and I need to save it as a variable in Vugen and not writing it to a file.

Tell me if you know if it achievable.

Thanks
Txxxx

Here is some example code…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// save headers to a parameter
web_save_header(REQUEST, "ParamRequestHeader");
web_save_header(RESPONSE, "ParamResponseHeader");
 
// save entire body to a parameter
web_set_max_html_param_len("262144"); // default max length is 256 characters
web_reg_save_param("ParamResponseBody", "LB=", "RB=", "Search=Body", LAST);
 
// check that page contains expected value
web_reg_find("Text=Google", LAST);
 
web_url("Google",
"URL=http://www.google.com.au/",
"TargetFrame=Main",
"Resource=0",
"RecContentType=text/html",
"Snapshot=t3.inf",
"Mode=HTTP", // If this is HTML, then ParamResponseBody will contain the most recently downloaded item on the page (eg/ a GIF).
LAST);       // but note that this means that the resources referenced on the page will not be downloaded.
// An easier way to do this is to define a left and right boundary around the item that you want to check.
 
lr_output_message("# Request Header:\n %s", lr_eval_string("{ParamRequestHeader}"));
lr_output_message("# Response Header:\n %s", lr_eval_string("{ParamResponseHeader}"));
lr_output_message("# Response Body:\n %s", lr_eval_string("{ParamResponseBody}"));

thanks stu, look promising, my HTML return code going to be in XML format so I will probably going to use XML api to find a specific values.

Thanks
Txxxx

If you are using this with web services, you just need to use…

1
2
3
// save entire body to a parameter
web_set_max_html_param_len("262144"); // default max length is 256 characters
web_reg_save_param("ParamResponseBody", "LB=", "RB=", "Search=Body", LAST);

…then you can use the lr_xml functions to extract values from the parameter containing the SOAP body.

Question: SAPGUI script fails on second iteration

Friday, December 28th, 2007

Subject: Help wanted in SAP with LR..

Hey Stuart,

I Guess u have got good experience in LR with SAP…
I got into a problem in my work place.. hope u can figure it out.. pelase let me know if u have a solution for his..

I created a Script for R/3, ( Order to Cash ) which will have 10 materials in a single transaction..
When i run the script with 1 Iteration, it is successfull.

But when i run it with 2 Iterations,, its bouncing from the program..
This happens even in Controller…

So please let me know if there is a solution for this..

Vxxxxx.

You need to make sure that the Action part of your script starts and ends in the same place (and with the same state) in your application.

If the screen is different on the second iteration, your script will probably fail.

Note that sometimes the screen looks the same, but object references are different. You can check this by recording two iterations of your business process in a single script and comparing iteration 1 with iteration 2 (including the object IDs).

Hey Stuart,

What you said was absolutely right..

We resolved the issue by adding a set focus function in the loop..so that on each and every iteration, it comes back to the focus..

Thanks a lot!

Question: Monitoring and alerting with VuGen?

Friday, December 28th, 2007

I frequently receive emails with LoadRunner-related questions. I try to reply to questions when I have time. Maybe posting my answers to MyLoadTest will be an incentive for me to answer more questions, and maybe it will save other people some time.

Subject: Sending email from loadrunner script

Hi Stuart,

We would like to run a LoadRunner script (HTTP WEB Protocol) which will send an email to the user whenever the transaction response time for web page is more than the specified time, or when the application is down for some reason. Basically we would like to monitor the application continuously. How can we achieve this using LoadRunner? Or can you suggest the best solution for monitoring application which would send email notifications to the monitoring team.

Thanks,
Rxxx

The best solution for monitoring a web application’s availability and performance is going to be HP Business Availability Center (BAC). BAC has a component called Business Process Monitor (BPM). BPMs are VuGen scripts that create synthetic transactions against your application. BAC handles the alerting, collection of historical data, and dashboard functionality.
(more…)

Question: How to record a JDBC application with VuGen?

Tuesday, December 11th, 2007

Subject: LR JDBC Protocol

Hi Stuart,

I have a Java Swing-based client that communicates directly with a database server using JDBC. What are my options for recording this application with LoadRunner

Thanks,
Jxxxx Cxxxx.

As you probably noticed, there is no native vuser type which will record your application successfully. Fortunately, you still have several options for recording your application.

Option #1 – Winsock (a bad option)

If you record your application with a Windows Sockets vuser, you will see uninteligible data being sent and received.

Just because you can record something with a Winsock vuser doesn’t mean it is a good idea to try to create a script with this vuser type. The rule-of-thumb is don’t try it unless you can understand what you have recorded at a glance. This means avoid any incomprehensible binary formats and only use Windows Sockets recording for the simplest text-based protocols.

Option #2 – Citrix or Terminal Services

Citrix vusers (and, with the release of LoadRunner 9.0, Terminal Services vusers) are kind of like a get out of jail free card for applications that are difficult to script. Rather than recording the network traffic between your client and the server, these record the traffic between your Citrix client and the server that is running your application client, giving you scripts that describe what is happening to the GUI (e.g. ctrx_mouse_double_click(), ctrx_sync_on_window() etc.)

The downside to this approach is that you will…

  • need to be licensed for LoadRunner Citrix (or Terminal Services) vusers.
  • need to have access to a server to run many Citrix sessions on. As you are adding another layer to your test, you must ensure that the Citrix server is not the bottleneck when running your load test.
  • need to have enough Citrix licenses to run your required number of virtual users.

Option #3 – QuickTest Pro vusers

LoadRunner has an option to run QuickTest Pro scripts instead of scripts created with VuGen. As with the Citrix vusers, your scripts are interacting with the GUI of the application you are creating the script for, so you will never have to worry about any difficult correlation situations.

The downsides are…

  • You need a special LoadRunner license.
  • You will need a separate QTP license for each vuser you intend to run; e.g. if you want to run 100 virtual users, you will need 100 QTP licenses. This rapidly becomes expensive.
  • You will only be able to run 1 vuser per load generator, so to run 100 virtual users, you may need to find 100 workstations and install QTP on them. You can increase this slightly by fiddling with VMWare or Terminal Services, but you will still need lots of generators.
  • As it operates through the GUI, it requires extra time to identify objects. Using WinRunner vusers in the past, I would get radically different response measurements between my WinRunner vusers and my web vusers.

Option #5 – Buy from a third-party

On June 13 2007, Clay Roach from J2EE 911 announced that they would be releasing a LoadRunner JDBC protocol through the HP partnering program.

J2EE 911 announces HP LoadRunner and HP Performance Center protocol extensions for the Java/J2EE platform – including the first pure JDBC Protocol which can be used in conjunction with existing HP LoadRunner scripts to test and validate database data on any database that supports JDBC. The JDBC protocol will allow customers to harness their existing investments in HP Quality Management and enable quality assurance (QA) and development teams to easily collaborate and ensure scalability of their Java/J2EE applications.

The new protocol hasn’t been officially released, but Clay will be happy to discuss licensing options for this product, and may make an early release available to you if you ask nicely.

Option #4 – Java recording with Custom Hooks

The Rmi-Java and Corba-Java vuser types (which I have written about previously) behave differently to other vuser types. They hook into the JVM and record the method calls and arguments to the methods, and generate a Java-based script with the same API calls that your application makes.

The RMI and CORBA methods that LoadRunner hooks to record these scripts can be found in \LoadRunner\dat\rmi.hooks and \LoadRunner\dat\corba.hooks.

An example hook might look like this…

[CORBA_2_3-ORB-init1]
;---------- ORB.init ----------
class      = com.sun.corba.se.internal.corba.ORB
method     = init
signature  = ()Lorg/omg/CORBA/ORB;
cb_class   = mercury.corba.CORBASupport

This hook instructs LoadRunner to hook (add extra code to the class as it is loaded to record method calls and object values) the init method in the ORB class in the com.sun.corba.se.internal.corba package.

It is possible to define your own hooks in \LoadRunner\dat\user.hooks

; This is a sample hook -

[Hook-Name]
;---------- ClassName-MethodName --------
class      = MyPackage.MyClass
method     = MyMethod
signature  = ()V
cb_class   = mercury.ProtocolSupport
general_cb = true

When choosing which classes and methods to hook, you will generally pick any which send network traffic, so for an application which communicates using JDBC, you would choose all of the JDBC methods (which can easily be found in the java.sql and javax.sql Javadocs).

There is further information in the Hooking “General” Java API calls with LoadRunner document, which was in the Mercury Support knowledgebase until HP took it down.

I would not advise that you try this approach unless you are competent at programming with Java.