Wednesday 1 May 2013

LoadRunner Tutorial



5
Solving Common Playback Problems
After you create a script, you validate it by running it from VuGen.
Occasionally, a simple playback will fail, even though the recording of the
same actions succeeded.
Many applications use dynamic values that change each time you use the
application. For example, some servers assign a unique session ID for every
new session. When you try to replay a recorded session, the application
creates a new session ID that differs from the recorded session ID.
LoadRunner addresses this issue through correlation. Correlation saves the
changing values, in our case the session ID, to a parameter. When running
the emulation, the Vuser does not use the recorded value—instead, it uses
the new session ID, assigned to it by the server.
In this lesson you will observe how LoadRunner automatically solves the
issue of dynamic values.
In this lesson you will cover the following topics:
Preparing HP Tours for Playback Errors
How do I work with unique server values?
Preparing HP Tours for Playback Errors
To illustrate a common playback failure, you need to modify a setting in the
HP Tours application. This setting tells the HP Tours Web Server not to allow
duplicate session IDs.
1 Open HP Tours.
Choose Start > Programs >LoadRunner> Samples > Web > HP Web Tours
Application. A browser opens with the HP Tours opening page.
2 Change the server options.
Click the administration link on the HP Web Tours opening page. The
administration page opens.
Select the 3rd checkbox entitled: Set LOGIN form's action tag to an error
page. Scroll down to the bottom of the page and click Update.
Scroll down to the bottom of the page and click the Return to the Web
Tours Homepage link.
This setting tells the server not to allow duplicate session IDs.
3 Close the browser.
How do I work with unique server values?
In the modified configuration of HP Tours, the server assigns a unique
session ID to the Vuser. If you try to play back the script, it will fail.
To overcome this issue, you use VuGen to automatically detect the need to
correlate the session ID. After you run the script, VuGen prompts you to
scan the script for correlations.
Automatic Correlation
In this lesson, you scanned a script for correlations after recording the user
actions.
VuGen also provides a set of configurable correlation rules to handle
dynamic values during the recording session. For details on automatic
correlation, refer to the HP Virtual User Generator User’s Guide.
Most servers have clear syntax rules, or contexts, that they use when creating
links and referrals. If you are recording a session with a supported
application server, you can use VuGen’s built-in correlation rules, and
VuGen will detect and correlate the dynamic values during the recording
stage.
Where To Go From Here
Now that you are familiar with some of the common playback problems,
you can proceed to Lesson 6, “Preparing a Script for Load Testing
6
Preparing a Script for Load Testing
In the previous lessons, you verified that your script was an accurate
emulation of your application. You watched the playback in real time and
you verified that the Vuser performed a typical business process.
This, however, is true only for a single user emulation. Will the application
work with many users working simultaneously? If so, will the application
slow down to an unacceptable level?
The next step, therefore, is to prepare the script for a load test and set it up
to gather response time data. In this lesson you will learn about different
methods to enhance the script and to make it more effective for the load
testing process.
In this lesson you will cover the following topics:
How do I measure business processes?
How do I emulate multiple users?
How do I verify Web page content?
How can I produce debugging information?
Did my test succeed?
How do I measure business processes?
When preparing an application for deployment, you need to measure the
duration of specific business processes—how long does it take to log in,
book a flight, and so on. These business processes are normally made up of
one or more steps or actions within your script. In LoadRunner, you
designate a series of actions you want to measure by marking them as
transactions.
LoadRunner gathers information about the time it takes to perform a
transaction and displays the results in color-coded graphs and reports. You
use this information to see if the application meets the original
requirements.
You can manually insert a transaction anywhere in your script. The way to
mark a user step as a transaction is to place a start transaction marker before
the first step of the transaction and an end transaction marker after the last
step.
In this section you will insert a transaction in your script to measure the
amount of time it takes for the user to find and confirm a flight.
Open the script Basic_Tutorialwhich you created in Lesson 3. If it is still
open you can select the tab displaying its name, otherwise you can open it
from the File menu.
Notice how the Start Transaction and End Transaction markers have now
been added to the tree as new steps at the precise points where you inserted
them.

