专注于软件性能测试与自动化测试的学习与应用

LoadRunner levels of integration with web pages

上一篇 / 下一篇  2011-06-11 10:22:52 / 个人分类:LoadRunner

******本文非原则******

LoadRunner basically allows two approches for load testing your web application. Before going into details lets see how communication between user and web server looks like.

As you can see between user and web server there are mainly 2 layers:

  • Layer 1is where user interacts with the browser by e.g. clicking a button, selecting values from the list or submitting a form.
  • Layer 2is where browser communicates with web server which includes:
    • creating and sending HTTP requests to the web server based on user’s actions
    • receiving HTTP responses from the web server
    • rendering HTTP responses, forming an UI and displaying it to the user

Below I’m providing two scripts that do exactly the same thing but in slightly different way. The goal for each script. is to search for a “linux” word using google search.

First, lets look at “Web (HTTP/HTML)” type of the script.:

  1. Action()
  2. {
  3.         web_url("www.google.com",
  4.                "URL=http://www.google.com/",
  5.                "Resource=0",
  6.                "RecContentType=text/html",
  7.                "Referer=",
  8.                "Snapshot=t1.inf",
  9.                "Mode=HTML",
  10.                 LAST);
  11.  
  12.         lr_think_time(6);
  13.  
  14.         web_url("search",
  15.                "URL=http://www.google.co.uk/search?hl=en&source=hp&q=linux&btnG=Google+Search&meta=&aq=f&oq=",
  16.                "Resource=0",
  17.                "RecContentType=text/html",
  18.                "Referer=http://www.google.co.uk/",
  19.                "Snapshot=t2.inf",
  20.                "Mode=HTML",
  21.                 LAST);
  22.  
  23.        return0;
  24. }

What happens here?

  • In line 3 we are entering google.com web site
  • In line 14 we are sending HTTP request that browser would generate after searching for value “linux”

Now, lets look at “Web (Click and Script)” type of the script.:

  1. Action()
  2. {
  3.  
  4.         web_browser("www.google.com",
  5.                 DESCRIPTION,
  6.                 ACTION,
  7.                "Navigate=http://www.google.com/",
  8.                 LAST);
  9.  
  10.         web_edit_field("q",
  11.                "Snapshot=t1.inf",
  12.                 DESCRIPTION,
  13.                "Type=text",
  14.                "Name=q",
  15.                 ACTION,
  16.                "SetValue=linux",
  17.                 LAST);
  18.  
  19.         web_button("INPUT",
  20.                "Snapshot=t2.inf",
  21.                 DESCRIPTION,
  22.                "Type=submit",
  23.                "Tag=INPUT",
  24.                "ID=",
  25.                "Value=Google Search",
  26.                 ACTION,
  27.                "UserAction=Click",
  28.                 LAST);
  29.  
  30.        return0;
  31. }
  • In line 4 we are entering google.com web site
  • In line 10 we are typing value “linux” into the input field
  • In line 19 we are clicking “Google Search” button that will move us to the page with search results

So what is the difference between these two scripts?

First script. operates on much lover level comparing to second script. It deals with HTTP requests without taking care about what actions user actually performs. It doesn’t care how fast user’s browser renders and display the UI. It only checks how fast web server is able to response with correct message.

Second script. operates only on UI level without taking care what happens underneath. Response time here includes not only time needed to send/receive HTTP traffic but also time needed to form/display UI to the user.

Basically second script. approach is less error prone because you don’t have to deal with low level things like HTTP parameters. And You are replicating user’s actions in a natural way.

So if you need to choose, then I would recommend Web Click and Script. type of the script.

LoadRunnerLoadRunner,performance

Average transaction response time vs Granularity

November 7th, 2009
No comments

Correct me if I’m from but I always thought that for particular transaction there should be only ONE average response time. But it looks like it’s not the case in LR Analysis.

I recently discovered that by changing granularity on average transaction response time graph, Analysis also recalculates average times under the graph. In my understanding granularity is responsible only for making the graph easier to read and thats all it should do. But by changing granularity we are also changing how many points LR actually counts which results in different average response times for different granularity.

So shame that this is not mentioned in the manual. Of course according to HP support it is mentioned there and this is a feature, not a bug:)

So my tip for today: be careful when looking at response times on average transaction response graph. Use “Summary” page if you want to omit any mistakes.

LoadRunneranalysis,granularity,response time

Exception ACCESS_VIOLATION

November 7th, 2009
No comments

Web (HTTP/HTML) scripts in LoadRunner are implemented using C programming language. And like always with C, you should remember about some basics. One of them is that few string handling function can return NULL value instead of correct pointer which will definitely lead to exception like the one below:

  1. Action.c(7): Error: C interpreter run time error: Action.c(7):  Error — memory violation : Exception ACCESS_VIOLATION received.

Basically if you see message like this, it is not any internal LoadRunner error. It means that you made a mistake in your script. and you need to fix it. But let’s start from the beginning with some example:

  1. Action()
  2. {
  3.        char* x_p;
  4.        
  5.         lr_save_string("hello_world!","MESSAGE");
  6.         x_p =(char*)strchr(lr_eval_string("{MESSAGE}"),‘ ‘);
  7.         lr_save_string(x_p,"MESSAGE_FROM_SP");
  8.         lr_output_message(lr_eval_string("{MESSAGE_FROM_SP}"));
  9.        
  10.        return0;
  11. }

This small piece of code takes parameter MESSAGE with value “hello_world”, then search for the first space character and display the string starting from that place up to the end. Function strchr() is responsible for searches for the space character. If it’s found then strchr() will return a valid pointer (something like 0xb36ac56e). But if the space is not there (which is our case since there is no space in the hello message), strchr() will return NULL which refers to 0×0 memory address location.

Such memory address is a very special address. Basically any read attempt from there is threated as incorrect operation and results in memory access violation (not only in LoadRunner).

Now, howto deal with it? If you see ACCESS_VIOLATION, in most cases it means that your LR script. is working on incorrect/incomplete values. You are responsible for error handling in your scripts and you should always:

  • validate parameter’s values
  • check results of C functions to handle any errors, unexpected conditions
  • remember that you can’t always expect correct values and you need to handle it as well

Here is our example with fix showing howto deal with ACCESS_VIOLATION. We are calling strchr() function and checking if value returned is not NULL.

  1. Action()
  2. {
  3.        char* x_p;
  4.        
  5.         lr_save_string("hello_world!","MESSAGE");
  6.         x_p =(char*)strchr(lr_eval_string("{MESSAGE}"),‘ ‘);
  7.        
  8.        if(x_p)// if the pointer is not NULL display correct message
  9.        {
  10.                 lr_save_string(x_p,"MESSAGE_FROM_SP");
  11.                 lr_output_message(lr_eval_string("{MESSAGE_FROM_SP}"));
  12.        }
  13.        else//if pointer is NULL display error message
  14.        {
  15.                 lr_error_message("Space not found in MESSAGE parameter");
  16.        }
  17.        return0;
  18. }

TAG:

 

评分:0

我来说两句

cow

cow

个人主要专注于性能测试与自动化测试方向的学习与应用

日历

« 2024-04-23  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 12841
  • 日志数: 13
  • 建立时间: 2011-03-08
  • 更新时间: 2011-06-12

RSS订阅

Open Toolbar