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…

// 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…

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

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

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!

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

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 loadrunner script (HTTP WEB Protocol) which will send an email to user Whenever transaction response time for web page is more than specified time or application is down for some reason.Basically we would like to monitor the application continuously. How can we achieve this using loadrunner? or suggest us best solution for monitoring application which would send email notification to 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.

Business Availability Center - End User Management page

The advantage of using BPMs as well as traditional infrastructure-based monitoring is that a BPM will tell you if your web application is really available because it is performing a real business process. Pinging a server every 5 minutes doesn’t tell you that the database service has hung. Requesting just the front page of the website every 5 minutes doesn’t tell you that all of your online store functions are working except the “checkout” function.

As well as alerting on response times which are outside of SLAs, capturing response time data shows historical performance trends - maybe you will see a jump in response times for searches after all those extra products were added to the catalog? Or maybe a slow degradation in response times as more and more old orders sit in the database?

But let’s assume that you are unable to convince your management that they should do things the correct way, and they decide to go with the unreliable but cheap solution of monitoring an application with a copy of VuGen which is running constantly on a workstation.

Problem #1 - stability of the monitor over time

Using VuGen by itself as a monitor is a solution you would have to babysit. You would probably want to restart it every day as logs will accumulate and eventually start slowing everything down.

Problem #2 - accuracy of response time measurements

As well as the possibility of very large logs distorting your response time measurements by slowing down VuGen, running a script in VuGen is far slower than running the same script through the LoadRunner agent (mmdrv.exe which is used by LoadRunner Controller and by BAC). The overhead can be reduced by disabling “Animated Run” and “Output Window”, but there should still be a significant difference.

Problem #3 - historical data

I don’t generally like collecting data if I am not going to keep a copy of it somewhere. I like to see trends over time. Extracting data out of the logs would probably be painful so, if I were doing this, I would probably write some extra code to write to a CSV file so that I could graph the data in Excel.

Problem #4 - email alerting on slow response times

If you have licensed the SMTP vuser type, then you can create a Multiple Protocol (Web + SMTP) script so that you can send emails with your script. Alternatively you might be able to find a command line tool that can send email (like Blat), and call it with the system() function; or you could send an email using a web-based interface - maybe set up a private web service on a completely separate server.

Actually detecting that the response time for a transaction does not meet your SLA would require you to set a timer at the start of each transaction, and write some conditional logic at the end of each transaction e.g. if ((endTime - startTime )> SLA) { raiseAlert(); }. Using BAC is obviously a much more robust way of doing this, and eliminates all of the extra code you would have to write.

Problem #5 - alerting on errors

Alerting on slow response times is reletively simple, but alerting on errors becomes much more complicated with my hacky VuGen solution. The problem is that control is passed from your code back to VuGen and its Run Logic as soon as you fail a Content Check Rule or a web_reg_find. The only way to get around this is to enable the “Continue on error” runtime setting and do all of your error handling manually. This will mean writing big ugly chunks of code like this for every request that you want to check…

lr_continue_on_error(LR_ON_ERROR_CONTINUE);
// Check for known error messages
web_reg_find(”Text=Your session has expired”, “SaveCount=errorSessionExpired”, LAST);
web_reg_find(”Text=A runtime error occurred”, “SaveCount=errorRuntimeError”, LAST);
// Check for message to indicate success (positive text check)
web_reg_find(”Text=Your order has been submitted successfully”, “SaveCount=checkOrderSubmitted”, LAST);

web_submit_data(…); // snip!

if (atoi(lr_eval_string(”{errorSessionExpired}”)) > 0) {
sendEmailAlert(”Error: Session expired for user %s”, lr_eval_string(”{UserName}”));
} else if (atoi(lr_eval_string(”{errorRuntimeError}”)) > 0) {
sendEmailAlert(”Error: Runtime error for user %s”, lr_eval_string(”{UserName}”));
} else if (atoi(lr_eval_string(”{errorSessionExpired}”)) < 1) {
sendEmailAlert(”Error: Text Check failed for \”Your order has been submitted successfully\”.);
}

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

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.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]