Your SlideShare is downloading. ×
Performance Teting - VU Scripting Using Rational (http://www.geektester.blogspot.com)
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Performance Teting - VU Scripting Using Rational (http://www.geektester.blogspot.com)

7,029
views

Published on

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

Rational Test Manager & Rational Robot - Performance Testing - Virtual User Scripting
http://www.geektester.blogspot.com/

Published in: Business, Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
7,029
On Slideshare
0
From Embeds
0
Number of Embeds
18
Actions
Shares
0
Downloads
300
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Transcript

    • 1. Performance Testing – VU Scripting using Rational Tools [email_address] www.itest.co.nr
    • 2. 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.
    • 3. 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
    • 4. 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.
    • 5. 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.
    • 6. 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. 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.
    • 8. 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.
    • 9. 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
    • 10. 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");
    • 11. 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.
    • 12. 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;
    • 13. 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;
    • 14. 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];
    • 15. 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.
    • 16. 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
    • 17. 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.
    • 18. VU Toolkit function
      • Data 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.
    • 19. 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 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.
    • 20. Emulation commands
      • SQL Emulation commands & Functions
      • SQL Send Emulation Commands
      • SQL Receive Emulation Commands
      • SQL Emulation Functions
    • 21. SQL Send Emulation Commands
      • sqlclose_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.
    • 22. 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.
    • 23. 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.
    • 24. HTTP Emulation Commands and Functions
      • HTTP Send Emulation Commands
      • http_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.
    • 25. 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.
    • 26. Socket Emulation Commands and Functions
      • Socket Send Emulation Commands
      • sock_send: Sends data to the server.
      • Socket Receive Emulation Commands
        • sock_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
    • 27. 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 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
    • 28. Scripts, Subroutines, and C Libraries
      • Program structure
      • Header Files
      • Preprocessor features
      • Defining your own subroutines
      • Accessing external C data and functions
    • 29. 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*/
      • }
    • 30. 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>
    • 31. 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.
    • 32. 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.
    • 33. 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 &quot;filename&quot;
      • 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
    • 34. 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;
      • }
    • 35. 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;
      • }
    • 36. 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.
    • 37. 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 [ ][ ][ ]
    • 38. 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 ''; 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.
    • 39. Declaring External C Subroutines
      • An external C subroutine is declared the same way as a VU function or procedure, 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);
    • 40. Accessing Values Returned from C Functions C Variable Type VU Variable Type void proc int int func char * string func int * int func[ ], int func[ ][ ], int func[ ] [ ][ ] char ** string func[ ], string func[ ] ], string func[ ] [ ] [ ]
    • 41. 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
    • 42. 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.
    • 43. Creating a Dynamic-Link Library
      • 1. 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_nameTestDatastoreDefaultTestScriptDatastoreTMS_ScriptsexternC
    • 44. 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.
      • To correct this situation, you use datapools, which supply unique test values to the server.
    • 45. Dynamic Data Correlation
      • Dynamic data correlation is a technique to supply variable data values to a script when the 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 unique string, or session ID, to your browser. The next time your browser makes a request, it must send back the same session ID to authenticate itself with the server.
      • The session ID can be stored in three places:
        • In the Cookie field of the HTTP header.
        • In an arbitrarily named field of the HTTP header.
        • In an arbitrary hidden field in an actual HTML page.
    • 46. Types of Performance Test
      • Benchmark tests – Compares the performance of a new or unknown server to a known reference standard, such as existing software or measurements.
      • Configuration tests – Verifies the acceptability of the server's performance behavior using varying configurations while the operational conditions remain constant.
      • Load tests – Verifies the acceptability of the server's performance behavior using varying workloads while the operational conditions remain constant.
      • Stress tests – Verifies the acceptability of the server's performance behavior when abnormal or extreme conditions are encountered, such as 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).
    • 47. LoadTest
      • Load testing is designed to test client or server response times under varying loads.
      • Load tests also are used to compute the maximum number of transactions a server can handle over a given time period.
      • When a client/server system uses workload balancing or a distributed architecture, load testing can help to ensure that the load balancing or distribution methods work as designed.
    • 48. Questions