After capturing the script the next step is to model it. There are 3 types of variables that you need to create and substitute in order to run a load test with each simulated or virtual user correctly behaving as a real end user. These variables are for:
When you record and play back a script a number of metrics are automatically generated that describe how each simulated or virtual user is performing. These statistics are:
HTTP Statistics may be generated for every GET and POST. For each individual URL you may record:
This type of information can be very useful in identifying problems when running load tests
Timer data is generated by the SCL commands:
By placing timers in the scripts you are able to measure the response time that would be experienced by an end user over individual pages or over an entire script. Timers are automatically inserted at the start and end of each script that are recorded.
From Commander double click on the FINDBYNAME script. The Modeler will then start. The screen should look a little like the screen below. Scroll through the script until the Load Response_Info Header line is found. This is shown in the middle of the screen shot below (figure 4-1-1)
OpenSTA has identified that cookies are being used and is placing the value of the cookie in to the variable cookie_1_0. This means the first cookie on connection zero.
Load Response_Info Header on 1 &
Into cookie_1_0 &
,WITH "Set-Cookie,findpresid"
|
This command loads the value of the HTTP cookie findpresid in to the SCL variable cookie_1_0 (you can see the definition of this variable in the DEFINITION section of the script). Looking a little further down the script at the next primary POST the HTTP cookie line is show as:
"Cookie:findpresid=a,969533471"} & |
For the script to run correctly the value of the cookie returned from the server must be passed back to the server on subsequent GETS and POSTS. The structure of the line is:
COOKIE STRING | SCL syntax | ||||||||
HTTP Header | Cookie Name | User Name | Session ID | ||||||
" |
Cookie: |
findpresid |
= |
a |
, |
969533471 |
" |
} |
& |
However, you want to model the script so that it can use any user name and correctly provide the session ID in the cookie. There are a number of ways to do this. The SCL lines below show one way in which it can be done. Please look at the code lines and read the comments with each.
! You can add a report line to see what the cookie value is report "The value of the 'cookie_1_0' is = => " ,cookie_1_0 ! Set the value of cookie_all to replace the HTTP cookie header set cookie_all = "Cookie: " + cookie_1_0 |
You can now substitute the variable cookie_all in place of the cookie string:
"Cookie:findpresid=a,969533471"} & |
As follows:
cookie_all} & |
As shown in the screen shot below (figure 4-1-2):
The code section above will only compile if the new variables that have been created are there. The variables are:
The code needed in the DEFINITION section is as follows:
CHARACTER*1024 cookie_all CHARACTER*9 sessionid CHARACTER*512 USERNAME ( "aha", "bab", "sas" & , "rar", "cac" ), LOCAL, RANDOM |
And in the Modeler this looks like the screen shot below (figure 4-1-3):
These variables can be created by simply typing them in or by using the Variable > Create option. If you use this option the box below will appear (figure 4-1-4). Enter the variable Name and set its Scope, Value Source, Order and Type as shown. See the Reference Guide for a more in-depth description of variable scopes and data types.
Then click on the Value List tab (figure 4-1-5)
Enter some values as show, and then click on OK.
The user name also needs to be substituted on the first POST as the screen shot below (figure 4-1-6) shows on the last visible line:
The last line was:
,BODY "loginid=a&passwd=a" |
has been changed to:
,BODY "loginid=" + username + "&passwd=" + username |
As the username is a variable with a list of values, you need to get the first value. To achieve this the line:
Generate username |
Has been inserted before the POST. This is shown in the screen shot above.
Having made these changes you can now compile the script Capture > Syntax Check. The screen should look as follows (figure 4-1-7):
And then run the script by selecting Capture > Run (figure 4-1-8)
Notice the third line from the bottom of the screen starting:
!Cannot find cookie...
This has happened because the cookies have not yet been substituted all the way through the script. Repeat the loading and manipulation of the cookies for each of the primary GETs and POSTs and substitute the variable cookie_all for each of the cookie HTTP headers as you have done above. When you next run the script the output should look like the output in the next screen shot. (figure 4-1-9)
Notice:
Remove some of the diagnostic report lines from the script. The easiest way to do this is to simply comment them out with a "!". Now you can start running more than one user at a time with the script. It will be useful to identify which virtual user is using which user name and cookie. Add the following lines to the script:
DEFINITIONS .. . character*40 VU_num . . CODE .. . Load TERMINAL into VU_num Report VU_num, " User = => ", username , " Session ID = => ", sessionid |
Be sure to add the Load TERMINAL after the logon as shown in the screen shot below. Also copy the report line after each primary GET or POST, since the server changes the value of the session ID with every request. The screen shot below shows (figure 4-1-10) these new lines at the bottom.
Save the changes and close the Modeler.