The LoadRunner Blog

Tuesday, October 31, 2006

1 User logging in 100 times? or 100 Users logging in only once?

Peter Dhondt has an interesting answer for the oft asked question . This is on the Loadrunner yahoogroups.

This is on the subject of 200 Vusers and the same/different user id's for your test.

It really doesn't matter if the same user can log into the application multiple times or not unless you want to use the same user ID and password for all of your users. But before you can answer that you need to find out a few things.

Typically you would want to use different user id and passwords for your test and here's why:

When a user logs into an application a memory space is created on the backend for that user. Lets call it a workspace for that user. Most applications will share the same workspace if the same user is logged into the application more than once. Here is where your problem is....If the same user is logged into the application 200 times then that user is typically sharing one piece of memory but if 200 users are logged into the application then there will be 200 different workspaces each with their own chunk of memory.

Now in some ERP applications (SAP, Oracle NCA, Peoplesoft)it treats each login as totally separate users and will spawn 2 memory spaces for John being logged in twice. So in that case if your application treats each user login as separate and does not share memory then you can use the same user id 200 times and it would be a legit test. But when you login with 200 (John Smiths) and you have system errors you might be asked which user got the error...Well John Smith did...and you have 200 of them logged into the application at the same time which can be difficult to figure out which user had the problem.

Hence going back to the...."You should have 200 different user IDs".

1. Can you log in multiple times?
2. If you log in multiple times does the system treat it as separate logins or does it share the workspace because it is the same user?
3. If it shares memory I would suggest NOT using the same user ID multiple times.
4. If it treats them as totally separate users then you CAN use the same ID 200 times as long as you understand that error analysis can be very difficult because you can't determine who did what because they all have the same ID's.

5. To be safe and sure you would be better off in the long run getting or creating 200 different user id for this test.

Tuesday, October 17, 2006

The Black Anvil: Shootout: Load Runner vs The Grinder vs Apache JMeter

The Black Anvil: Shootout: Load Runner vs The Grinder vs Apache JMeter

Gives a nice overview of the features of the Load Testing tools. Worth visiting.

Dynamic Transaction Names in LoadRunner

Say you want the transactions to be named dynamically depending on a parameter being used. You can use sprintf and lr_eval_string functions to dynamically create the trn names. Here is the sample code


Action()
{

char trnname[10];

sprintf (trnname, "Item_%s", lr_eval_string("{TrnType}"));
lr_start_transaction(trnname);
web_submit_data("Payment Done",...... ) ;
lr_end_transaction(trnname, LR_AUTO);

return 0;
}

Tuesday, October 03, 2006

Using ORD=ALL and getting a Random Value from Array

TOOL : LoadRunner 8.1

This code is used for getting a bunch of values returned by the server and randomly selecting one of them to use in the next weburl step. Imagine searching for a number of items on ebay and then clicking one of the results... Paste the code in the Action () step.


//declare variables
int IterNum, ItemNumCount, RandNum;
char* temp;
char RandNumStr[20];
char namestr[20];

web_reg_save_param ("ItemNumArray", "LB=/catalog/product/index.cgi?catalog_number=", "RB=&", "ORD=All", LAST);
web_submit_data("Send Search Term and Get Results",
"Action=https://alpha.test.com/psearch/searchProcessor.jsp",
"Method=GET",
"EncType=",
"RecContentType=text/html",
"Referer=https://alpha.test.com/index.cgi?osid=RSEupwwUN8gAAEQuCts",
"Snapshot=t7.inf",
"Mode=HTTP",
ITEMDATA,
"Name=org_id", "Value=2003521", ENDITEM,
"Name=custpartgrp", "Value=WEB", ENDITEM,
"Name=cntry", "Value=us", ENDITEM,
"Name=Nu", "Value=RollupKey", ENDITEM,
"Name=spage", "Value=header", ENDITEM,
"Name=Np", "Value=2", ENDITEM,
"Name=Ntt", "Value={SearchParam}", ENDITEM,
"Name=Ntk", "Value=All", ENDITEM,
LAST);

//Display array count
lr_output_message ("Number of Items in Array : %s",lr_eval_string("{ItemNumArray_count}"));
ItemNumCount = atoi(lr_eval_string("{ItemNumArray_count}"));

//Parse thru array and display all the results
for (IterNum=1; IterNum<=ItemNumCount; IterNum++) {
sprintf(namestr, "{ItemNumArray_%i}",IterNum);
lr_save_string(lr_eval_string(namestr), "TempItemNum");
lr_output_message("Saved Item Number: %s", lr_eval_string("{TempItemNum}"));
}

//Generate a Random Number
RandNum = 1 + rand() % ItemNumCount;

//SAve Random Number to String
itoa (RandNum,RandNumStr,20);
lr_output_message("Random Number Generated is :%s", lr_eval_string(RandNumStr));

//Saves RandNumStr into random_value
lr_save_string(RandNumStr, "random_value");

temp = lr_eval_string(lr_eval_string("{ItemNumArray_{random_value}}"));
lr_save_string(temp, "RandItemNum");

//Use RandNumStr variable in a weburl step
web_url("Click on Random Product Page",

"URL=https://alpha.test.com/index.cgi?catalog_number={RandItemNum}&inE=1",
"Resource=0",
"RecContentType=text/html",
"Referer=https://alpha.test.com",
"Snapshot=t11.inf",
"Mode=HTTP",
LAST);

return 0;