Editor's note: This article is part of a library of custom VuC functions developed by performance test engineers to handle special situations encountered in scripting applications. For an overview of the library and links to other custom functions, see "A Library of Custom VuC Functions."
The statuslog procedure is called while a script is executing and writes the command ID, the actual GET or POST, and the HTTP response code for each command to a separate log file for easy viewing and reporting. The statuslog utility automatically inserts a call to the statuslog procedure in all of the correct places in your existing scripts so you don't have to do it manually.
Scrolling through the IBM® Rational® TestManager® test log to
look at every command that failed can be a time-consuming process. Scrolling
through the d00 file can be even more tedious. Getting the information
out of either of those places to compile and report to the development team
requires a lot of manual work. I wrote the statuslog procedure
and the StatusLog utility in an effort to simplify this process.
With this procedure/utility combination, you can instrument your script to create
a log file while your script is running.
By comparison, the LogParse utility parses existing log files from previous test runs. If you don't want the additional step of running this utility as a separate process after test execution, you'll want to use statuslog/StatusLog. But if you prefer to modify your script as little as possible or have existing log files from previous test runs that you want to parse, you'll want to use the LogParse utility.
Using the statuslog/StatusLog combination results in an output file like the sample below that contains the complete object request and the HTTP return code that was sent back from the Web server in response to that request.
GET /psp/GDV01/?cmd=login, HTTP/1.1 200 OK, GET /GDV01/images/footerRight.jpg, HTTP/1.1 304 Not Modified, GET /GDV01/images/ps_logo_blue.gif, HTTP/1.1 304 Not Modified, GET /GDV01/images/topGradientBarBgStripe.gif, HTTP/1.1 304 Not Modified, GET /GDV01/images/tallBgStripe.gif, HTTP/1.1 404 File Not Found, POST /psp/GDV01/?cmd=login&languageCd=ENG, HTTP/1.1 302 Moved Temporarily, |
This information can be used to quickly see if the requested files are being handled as expected by the Web server.
To use this procedure/utility combination, you'll need to have an HTTP script
to modify. First create the statuslog.s script as outlined below
under "Utility code." Then simply execute the statuslog.s
script like you would any other VU script. When the script has finished executing,
return to Robot. From the menu bar choose File > New > Script and enter the
name of the modified HTTP script (this name must be identical to the name you
substituted for "NEWNAME.S" in the statuslog.s script).
Finally, copy and paste the actual procedure code into your script, or type
in the appropriate #include command, and your new script is ready
to be executed.
Once the script is executed, the results will be written out in the o001 file located here:
\\\[Drive\\\]:\\\\[RepositoryName\\\]\TestDatastore\TMS_Builds
\\\\[BuildName\\\]\\\\[SubBuild\\\]\\\\[TestRun\\\]\perfdata\
That file can be opened in either a text editor or in Excel as if it were a .csv file.
This procedure/utility combination works only in conjunction with an existing VU Robot script containing the HTTP protocol.
Here's the code for the statuslog procedure, to be included in the script:
proc statuslog()
{
string str_tmpline, str_tmpline2;
if (strstr(_command, "GET") >0) str_tmpline = substr(_command,
(strstr(_command, "GET")), (strstr(_command, "HTTP")-2));
else str_tmpline = substr(_command, (strstr(_command, "POST")),
(strstr(_command, "HTTP")-2));
str_tmpline2 = substr(_response, (strstr(_response, "HTTP/1.1")),
(strstr(_response, "Date:")-1));
print(str_tmpline +', '+str_tmpline2+', \n');
} |
The statuslog procedure can be placed in each calling script immediately following the #include command, or it can go in a separate .h file referenced by an additional #include command. The procedure can then be put in either the test script section of the repository or the Rational Test include directory. Putting it in the latter location will give you the benefit of not having to copy this procedure into every repository you work with.
int statuslog()
The call to the statuslog procedure takes no input parameters and should be placed in the script following each http_header_recv command associated with the request you want to have logged. This ensures that every request-response code pair is output to the log file.
The statuslog utility simply inserts the line
statuslog();
immediately after every http_header_recv command in an existing script.
Here's the code for the StatusLog utility:
#include <VU.h>
#include <sme\fileio.h>
{
string str_oldscript, str_newscript, str_theline;
result = 1;
str_oldscript = "YOURSCRIPTNAME.S"; //Enter the name of the existing script
here.
str_newscript = "NEWNAME.S"; //Enter the name of the new script here.
oldscript=open(str_oldscript, "r");
newscript=open(str_newscript, "w");
while (result==1){
result = ReadLine(oldscript);
str_theline = NextField();
if (strstr(str_theline, "http_header_recv") >0){
fputs(" " + str_theline + "\n\n", newscript);
fputs("statuslog();" + "\n", newscript);
}
else {
fputs(" " + str_theline + "\n", newscript);
}
}
close(oldscript);
close(newscript);
} |
In the code, replace "YOURSCRIPTNAME.S" with the name of your existing HTTP script and replace "NEWNAME.S" with the name of the new script you're about to create. Then copy and paste this code into a new VU script and save it, as follows:
- Choose File > New > Script from the Robot menu bar.
- Name the script
statuslog, ensure that the VU radio button is selected, and click OK.
- Delete any auto-generated code in the script window.
- Paste the
statuslogcode into the script window. - Click the green checkmark on the main Robot menu bar to compile the script.
statuslog and statuslog are particularly useful for instrumenting new scripts but can also be used to instrument old scripts that will be rerun. I used this procedure/utility combination recently on a client engagement where old scripts were being reused against a new build of the application to gauge if or how much performance had been affected by the changes from the old build. Before I reexecuted the scripts, I instrumented them with the statuslog procedure using the StatusLog utility so I would have direct output for this round of tests.
While evaluating the output from the statuslog procedure I saw several unexpected response codes. Initially, we thought the build was bad. Then we thought to use LogParse to check the logs from the tests conducted on the old build, only to find out that the application returned the same response codes for the same requests. As a result of this, the developers were able to check those individual requests and correct the problem. While this use doesn't sound very fancy, it saved many hours of our time as compared to searching through and consolidating this information from other sources.
Currently, Scott Barber serves as the lead Systems Test Engineer for AuthenTec. AuthenTec is the leading semiconductor provider of fingerprint sensors for PCs, wireless devices, PDAs, embedded access control devices and automotive markets. He is also member of the Technical Advisory Board for Stanley-Reid Consulting, Inc.
With a background in consulting, training, network architecture, systems design, database design and administration, programming, and management, Scott has become a recognized thought leader in the field of performance testing and analysis. Before joining AuthenTec, he was a software testing consultant, a company commander in the United States Army and a government contractor in the transportation industry.
Scott is a co-founder of WOPR (the Workshop on Performance and Reliability), a semi-annual gathering of performance testing experts from around the world, a member of the Context-Driven School of Software Testing and a signatory of the Agile Manifesto. He is a discussion facilitator for the Performance and VU Testing forum on Rational DeveloperWorks and a moderator for the performance testing and Rational TestStudio related forums on QAForums.com. Scott speaks regularly at a variety of venues about relevant and timely testing topics. Scott's Web site complements this series and contains much of the rest of his public work. You can address questions/comments to him on either forum or contact him directly via e-mail.
Comments (Undergoing maintenance)