How do I emulate multiple users?
In your emulation, you tracked a user booking a flight and choosing an aisle
seat. In a real-life setting, however, different users will have varying
preferences. To improve your test, you therefore need to check if the
booking will work when users choose different seating preferences (aisle,
window, or none).
To accomplish this, you will parameterize the script. This means that you
take the recorded value, Aisle, and replace it with a parameter. You will place
values for the parameter in a parameter file. When you run the script, the
Vuser will take values from the parameter file (aisle, window, or none)
thereby emulating a true travel agency environment
5 Specify some sample values to vary the data.
Click Add Row. VuGen adds a row to the table. Replace the word Value with
Window.
Click Add Row. VuGen adds a row to the table. Replace the word Value with
None.
Note that the values are not case sensitive.
Keep the default settings in the Select column and File format sections of the
dialog box.
6 Define how the test will vary the data.
Keep the default setting that instructs VuGen to take sequential values for
each iteration—not random values.
Select next row: Sequential
Update value on: Each iteration
7 Click Close to close the Parameter Properties dialog box, and click OK to
close the Step Properties dialog box.
You have now created a parameter for the seating preference. When you run
the load test, the Vusers will use the parameter values instead of the
recorded value, Aisle.
When you run the script, the replay log shows the parameter substitution
that occurs for each iteration. You will see that for the first iteration, the
Vuser chose Aisle and for the second iteration, the Vuser chose Window.
How do I verify Web page content?
When running a test, you often need to verify if certain content is found on
the returned page. A content check verifies that expected information appears
on a Web page while the script is running. You can insert two types of
content checks: a text check and an image check.
Atext check checks that a text string appears on a Web page.
Animage check checks for an image on a Web page.
Looking for Text
In this section, you will add a text check that checks that the phrase "Find
Flight" appears on the reservations page in your script.
To insert a text check:
1 Open the Content Check Wizard.
Ensure that the Task pane is displayed (If not click the Task button). In the
task pane under the heading Enhancements, click Content Checks.
The Content Check wizard opens displaying thumbnails of each step in the
script.

Select the Page View tab in the right pane to display snapshots of the
thumbnails.
2 Select the page containing the text you want to check.
Click the fourth thumbnail entitled reservations.pl.
3 Select the text that you want to check.
Highlight the words Find Flight within the snapshot. With the words
selected, right click and select Add a Text Check (web-reg-find).
The Find Text dialog box opens displaying the text you selected in the
Search for specific Text box. Click OK.
4 View the new step.
In tree view (View > Tree View) you will notice that VuGen inserts a new
step, Service:Reg Find, into the script. This step registers the text check—
LoadRunner checks for the text after running the step. During replay,
VuGen will look for the text Find Flight and indicate in the replay log
whether or not it was found.
Looking for an Image
In this section, you will insert an image check to verify that the image fmagateway.
jpgappears on the page after the users log off.
To insert an image check:
1 Choose View > Tree View to return to tree view.
2 Select the page containing the image you want to check.
Select the Image: SignOff Button step. Select the Page View tab in the right
pane to view the step’s snapshot.
3 Insert an image check step.
Choose Insert > New Step. The Add Step dialog box opens
Expand Web Checks and select Image Check. Click OK. The Image Check
Properties dialog box opens.

4 Specify an image.
In the Specification tab, check the option Image server file name, and enter
the name of the image, fma-gateway.jpg, in the edit box.
Click OK. Note that VuGen inserts the Image Check step as a sub-step of the
Image: SignOff Button step.
5 Save the script.
During replay, VuGen will look for the image fma-gateway.jpg and indicate
in the replay log whether or not it was found.
How can I produce debugging information?
At certain points during the test run, you often need to send messages to the
output, indicating your location and other information. These output
messages will appear in both the replay log and in the Controller’s Output
window. You can send a standard output message or a message that
indicates that an error occurred.
Did my test succeed?
In this section, you will run the enhanced script and view the replay log for
text and image checks. You will view the text and image checks, the
transactions, and the parameterization.
By default, image checks are disabled during playback since they require
more memory. If you want to perform an image check, you need to enable
checks in the run-time settings.
1 Enable image checks.
Open the Run-Time settings (Vuser> Run-Time Settings) and select the
Internet Protocol: Preferences node. Select the Enable image and text check
option. Click OK to close the Run-Time Settings dialog box.
2 Run the script.
Click the Run button or choose Vuser> Run. VuGen begins running the
script, creating a replay log in the Output window. Wait for the script to
finish running.
3 Locate the text check.
Ensure that the output window is open (View > Output Window). Click in
theReplay Log tab and press Ctrl+F to open the Find dialog box. Search for
web_reg_find. The first instance says as follows:
Registering web_reg_find was successful.
This is not the actual text check—it only prepares VuGen to check for the
text after the form submission.
Search again (F3) for the next instance of web_reg_find. This instance
indicates:
Registered web_reg_find successful for “Text=Welcome” (count=1).
This verifies that the text was found. If someone changes the Web page and
removes the word Welcome, then in subsequent runs, the output will
indicate that the text was not found.

No comments:

Post a Comment