Skip to main content

Custom VuC functions: Log_Parse

Scott Barber, Performance testing consultant, AuthenTec

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.

Summary:  The custom VuC utility described here parses a default output file and writes just the command ID, the expected and/or accepted response, and the actual response to a separate file for easy analysis and reporting. This function is part of a library of customized utilities and VuC functions created by experts in the testing community.

Date:  28 Apr 2004
Level:  Introductory
Activity:  180 views
Comments:  

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

LogParse is a utility that takes a default output file (d00) as input and writes just the command ID, the expected and/or accepted response, and the actual response to a separate file for easy analysis and reporting. LogParse allows you to obtain information similar to that obtained by the statuslog procedure but without making any modifications to your existing scripts.

Purpose/use

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 LogParse utility in an effort to simplify this process without requiring modification of recorded scripts.

The LogParse utility parses existing log files from previous test runs. By comparison, the statuslog procedure lets you instrument your script to create a log file while your script is running. 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 this utility results in an output file like the sample below that contains the command ID, the line number, and the complete object request, plus the HTTP return code if successful or the expected and actual responses sent back from the Web server if unsuccessful.

>>>> cmdid: [test001][1] src: [test.s] line [19]
GET http://www.perftestplus.com/ 

>>>> cmdid: [test002][2] src: [test.s] line [37]
HTTP/1.0 304 Not Modified

>>>> cmdid: [test004][4] src: [test.s] line [44]
GET http://www.perftestplus.com/missing.gif 

>>>> cmdid: [test005][5] src: [test.s] line [60]
EXPECT=200
ACTUAL=HTTP/1.1 404 Not Found

This information can be used to quickly see if the requested files are being handled as expected by the Web server.

To use this utility, you first must create the LogParse.s script as outlined below under "Utility code." Then you'll need to have an HTTP script to execute. For the utility to parse this script, you'll need to move the d00 file from the test datastore into the TMS_Scripts directory. The d00 file will be located here:

[Drive]:\[RepositoryName]\TestDatastore\TMS_Builds\[BuildName]\[SubBuild]\[TestRun]\perfdata\

Simply copy the d00 file and paste it into the script directory, located here:

[Drive]:\[RepositoryName]\TestDatastore\DefaultTestScriptDatastore\
   TMS_Scripts\
   

You can replace d00 with the actual name of the log file you want to parse (for example, d001) and/or the name of the new log file you want to create (the default name is d00_summary.txt). If you do change either of those parameters, remember to click the green checkmark on the Robot menu bar to compile your script.

Next, simply execute the LogParse.s script like you would any other VU script. When the script has finished executing, launch your favorite text editor (such as Notepad) and open the resulting file, located in the TMS_Scripts directory:

[Drive]:\[RepositoryName]\TestDatastore\DefaultTestScriptDatastore\
   TMS_Scripts\d00_summary.txt
   

If you prefer, you can simply substitute the entire path in the utility where str_oldlog and str_newlog are declared, like this:

str_oldlog = 'D:\Rat2002_Repo\TestDatastore\TMS_Builds\Build
   1.Build\Default.LogFolder\perftestplus Users 1 #100.Log\perfdata\d00';

str_newlog = 'D:\Rat2002_Repo\TestDatastore\TMS_Builds\Build
   1.Build\Default.LogFolder\perftestplus Users 1 #100.Log\perfdata\
   d00_summary.txt';
   


Requirements

This utility works only in conjunction with an existing VU Robot script containing the HTTP protocol with default logging enabled.


Utility code

Here's the code for the LogParse utility:

#include <VU.h> 
#define _PV_FILEIO_NOWRAP   1
#include <sme\fileio.h> 

{ 

string str_oldlog, str_newlog, str_theline, str_theline2, tmp_string;
int result;

result = 1; 

str_oldlog = 'd00';
str_newlog = 'd00_summary.txt';

oldlog=open(str_oldlog, "r");
newlog=open(str_newlog, "w");
   
while (result==1){
   result = ReadLine(oldlog);
   str_theline = NextField();  
      if (strstr(str_theline, ">>>> cmdid:")){ 
         result = ReadLine(oldlog);              
         str_theline2 = NextField();
         if (strstr(str_theline2, "EXPECT")) {
            fputs("\r\n" + str_theline + "\r\n", newlog);
            fputs(str_theline2 + "\r\n", newlog);
            result = ReadLine(oldlog);              
            str_theline2 = NextField();
            fputs(str_theline2 + "\r\n", newlog);
         }
         else if (match('.*HTTP/1.[0-1] [0-9]{3}.*', str_theline2)){
            fputs("\r\n" + str_theline + "\r\n", newlog);
            fputs(str_theline2 + "\r\n", newlog);
         }
         else if (strstr(str_theline2, "HTTP/1.")){
            fputs("\r\n" + str_theline + "\r\n", newlog);
            str_theline2 = substr(str_theline2, 1, ((strstr(str_theline2, 
               "HTTP/1."))-1));
            fputs(str_theline2 + "\r\n", newlog);
         }
         else if ((strstr(str_theline2, "Connected to")) || 
            (strstr(str_theline2, "connection to"))){
            result = ReadLine(oldlog);
            str_theline2 = NextField();
            str_theline2 = substr(str_theline2, 1, ((strstr(str_theline2, 
               "HTTP/1."))-1));
            fputs("\r\n" + str_theline + "\r\n", newlog);
            fputs(str_theline2 + "\r\n", newlog);
         }
      } 
   }   
close(oldlog);    
close(newlog); 
}

T his code should be copied and pasted into a new VU script and saved, as follows:

  1. Choose File > New > Script from the Robot menu bar.
  2. In the New Script dialog box, name the script LogParse, ensure the VU radio button is selected, and click OK.
  1. Delete any auto-generated code in the script window.
  2. Paste the LogParse code into the script window.
  3. Click the green checkmark on the main Robot menu bar to compile the script.

Examples of use

LogParse is particularly useful for parsing existing log files rather than instrumenting new scripts for specific output. I used this utility 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.


About the author

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



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational
ArticleID=4276
ArticleTitle=Custom VuC functions: Log_Parse
publish-date=04282004
author1-email=dwinfo@us.ibm.com
author1-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers