Hello,
Run preferred Action in Loadrunner
One might encounter a scenario/requirement where a
specific Action needs to be Run in a LR script for a specific set of users in a sequence or probably randomly and to be run(action group users) in parallel.
Let's clearly define how we can implement this :
Problem Statement - When Multiple Actions are implemented for different functionality which might have a dependency on the previous action by just consuming single script.
To keep things simple lets pick for Script 1 that has 3 Actions , "Action1,Action2,Action3" , now load test has to be performed for functionality where virtual users need to
run in parallel and
one after the other Action.
Which means Action1 has
2 unique vusers , Action2 has
4 unique vusers and Action3 has
8 unique vusers. totaling =
14 vusers .
This is how it should be run --
Sequence - Action1 --> Action2 --> Action3
Here we are going to cover two concepts
Rendezvous points and Flags
The Solution is illustrated below :
The P_Flags.dat is as shown below :-
As one can see P_Flag1 corresponds to Action1 , P_Flag2 corresponds to Action2 and P_Flag3 corresponds to Action3
Since Action1 has 2 users hence contains 2 true values and similarly for other actions it is shown in multiples of 2
The Action files are implemented below , we use the Flag in this fashion so it runs only that specific Action when
TRUE
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Action1
{
int Flag1;
Flag1 = atoi(lr_eval_string("{P_FLAG1}")); // Value of P_FLAG1 is copied to Flag1
lr_rendezvous("2_Users"); // This creates a rendezvous point for 2 vusers which runs in parallel
if (Flag1 == 1)
{
// The steps for the functionality
sapgui_set_ok_code("/nUCMON",
BEGIN_OPTIONAL,
"AdditionalInfo=sapgui2015",
END_OPTIONAL);
sapgui_send_vkey(ENTER,
BEGIN_OPTIONAL,
"AdditionalInfo=sapgui2015",
END_OPTIONAL);
} //End IF
} // End of
Action1
Similarly for the remaining actions lets put the code
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Action2
{
int Flag2;
Flag2 = atoi(lr_eval_string("{P_FLAG2}"));
lr_rendezvous("4_Users"); // This creates a rendezvous point for 4 vusers which runs in parallel
if (Flag2 == 1)
{
// The steps for the functionality
sapgui_set_ok_code("/nUCMON2",
BEGIN_OPTIONAL,
"AdditionalInfo=sapgui2015",
END_OPTIONAL);
sapgui_send_vkey(ENTER,
BEGIN_OPTIONAL,
"AdditionalInfo=sapgui2015",
END_OPTIONAL);
} //End IF
} // End of
Action2
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Action3
{
int Flag3;
Flag3 = atoi(lr_eval_string("{P_FLAG3}"));
lr_rendezvous("8_User"); // This creates a rendezvous point for 8 vusers which runs in parallel
if (Flag3 == 1)
{
// The steps for the functionality
sapgui_set_ok_code("/nUCMON3",
BEGIN_OPTIONAL,
"AdditionalInfo=sapgui2015",
END_OPTIONAL);
sapgui_send_vkey(ENTER,
BEGIN_OPTIONAL,
"AdditionalInfo=sapgui2015",
END_OPTIONAL);
} //End IF
} // End of
Action3
Upon following these above steps one can achieve it very easily
Additionally, as a best practice one can also print/output the Group name if needed for better reporting
char TransName[70];
strcat(TransName,lr_eval_string("{P_CONS_GRP}")); // copy the group name to the string
then for the specific activity one can start and end the lr transactions like this
lr_start_transaction((char *)TransName);
lr_end_transaction((char *)TransName,LR_AUTO);
Contents of
P_CONS_GRP
For how to create Rendezvous points in LR , please refer to the document shown in the Comments section, I hope you find this useful!
Thanks
Dilip Mamidela , SAP India BLR