Performance Teting - VU Scripting Using Rational ( )

  • View

  • Download

Embed Size (px)


Rational Test Manager & Rational Robot - Performance Testing - Virtual User Scripting

Text of Performance Teting - VU Scripting Using Rational ( )

Advanced Rational Robot

Performance Testing VU Scripting using Rational

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 PlanCreate Test CasesConfigure test CasesDesign test CasesCreate 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 GenerationDuring 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 filesThe VU language supports the following kinds of files:

File typeExtensionLocation

Script files.sThe script directory (TMS_Scripts) of your project.

Watch files (also called session files).wchThe session directory (TMS_Session) of your project.

Header files.hVU.h file shipped with TestManager is located in \rational\rational test\include by default.

VU addition to C LanguageThe VU language contains a number of commands in addition to standard C programming language commands.

Environment control commands Enable you to control a virtual testers 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 servers responses, as well as performing communication and timing operations. You can log emulation commands in a log file.

Notes: Emulation functions doesnt perform communication & timing operation and hence doesnt log emulation commands in a log file

Environment Control commands

eval: Returns the value and data type at the top of a VU environment variables 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];


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 commandsreset: 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 commandsSave: 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.

for: Repeatedly executes a VU statement.

if-else: Conditionally executes a VU statement.

while: Repeatedly executes a VU statement.

Library Routines

I/O Routines : open, close, fseek, feof, fgetc, fputc, fprintf, fscanf etc.

Conversion Routines : atoi, ctos, stoc etc.

String Routines: sindex, strlen, strstr, substr, subfield etc.

Random Number Routines: negexp, rand, uniform etc.

Timing Routines: delay, time, tod.

Miscellaneous Routines: abs, display, getenv, user_exit, usergroup_sizeSynchronization Functions: wait

Datapool commands

datapool_close Closes an open datapool.

datapool_fetch Moves the datapool cursor to the next record.

datapool_open Opens a datapool.

datapool_rewind Resets the cursor for the datapool.

datapool_value Retrieves the value of a specified column.

VU Toolkit functionData commands:

AppendData: Adds the data returned by sqlnrecv to the specified data set.

FreeAllData: Frees all data sets saved with SaveData and AppendData.

FreeData: Frees specified data sets saved with SaveData and AppendData.

GetData:Retrieves a specific value created with SaveData or AppendData.

SaveData: Stores the data returned by the most recent sqlnrecv command.

VU Toolkit functionFile I/O commands:

NextField :Parses the line read by the ReadLine function.

NextSubField: Parses the field returned by the most recent call to NextField or IndexedField.

ReadLine:Reads a line from the open file designated by file_descriptor.

SHARED_READ: Allows multiple virtual testers to share a file.

IndexedField :Parses the line read by the ReadLine function and returns the field designated by index.

Emulation commandsSQL Emulation commands & Functions

SQL Send Emulation Commands

SQL Receive Emulation Commands

SQL Emulation Functions

SQL Send Emulation Commandssqlclose_cursor : Closes the indicated cursor.

sqldelete_cursor :Deletes the current row using the indicated cursor.

sqlexec: Executes SQL statements.

sqlopen_cursor: Opens the specified cursor.

sqlposition_cursor: Positions a cursor within a result set.

sqlrefresh_cursor: Refreshes the result set of a cursor.

sqlupdate_cursor: Updates the current row of the indicated cursor.

SQL Receive Emulation Commands

sqlfetch_cursor : Fetches the requested rows from the cursor indicated.

Sqllongrecv: Retrieves longbinary and longchar results.

sqlnrecv: Retrieves row results after sqlexec is executed.

SQL Emulation Functions

Sqlcommit: Commits the current transaction.

Sqlconnect: Logs on to a SQL database server.

Sqldisconnect: Closes the specified connection.

sqlfree_cursor :Frees a cursor.

Sqlrollback:Rolls back the current transaction.

sqlsetoption : Sets a SQL database server option.

HTTP Emulation Commands and Functions

HTTP Send Emulation Commandshttp_request: Sends an HTTP request to a Web server.

Syntax:int http_request [cmd_id] primary_addr [, secondary_addr] [, flags], text

HTTP Receive Emulation Commands

http_header_recv: Receives header metadata from a Web server.

http_recv: Receives data from a Web server until the specified text string occurs.

HTTP Emulation Commands and Functions

HTTP Emulation Functions:

http_disconnect: Closes the connection to a Web server.

http_find_values: Searches for the specified values on the current connection.

http_header_info: Gets individual header values from header metadata.

expire_cookie: Expires a cookie in the cookie cache.

set_cookie:Adds a cookie to the cookie cache.

Socket Emulation Commands and FunctionsSocket Send Emulatio

View more >