Monday, April 13, 2009

How to debug Performance Scripts Issue in Loadrunner

Here are my thoughts:

1. Do you have content check points in your current load testing scripts?
If not, adding check points on the most critical actions for tracking; This is very important for the performance scripts design:
You may want to Check these:
http://joychester.blogspot.com/2009/01/lr-scripts-debuging-on-controller-try.html
http://joychester.blogspot.com/2009/03/content-check-for-web-service-calls-2.html
http://joychester.blogspot.com/2009/02/content-check-for-webservicecalls.html

2. Try to isolate the problem,not mix everything up at the same time.
You can run just one performance scripts at a time which has the problem, and you can run it under different user load, so that you may reproduce the issue easily or just guarantee that this script has no problem;

3. Checking the very first error you met in your scripts.
Usually it is the first thing you need to be caution when you running the load testing. Because it may trigger a tons of following errors, if you did not do error handling well

4. Try to look at the parameters/correlation value you use within the scripts.
This is a check point when you find there is an error on your scripts, make sure you use the write parameters/correlation value before you start to do other deeper investigation. It is not easy to find if you do not know the application very well

5. Of course you should run your scripts in Vugen successfully before running it in Controller.
But I want to remind is that you have to validate all the parameters or situations you may meet, such as using different accounts, different data, also do the Branch coverage if you have "if-clause" in your scripts. So you may get my idea--"Do your unit test on your test scripts" :)

6. Sometimes or more often,The errors may just related to the load you add to the system, not caused by scripts itself.
This errors are only reproduce under a certain load, so it might not be a scripts issue... You can do a load test on your scripts to verify your idea--10 users load, 20 users load, 30... till you get such an error.
But one kind of error is not related to the load, for example, you just input one column which need to be unique value, but in your scripts does not implement this well, so that in Vugen(single user load) or even low load you will not get kind of error, however, if two thread generate this value at the same time, then you may get duplicated value for these two users...thus, you will get an system error,but actually this is absolutely a scripts issue! Be careful!

7. Last and the best practice--After running your scripts in Vugen, please look at your application whether the scripts make the action happen or not, you should believe your eyes, right? :)

Tuesday, April 07, 2009

How to generate random number in a dynamic world

Besides the random number by Loadrunner parameter itself, usually you need to create a Random number of which range is based on the correlated result, for example, you want to check a check-box which number is dynamically changed:



int checkbox_num1=0;
char Randomitem[10];
char RandomStatus[10];
char SRanStatus[10];
...

web_reg_save_param("Checkbox_name1",
"LB=TableSelectCheckbox-_dash_",
"RB=)\" >",
"ORD=ALL",
LAST);

web_submit_data(...
.... );

checkbox_num1 = atoi(lr_eval_string("{Checkbox_name1_count}"));

srand(time(NULL));

if (checkbox_num1>0) {

itoa(rand() % checkbox_num1 +1,Randomitem,10);

sprintf(RandomStatus,"{Checkbox_name1_%s}",Randomitem);

sprintf(SRanStatus, "%s", lr_eval_string(RandomStatus));

lr_save_string(SRanStatus, "CheckboxORD");

}

else if (checkbox_num1==0) {//there is no any suitable value found

lr_exit(LR_EXIT_ITERATION_AND_CONTINUE, LR_AUTO);

}

Loadrunner: How to insert a charactor(s) into a string

I want to replace the '\' into '\\' in one string, here is my implementation in Loadrunner:


char * position;
int i=0;
int j=0;
Char * SRanStatus2_backup;
Char SRanStatus2[50]="abcc\dada-com";

SRanStatus2_backup= (char *)malloc(50 * sizeof(char));

memset(SRanStatus2, 0, sizeof(SRanStatus2));

memset(SRanStatus2_backup, 0, sizeof(SRanStatus2_backup));

position = SRanStatus2;

while ((*position)!= NULL) {

if ((*position)!='\\') { //if ((*position)!='\x07') {

SRanStatus2_backup[j]=SRanStatus2[i];
i++;
j++;
}

else if ((*position)=='\\') { //else if ((*position)=='\x07') {
SRanStatus2_backup[j]='\\';
SRanStatus2_backup[j+1]='\\';
j=j+2;
i++;
}

position++;
}

