Performance Teting Vu Scripting Using Rational 1203210899768270 4
-
Upload
saurabh-malusare -
Category
Documents
-
view
215 -
download
0
Transcript of Performance Teting Vu Scripting Using Rational 1203210899768270 4
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
1/48
Performance Testing
VU Scriptingusing Rational Tools
www.itest.co.nr
mailto:[email protected]://www.itest.co.nr/http://www.itest.co.nr/mailto:[email protected] -
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
2/48
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.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
3/48
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
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
4/48
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 makemodifications in Robot.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
5/48
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.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
6/48
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.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
7/48
Source & Runtime files
File type Extension Location
Script files .s The script directory (TMS_Scripts) ofyour 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 \rational\rational
test\include by default.
The VU language supports the following kinds of
files:
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
8/48
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 testersenvironment by changing the VU
environment variables. For example, the
number of times to try a connection.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
9/48
VU addition to C Language
Contd..
Datapool functions Retrieve data froma datapool. This enables a script that isexecuted more than once to usedifferent values in each execution.
VU toolkit functions These functions,which come with TestManager, enableyou to parse data returned by sqlnrecvinto rows and columns.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
10/48
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");
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
11/48
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_listcontains 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.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
12/48
Environment Control
commands
push: Pushes the value of a VU environment variable to the top of thestack.
Syntax: push [env_assign_list];
env_assign_list: A list of one or more environment variableassignments, 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;
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
13/48
Environment Control
commandsreset: Changes the current value of a VU environment variable to itsdefault value, and discards all other values in the stack.
Syntax: reset [env_var_list];
restore: Makes the saved value of a VU environment variable thecurrent value.
Syntax: restore [env_var_list];
Example: set Timeout_val = 60000;save Timeout_val;
set Timeout_val = 30000;
restore Timeout_val;
show Timeout_val;
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
14/48
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];
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
15/48
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.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
16/48
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_size
Synchronization Functions: wait
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
17/48
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.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
18/48
VU Toolkit function
Data commands:
AppendData: Adds the data returned by sqlnrecv to the specified dataset.
FreeAllData: Frees all data sets saved with SaveData and AppendData.
FreeData: Frees specified data sets saved with SaveData andAppendData.
GetData:Retrieves a specific value created with SaveData orAppendData.
SaveData: Stores the data returned by the most recent sqlnrecvcommand.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
19/48
VU Toolkit function
File I/O commands:
NextField :Parses the line read by the ReadLine function.
NextSubField: Parses the field returned by the most recent call toNextField 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.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
20/48
Emulation commands
SQL Emulation commands & Functions
SQL Send Emulation Commands
SQL Receive Emulation Commands
SQL Emulation Functions
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
21/48
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.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
22/48
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.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
23/48
SQL Emulation Functions
Sqlcommit: Commits the current
transaction.
Sqlconnect: Logs on to a SQL database
server.
Sqldisconnect: Closes the specified
connection.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
24/48
HTTP Emulation Commands and Functions
HTTP Send Emulation Commands
http_request: Sends an HTTP request to aWeb server.
Syntax:int http_request [cmd_id] primary_addr [,
secondary_addr] [, flags], text
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
25/48
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.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
26/48
Socket Emulation Commands and Functions
Socket Send Emulation Commands
sock_send: Sends data to the server.
Socket Receive Emulation Commandssock_nrecv: Receives n bytes from the server.
sock_recv : Receives data until the specified
delimiter string is found.
Socket Emulation Functions
sock_connect, sock_create, sock_disconnect,
sock_open etc
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
27/48
Emulation Commands Used with Any
Protocol
emulate : Provides generic emulation command services to support
a proprietary protocol.
Note: VU supports the SAP protocol by using external C functionsand 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
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
28/48
Scripts, Subroutines, and C
Libraries
Program structure
Header Files
Preprocessor features
Defining your own subroutines
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
29/48
Program Structure
VU programming structure is similar to the structure of the Cprogramming language.
#include
#include
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*/
}
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
30/48
Header Files
VU header files contain a collection of definitions and macros. VU.h isautomatically included in scripts generated from recording HTTP, SQL,and socket sessions. VU_tux.h is automatically included in scriptsgenerated from recording a TUXEDO session.
If you are manually writing a script, include the following preprocessorstatement:
#include
If you are manually writing a script that accesses a TUXEDO
application, include both VU_tux.h and VU.h as preprocessorstatements:
#include
#include
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
31/48
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.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
32/48
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.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
33/48
Preprocessor Features
Replace tokens : Token replacement and macro substitution can bespecified with the #define preprocessor command. To indicate simplereplacement 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 preprocessorcommand lets you include another source file in your script at compiletime. This command has two forms:
#include
#include "filename"
Compile parts of a script: Conditional compilation commands allow youto conditionally compile parts of a script. There are three ways to specifyconditional compilation:
#if-#else-#endif
#ifdef-#else-#endif
#ifndef-#else-#endif
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
34/48
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;
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
35/48
Procedures
Procedures Subroutines that do not
return a value. You define procedures
with the proc keyword.
proc pname (arg_list)
arg_declar;{
stmnt1;
stmnt2;
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
36/48
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.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
37/48
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 [ ][ ][ ]
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
38/48
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'; it is specified with a
colon and an integer constant, as in:
external_C string:81 extc_line;
External C data cannot be declared persistent or shared. Values of
external C variables persist for the duration of the run.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
39/48
Declaring External C
Subroutines
An external C subroutine is declared the same way as a VU function orprocedure, with an empty statement block for the body.
The following VU declarations:
external_C func foo(i, s)
string s;
{ }
external_C int func[10][20] afunc()
{ }
are used for the C functions whose prototypes are:
int foo(int, char *);
int *afunc(void);
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
40/48
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
41/48
Specifying External C
Libraries
In TestManager, select Tools -> Options, and then
click the Compilation tab. Under External C Libraries,
click Add and enter the name of the library.
To make a library available to a particular script,
modify the script properties for that script. You can
modify script properties using TestManager, Robot, or
LoadTest. In LoadTest
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
42/48
Creating a Dynamic-Link
Library
To access C code and data from a VU script, compile the C code into a
dynamic-link library (DLL).
There are three steps involved in creating a DLL:
1. Write and compile the C source code to be called from your VU script.
2. Examine the VU script, and note which functions and variables the
script needs to access.
3. Create the DLL, and export the necessary symbols.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
43/48
Creating a Dynamic-Link
Library1. Write c_prog.c, which contains code that you want to call from your script,
script.s. Invoke the compiler to compile c_prog.c and produce c_prog.obj
2. Examine your VU script script.s. The script uses external C notation to indicate
that the symbols s_func, afunc, and addr_message are defined in a C module.
3. Issue the link command to create a DLL and export the external C symbols.
The following command produces c_prog.lib, c_prog.exp and c_prog.dll, and
exports s_func, afunc and addr_message:
link c_prog.obj /dll /export:s_func /export:afunc /export:addr_message
4. Once you have created the DLL, copy it to each project that needs to access
it. The directory location is
project_nameTestDatastore\DefaultTestScriptDatastore\TMS_Scripts\externC
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
44/48
Supplying a Script with
Meaningful Data
When you play back a script, the script
uses the exact values that you recorded.
Assume, for example, that you record a
script that adds a record with a primary
key of John Doe to a database. When
you play back the script, to emulate
thousands of users, you will get errors
after the first John Doe is added.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
45/48
Dynamic Data Correlation
Dynamic data correlation is a technique tosupply variable data values to a script whenthe transactions in a script depend on values
supplied from the server.
For example, when you record an http script,
the Web server may send back a uniquestring, or session ID, to your browser. Thenext time your browser makes a request, itmust send back the same session ID to
authenticate itself with the server.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
46/48
Types of Performance Test
Benchmark tests Compares the performance of a new or unknownserver to a known reference standard, such as existing software ormeasurements.
Configuration tests Verifies the acceptability of the server's
performance behavior using varying configurations while the operationalconditions remain constant.
Load tests Verifies the acceptability of the server's performancebehavior using varying workloads while the operational conditionsremain constant.
Stress tests Verifies the acceptability of the server's performancebehavior when abnormal or extreme conditions are encountered, suchas diminished resources or an extremely high number of users.
Contention tests Verifies that the server can handle multiple user
demands on the same resource (that is, data records or memory).
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
47/48
LoadTest
Load testing is designed to test client or
server response times under varying
loads.
Load tests also are used to computethe maximum number of transactions a
server can handle over a given time
period.
-
7/27/2019 Performance Teting Vu Scripting Using Rational 1203210899768270 4
48/48
Questions