Performance Teting - VU Scripting Using Rational (http://www.geektester.blogspot.com) - Presentation Transcript
Performance Testing – VU Scripting using Rational Tools [email_address] www.itest.co.nr
Courseware Information
This introductory course is designed to familiarize testing professionals with the basics of Rational Test Manager
The focus will be on applying Rational Test Manager to define, configure and design test cases, define project iterations, configurations and computers and establish traceability links between test inputs and test cases.
Course Objective & Outline
After completing this course, you will be able to:
Build a Test Plan
Create Test Cases
Configure test Cases
Design test Cases
Create Planning Reports
Virtual User Scripting
The VU language is the Rational Software corporation language for building virtual tester scripts.
The VU language is based on the C programming language. In addition to supporting many C language features, VU includes commands and environment variables specifically designed for use in Rational Suite TestStudio scripts.
When you record client/server conversations, Rational Robot automatically generates a script for you in the VU language. You can either play back the script as it was generated, or you can make modifications in Robot.
Automated Script Generation During virtual tester recording, Robot "listens in" on the client/server conversation. Robot translates the raw conversation into a series of VU commands and stores them in the script.
Modifying Scripts
Although Robot generates complete, executable scripts, sometimes you may want to edit a recorded script — for example, to:
Add for, while, and do-while loops to simplify repetitive actions.
Add conditional branching.
Modify think time variables.
Respond to runtime errors.
Source & Runtime files The VU language supports the following kinds of files: File type Extension Location Script files .s The script directory (TMS_Scripts) of your project. Watch files (also called session files) .wch The session directory (TMS_Session) of your project. Header files .h VU.h file shipped with TestManager is located in
ational
ational testinclude by default.
VU addition to C Language
The VU language contains a number of commands in addition to standard C programming language commands.
Environment control commands – Enable you to control a virtual tester’s environment by changing the VU environment variables. For example, the number of times to try a connection.
Flow control statements – Enable you to add conditional execution structures and looping structures to your virtual tester script. The flow control statements behave like their C counterparts, with enhancements added to break and continue.
Library routines – Provide your virtual tester script with predefined functions that handle file I/O, string manipulation, and conversion of data types and formats.
VU addition to C Language – Contd..
Datapool functions – Retrieve data from a datapool. This enables a script that is executed more than once to use different values in each execution.
VU toolkit functions – These functions, which come with TestManager, enable you to parse data returned by sqlnrecv into rows and columns.
Emulation commands & functions: Emulation commands emulate client activity and evaluate the server’s responses, as well as performing communication and timing operations. You can log emulation commands in a log file.
Notes: Emulation functions doesn’t perform communication & timing operation and hence doesn’t log emulation commands in a log file
Environment Control commands
eval: Returns the value and data type at the top of a VU environment variable’s stack.
Syntax: type eval env_var;
Example:
set [Timeout_val = 2000, Log_level = "ALL"];
t = eval Timeout_val;
e=(eval Log_level=="ALL");
Environment Control commands
pop: Removes the value of a VU environment variable from the top of the stack.
Syntax: pop [env_var_list];
env_var_list
A list of one or more environment variables, separated by commas and optionally by white space. If env_var_list contains one item, the brackets are optional. If env_var_list contains more than one item, pop operates on the items from left-to-right.
ENV_VARS. This specifies all the environment variables.
Environment Control commands
push: Pushes the value of a VU environment variable to the top of the stack.
Syntax: push [env_assign_list];
env_assign_list: A list of one or more environment variable assignments, of the form env_var = expr
Example:
/* Set values for Timeout_val and Log_level. */
set [Timeout_val = 120000, Log_level = TIMEOUT];
push Timeout_val = 30000;
pop Log_level;
Environment Control commands
reset: Changes the current value of a VU environment variable to its default value, and discards all other values in the stack.
Syntax: reset [env_var_list];
restore: Makes the saved value of a VU environment variable the current value.
Syntax: restore [env_var_list];
Example: set Timeout_val = 60000;
save Timeout_val;
set Timeout_val = 30000;
restore Timeout_val;
show Timeout_val;
Environment Control commands
Save: Saves the value of a VU environment variable.
Syntax: save [env_var_list];
Set: Sets a VU environment variable to the specified expression.
Syntax: set [env_assign_list];
show: Writes the current values of the specified variables to standard output.
Syntax: show [env_var_list];
Flow Control Commands
break: Stops execution of for, while, and do-while statements.
continue: Skips remaining statements in a loop and continues with the next iteration of the loop.
do-while :Repeatedly executes a VU statement while a condition is true.
emulate : Provides generic emulation command services to support a proprietary protocol.
Note: VU supports the SAP protocol by using external C functions and the emulate command.
start_time: Enables you to define start and stop times.
stop_time: Enables you to define start and stop times.
testcase: Checks a response for specific results and reports and logs them
Scripts, Subroutines, and C Libraries
Program structure
Header Files
Preprocessor features
Defining your own subroutines
Accessing external C data and functions
Program Structure
VU programming structure is similar to the structure of the C programming language.
#include <VU.h>
#include <VU_tux.h>
proc proc_name()
{ /* body of procedure */ }
func function_name()
{ /* body of function */ }
/* main body of script follows: */
{
string declarations;
shared declarations;
/* VU code goes here*/
}
Header Files
VU header files contain a collection of definitions and macros. VU.h is automatically included in scripts generated from recording HTTP, SQL, and socket sessions. VU_tux.h is automatically included in scripts generated from recording a TUXEDO session.
If you are manually writing a script, include the following preprocessor statement:
#include <VU.h>
If you are manually writing a script that accesses a TUXEDO application, include both VU_tux.h and VU.h as preprocessor statements:
#include <VU.h>
#include <VU_tux.h>
VU.h Header File
The VU.h file includes definitions for:
The EOF value returned by various VU functions.
The file descriptors for the standard files.
ENV_VARS, which lets you operate on the environment variables as a unit.
HOURS(A), MINUTES(A) and SECONDS(A) returns the time in milliseconds.
All error codes (_error) that are not provided by the SQL database server.
sme/data.h file & sme/file.h
The sme/data.h file includes definitions for functions that come with TestStudio. These functions let you parse data returned by sqlnrecv into rows and columns. Typically, this is useful in dynamic data correlation for SQL, where you extract data from queries and use that data in subsequent statements.
The sme/file.h file includes definitions for functions that read a line of data from a file, parse the line that was read, and then reset the pointer to the next line of data, so that each emulated user can parse a line. Typically, this is useful as an alternative to datapools.
Preprocessor Features
Replace tokens : Token replacement and macro substitution can be specified with the #define preprocessor command. To indicate simple replacement throughout the entire script, use a command of the form:
#define orig_ident new_token
Include more than one source file in a script: The #include preprocessor command lets you include another source file in your script at compile time. This command has two forms:
#include <filename>
#include "filename"
Compile parts of a script: Conditional compilation commands allow you to conditionally compile parts of a script. There are three ways to specify conditional compilation:
#if-#else-#endif
#ifdef-#else-#endif
#ifndef-#else-#endif
Functions
Functions – Subroutines that return a value through a return statement. You define functions with the func keyword.
[type] func fname [array_spec] (arg_list)
arg_declar;
{
stmnt1;
stmnt2;
...
stmntn;
return ret_exp;
}
Procedures
Procedures – Subroutines that do not return a value. You define procedures with the proc keyword.
proc pname (arg_list)
arg_declar;
{
stmnt1;
stmnt2;
...
stmntn;
}
Accessing External C Data and Functions
The VU language supports access to external C data and functions.
A VU script can call functions written in C and pass values as arguments to the C functions.
C functions can return values to VU scripts.
External C objects are declared in VU using the keyword external_C.
External C Variables C Variable Type VU Variable Type int int char * string /* read only */ char * string:maxsize /* writable */ int * int [ ], int[ ][ ], int[ ][ ][ ] char ** string [ ], string [ ][ ], string [ ][ ][ ]
External C Variables
In a script an external C string is read-only unless its VU declaration includes its maximum size. The C code must allocate space for the string greater than or equal to maxsize bytes. The maximum size must include room for the C null-terminator character '
0 comments
Post a comment