SRanStatus2_backup[j]='\0';

lr_save_string(SRanStatus2_backup, "CheckboxORD_2_backup");

free(SRanStatus2_backup);
free(SRanStatus2);

return 0;

Friday, April 03, 2009

A Joke on a Slow response page

My friend and I take a look at one website, when we got to one page, it takes almost 2 mins loading...

Me: So damn slow page, and no useful information. Let's go to another page to have a try

I was taking my mouse to try to click next link, while my friend stop me at once!

My friend speak seriously: NO! NO! NO! Let's treasure this Hard-earned page, take more seconds on it to retrieve our time losses, even it give us nothing information...

we just stared at that slow page for a few seconds quietly, and never come back in the future

Tuesday, March 31, 2009

JVM (GC) tuning useful links and Netbeans Heapwalker demo project

I want to add some useful document links which bring me up on this big topic--JVM (GC) tuning:
http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html
http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html
http://java.sun.com/performance/reference/whitepapers/tuning.html
http://java.sun.com/j2se/1.5.0/docs/guide/vm/gc-ergonomics.html
http://java.sun.com/j2se/1.5/pdf/jdk50_ts_guide.pdf
http://java.sun.com/j2se/1.5.0/docs/guide/vm/server-class.html

For Heap dump analyzer, apart from Eclipse Memory Analyzer, there is another Cool free analyzer tool,Netbeans HeapWalker:
http://profiler.netbeans.org/docs/help/6.0/heapwalker.html

here is one very interesting HeapWalker Demo, for QA people who is interesting in trying to tune the performance memory issues, you may go through this message and get some sense of performance tuning by yourself :)

http://wiki.netbeans.org/HeapWalkerDemo

Tuesday, March 24, 2009

Dining Philosophers Game--how to make Deadlock issue

Try this game if you do not want to write a code to implement the deadlock issue:
snapshot:


play at below :
http://wwwhomes.doc.ic.ac.uk/~jnm/book/book_applets/Diners.html

利用Firebug实现Google Maps中国的地理译码

2007年8月在北京参加首届研究生地理信息系统论坛,在论坛上有幸介绍了一下陈汝烨和我在创建roommap网站时期的一个地理译码的过程,现在Google Maps中文的地理译码已经公开了一些地理译码信息,之前需要自己去“hack”这部分信息:
http://www.codechina.org/doc/google/gmapapi/#Geocoding_Etc

所谓地理译码:是把地址(如"1600 Amphitheatre Parkway, Mountain View, CA")转换为地理坐标(如经度-122.083739,纬度37.423021)的流程,您可以用它把数据库里面的街道地址或用户提供的地址信息标记在地图上。

现在将我们俩当时(2007年)的思路共享给大家:

摘 要:目前Google Maps 中国的API已经提供了地图所需要的基本服务,比如任何网站可以引用浏览Google maps中国地图,以及一些简单应用比如显示气象图等,但使用者不能进行地理译码。地理译码是把地址(如“中国科学院遥感应用研究所”)转换为地理坐标(如经度-122.083739,纬度37.423021)的过程。通过它,您就可以把数据库中的街道地址或用户提供的地址信息标记在地图上。但是,到目前为止,在Google maps US 已经实现了地理译码的API(GClientGeocoder 类中有相应的方法实现)。Google Maps中国地图中,用户可以对地名搜索并进行地理坐标定位,然而,中文 Google Maps API尚不提供地理译码功能。不过,我们可以根据Google提供的规范开发自己的地理译码器。本文介绍了利用Google maps网络已有资源,如何实现对中文地理位置名称到地理经纬度坐标的转换,从而在自己的网站中利用Google maps中国对任何国内的地理位置进行搜索定位。

作者采用Firebug监测工具,分析Google中国地图程序产生的Http响应,从中解析经纬度坐标信息,最终实现Google Maps中国的地理译码功能。

