Using a LoadRunner workload as a model for a Rational workload
by
Yuriy
Veytsman
Level:
Intermediate
Works with:
Rational, Lotus Team Workplace
Updated:
17-Nov-2003
Over the past several years, Lotus has invested vast amounts of time and effort developing load, scalability, and performance tests for evaluating and tuning our products. The primary tools for these efforts (in addition to internally developed programs) have been Mercury LoadRunner, Segue SilkPerformer, and Server.Load from the NotesBench Consortium. These tools utilize
workloads
(sometimes referred to as scenarios or test scripts) that simulate user activity and form the core of our evaluation and testing work. As you may have already learned from reading several recent articles and Performance Perspectives columns, IBM recently acquired Rational Software, an industry-leading producer of software testing and analysis tools. Since then, we have embarked on a plan to use Rational tools to create our workloads. At the same time, we still want these workloads to simulate the same types of user activities as the workloads we've already developed using other tools and methods. This helps ensure consistency in our test and analysis results.
This article explains how we used an existing LoadRunner workload for Lotus Team Workplace (QuickPlace) as a blueprint for an IBM Rational Performance Tester workload. In the example we describe, we transform an existing, simple LoadRunner test into an identically performing Rational Robot test script with a minimal amount of change to the workload actually generated during test execution (although given the differences between the two tools, some modifications were unavoidable). The workload we discuss emulates a very limited HTTP-based load on a Lotus Team Workplace server. (You can download the complete code for the workload from the
Sandbox
.)
Our goal is to share our experiences migrating a simple LoadRunner workload to Rational. However, we do not cover all possible issues that may result from working with longer and more complex workloads. This would require far more explanation than a single article can provide. However, we feel our observations and advice should help others who may be interested in adopting Rational tools both to migrate existing HTTP-based workloads and to build workloads from scratch.
This article assumes that you're familiar with LoadRunner and workloads in general. And although some knowledge of Rational tools may be helpful, we hope readers new to Rational can still learn from this article.
Visit the
Rational Developer Domain
for articles and related information about Rational products.
Our original Lotus Team Workplace user workload
To build our Rational workload, we started with a Lotus Team Workplace (LTW) workload that we created previously in LoadRunner. We used this workload as a "pattern." Following this pattern helped save time because it showed us how all the components of the workload fit together. Also, this allowed us to examine both the Rational and LoadRunner scripts in parallel and to determine how well their variables correlated.
The LoadRunner workload we migrated to Rational performs the following LTW user actions:
Log in.
Sleep for 30 minutes (allowing a large number of users to log in).
Go to MyPlaces.
Flip each page to see all pages with LTWs names to which the user belongs.
Log out.
There are two primary ways we can re-create this workload with Rational Robot:
Record and playback actual user activity with the Rational Robot record function
In this method, we estimated that 90 percent of our work would be performed by Rational Robot's record feature. We would then need to "parameterize" the script to make its variables dynamic rather than static, using the automated datapooling provided by Rational Robot. The one drawback to this technique is that very complicated scripts with lots of variables require a significant amount of manual tweaking. (For an example of how we used the Rational Robot record function to create a workload, see the Performance Perspectives column, "
Creating a Lotus Workplace Messaging test scenario with Rational Suite TestStudio
."
Create the workload with Rational Robot's VU (Virtual User) programming language
This method is especially suited for unsupported protocols such as SMTP. It also offers better error and failure handling, as well as debugging. And it's possible to simply translate an existing LoadRunner workload into a Rational Robot workload one line at a time. (The languages used to build both LoadRunner and Rational Robot scripts closely resemble the C programming language, so they are very similar.) However, creating scripts with VU usually involves more work than using the record function. It also requires the builder of the script to be an experienced programmer and to understand the application being tested. The recent
technical article, "
Developing an LWM SMTP workload with Rational Suite TestStudio
," explains how to build a workload with VU.
Because our original LoadRunner script is relatively simple, we decided to use the Rational Robot record function to re-create it. To do this, we followed the same basic procedure we used when creating scripts with LoadRunner:
Record network activity created by the user.
"Parameterize" the variables.
Correlate workload flow programmatically.
Using the Rational Robot record feature
As we mentioned in a
previous Performance Perspectives column
, IBM Rational Performance Tester includes several integrated components, each with a specific purpose in the performance testing workflow:
Rational Robot provides script recording and editing.
Rational TestManager provides test scheduling, test reporting, and test management.
Rational TestAgent provides concurrent execution of test scripts on multiple Windows and UNIX machines.
To duplicate our LoadRunner script, we used Rational Robot to record LTW user activity, using timers to measure response time for transactions. We also added comments to distinguish each transaction. Before recording the activity, we set the following record options in Rational Robot:
Method
:
API recording
Generator: Use datapools
Generator Filtering: Auto Filtering - HTTP
The result was a script that resembles a LoadRunner recording log, as shown in the following:
HTTP_CONN_DIRECT,
"POST /quickplace/" + quickplace +"/Main.nsf?Login HTTP/1.1\r\n"
"Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, applicat"
"ion/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */"
"*\r\n"
"Referer: " + SgenURI_001 + "\r\n"
/* "Referer: http://" + servername + "/quickplace/" + quickplace +"/Main.nsf?Login&Re"
"directTo=%2Fquickplace%2F" + quickplace +"%2FMain.nsf" */
"Accept-Language: en-us\r\n"
"Content-Type: application/x-www-form-urlencoded\r\n"
"Accept-Encoding: gzip, deflate\r\n"
"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)\r\n"
"Host: " + servername + "\r\n"
"Content-Length: 114\r\n"
"Connection: Keep-Alive\r\n"
"Cache-Control: no-cache\r\n"
"\r\n"
"%25%25ModDate="
+ http_url_encode(datapool_value(DP1, "%%ModDate"))+
"&Username="
+ http_url_encode(datapool_value(DP1, "Username"))+
"&Password="
+ http_url_encode(datapool_value(DP1, "Password"))+
"&RedirectTo="
+ http_url_encode(datapool_value(DP1, "RedirectTo"))+
"\r\n";
We then needed to modify the script to generalize the specific activity we recorded, to allow it to be used to build a multi-user workload, and to run on different servers with different users and so on. To do this, we "parameterized" the script, changing hard-wired values to variables. This is a fairly simple procedure in Rational Robot.
Building the datapool
We started by creating the following datapool (note that Rational Robot datapools are equivalent to LoadRunner parameters). We created this datapool automatically by using Rational Robot's Datapool service:
DATAPOOL_CONFIG "qp2” DP_SHARED DP_WRAP
{
INCLUDE, "quickplace", "string", "QP";
INCLUDE, "servername", "string", "SW";
INCLUDE, "user", "string", "US";
EXCLUDE, "%%ModDate", "string", "0000000000000000";
EXCLUDE, "Count", "string", "12";
EXCLUDE, "Form", "string", "qpbase";
EXCLUDE, "Form_1", "string", "qpread";
EXCLUDE, "Form_2", "string", "h_RequestContext";
EXCLUDE, "Form_3", "string", "h_StyleSheet";
EXCLUDE, "Form_4", "string", "h_QPLogout";
EXCLUDE, "Password", "string", "somepassword";
EXCLUDE, "RedirectTo", "string", "/quickplace/QP1/Main.nsf";
EXCLUDE, "Start", "string", "12";
EXCLUDE, "TimeStamp", "string", "85256D02006FBB28";
EXCLUDE, "TimeStamp_1", "string", "85256CFB00337223";
EXCLUDE, "Username", "string", "Place Catalog1";
}
In the preceding code:
DP_SHARED specifies that the virtual tester population uses a share pointer into the datapool. Each virtual tester pulls a unique record from the datapool. For example, the first virtual tester to access the datapool uses line 1, the second uses line 2, and so on.
DP_WRAP resumes at the beginning of the access order.
As you can see, we used the INCLUDE statement to enable just three parameters to be used in our script: servername (the name of the user's server), quickplace (the name of the Web site), and user (the name of the simulated user). Note that the Datapool service worked fine for building our simple script. However, more complicated scripts may need to be done manually. See the
Rational documentation
for more information.
Performing open and fetch on the datapool
To use variables contained in the datapool, you must perform open and fetch operations on the datapool as follows:
DP1 = datapool_open ("qp2"); //Open Datapool
datapool_fetch (DP1); //Fetch Datapool
This allows you to access the datapool variables via the function datapool_value (“datapool name”, “variable name”):
usr = datapool_value (DP1, "user");
Putting variables in the URLs
As you can see, all variables in the datapool are strings. To build URLs from these strings, use the following format:
"Host:” +
servername
+ "\r\n”
where
servername
is the variable from the datapool.
Procedures
We recommend that you put sections of code that you use often into separate procedures and include these procedures either in a separate header file or at the top of the main script file. An example of a simple procedure follows:
/* Traverse one page with 12 quickplaces
*/
proc dopages(servername, npages)
string servername;
int npages;
{
for ( i = 1; i <= npages; i++)
{
dopage(servername, i);
}
And you can call your procedure from the main script like this:
dopages (sname, 10);
For detailed information about using procedures, consult the
Rational documentation
.
Handling cookies
In our test case, SSO (single sign-on) is enabled and user authentication kept by LtpaToken, a cookie (created on the fly by the server) that changes for every user and every session. Our original Rational Robot recording produced a hard-coded token that only works for the server on which it was recorded. We, therefore, need a way to change this token, so it can run on other servers. By examining our recording, we see that the token has been set in the header to the value for Set-Cookie. To pick up the token value, we used the function http_header_info ("Set-Cookie"). The http_header_info function scans the headers received by http_header_recv to locate lines beginning with the requested attribute (“Set-Cookie") and returns a string containing the value of this attribute:
LtpaToken =http_header_info ("Set-Cookie");
Using this routine:
if (! match ("([ \r\n]*)$0LtpaToken=(.+)$1", LtpaToken, &result))
{
script_exit ("Can't find token value" + LtpaToken + "\n");
}
helps us pick up the whole token and put its value into the variable result (or exit if no token value exists). Thus, together these two Rational Robot functions work similar to the LoadRunner function web_reg_save_param ().
Print output for debugging purposes
It is always a good idea to print variables to a file to see how they change when you play your script:
fprintf (fd, "servername: %s\n", sname);
We have found routines, such as this one, reliable and simple to implement.
Results
After we finished creating the script, we were eager to run it against the same server we used to run the LoadRunner workload. We measured response time for each script during one hour of simulated activity and found the results of the Rational Robot workload comparable to the LoadRunner workload:
Conclusion
This article describes how to create a Rational script that performs the same actions as a Mercury LoadRunner script. Using Rational Robot, we were able to:
Record user activity.
Parameterize the resulting script.
Correlate the Rational Robot script with the LoadRunner script.
Create a meaningful performance test.
Converting scripts to Rational allows us to take advantage of the integrated toolset and methodology offered by Rational. These tools support the full range of product development from concept to coding to product release. In addition, Rational tools integrate with current and future IBM products
—
a compelling reason for IBM customers to consider adopting Rational tools at their sites.
Bear in mind that we're still new at this. We expect to learn more as we migrate other existing workloads into our expanding Rational environment. As we do, we will likely encounter more comp
lex issues not discussed in this article. However, our simple example demonstrates that migration is in fact possible and doesn't necessarily require a great deal of time and effort. This should be good news to users who have experience with HTTP-based workloads and similar tools and are now considering adopting Rational tools to meet their load and scalability analysis needs. Give it a try and see for yourself!
ABOUT THE AUTHOR
Yuriy Veytsman has been a Staff Software Engineer with IBM/Lotus since the late 1990's, working on projects involving Domino Web Access (iNotes), Discovery Server, Lotus Team Workplace (QuickPlace), and Lotus Instant Messaging (Sametime) testing, and various other responsibilities. Previously, Yuriy was employed developing a variety of software and hardware applications for numerous companies throughout Europe.