首先登录http://ditu.google.cn/网站,将需要查询的地名提交并提交。查看Firebug中获得命名为maps的Http响应(response),从相应的html文本中发现名为markers: [] 数组, [] 内每个id: 的内容就表示一个对象或称一个地理信息结果。由此按照markers: [] 数组内对象(或id)的数量,我们可以把地理译码过程分成一下三种情况:

1. markers: [] 数组中有多个对象(或id)。比如搜索“扬州大学“,那么地图上可以得到多个结果,包含扬州大学的多个校区的地址。在这种情况下markers: [] 数组中每个对象(或id)存在一个geocode的属性,在这个属性中我们发现了一个没有经过加密的该地址的地理坐标。因此,我们可以直接用正则表达式获取到改对象(或id)的经纬度信息,从而遍历得到每个地址的地理位置。

2. markers: [] 数组中仅有一个对象(或id)。比如搜索“中国科学院遥感应用研究所”,只有一个精确地址。这种情况下的http响应结果中包含一个markers数组,数组长度为1,这个数组包含的元素对象有laddr和mapabcPoiid两个属性。laddr就是中文地址描述,而作者发现Firebug监测到浏览器发送了标识为mapabcPoi的请求,从地址中中可以看到 Google地图的地理数据用的mapabc.com的数据,那么推断mapabcPoiid是该地理点在mapabc数据库中的标识符。作者查看mapabcPoi请求的响应内容(response),得到类似这样的代码notpcoStrbase64=…发现这个结果应该是base64编码后的结果,所以作者利用base64解码后就可以获得该地址的地理坐标了。

3. 找到多个不确定的结果。这种情况下,返回结果中包含一系列的建议的地址,比如搜索“上海马戏城” ,结果提示您找的是不是“某某路上的马戏城”。从响应的html文本中利用正则表达式取得这些建议的地址,然后再重新搜索就可以得到建议地址的坐标了

《注:代码部分已经由陈汝烨同学利用javascript实现》

结语:有时候,结果并不重要,过程更重要 :)

LR Vugen become slow when scripts is running with parameter notepad file opened

Today, I notice that LR(9.0) Vugen become slow when scripts is running with parameter notepad opened.

Vugen seems like a "snail" to execute your scripts line by line, once you close the parameter notepad file, then it become normal.

I am sure it is a bug in LR 9.0 , at least it is not fit my expectation :)

Monday, March 23, 2009

content check for web service calls (2)

I have written one way to do the XML content check for web service call:
http://joychester.blogspot.com/2009/02/content-check-for-webservicecalls.html

Here is another simple way to do this in Loadrunner if you find hard to write a Query(Xpath) in lr_xml_find:

Char Position;
......

lr_start_transaction("web service transaction");

web_service_call( "StepName=echo_101",

"SOAPMethod=MyService.MyServiceSOAP12port0.echo",

"ResponseParam=response",

"Service=MyService",

"Snapshot=t1156241380.inf",

BEGIN_ARGUMENTS,

"xml:part1=*******",

END_ARGUMENTS,

BEGIN_RESULT,

"part1/EchoOutput=Param_EchoOutput2",

END_RESULT,

LAST);

//want to match if the response data include Success Key word
Position= (char *)strstr(lr_eval_string("{response}"), "Success");

if (Position!=NULL) {

lr_end_transaction("web service transaction", LR_PASS);

}

else {
lr_output_message("web service call error occured!Help!:)"
}

Sunday, March 22, 2009

Nike Hyperdunk Supreme Kobe

科比不是我的偶像,他的球技出众,领袖气质,虽不讨厌,但打球的风格不是我欣赏的那种(俺的偶像是皮蓬,纳什):)

今天无意中在Nike factory看到了这双黑的出众的Nike Hyperdunk Supreme Kobe's PE, 是在去年10月份上市的,比起奥运版的白灰色,我觉得这款更具科比的个性--720CNY拿下(原价1250CNY):
“黑夜给了我黑色的眼睛,我却用它来寻找光明”:



还有一点,如果有你非常喜欢的鞋子,而且觉得贵,请忍耐半年的时间,然后去折扣店淘,祝你好运!