Tuesday, May 20, 2014

Loadrunner MAPI Protocol

The comments made here about the Loadrunner MAPI protocol are applicable for Loadrunner version 8.1. MAPI is Loadrunner’s Microsoft Exchange protocol.

I had reasonably straight forward objectives for a test I was preparing. Ramp up a few hundred users who would simulate use of Microsoft Exchange, i.e. users who were logging on, sending and receiving emails

I expected that Loadrunner would work with Outlook much like Loadrunner works with Internet Explorer. Loadrunner can simulate Internet Explorer with multiple users and sessions all working independently. Whilst working with the MAPI protocol I discovered that Loadrunner struggles to interact with Outlook. Some of the problems encountered were:


1) Not all of the statements worked. While they did not cause any problems, they just did not do what they were supposed to do. For instance:

The following statement should return a message ID, which it didn’t.

msgid = mapi_get_property_sz_ex(&mapi, "Message ID");

The following statement deleted a mail, but would not delete another email unless the logon statement was reissued on a fresh iteration:

mapi_delete_mail_ex(&mapi,"NextMail", "Show=all", LAST);

2) While the logon statement worked, it was not possible to logon a user to Outlook unless that user was logged onto the domain. Theoretically, the web_set_user will do this for you but it was not possible to introduce a web statement into the email script.

3) Configuring Outlook and permissions on the Injector machines was very much a trial and error process. Some handy hints:

Sessions can be run as local or global sessions. If running as a global session, the Loadrunner statements all finish with a suffix of _ex. The following settings are required: Define mapi as ‘MAPI mapi = 0;’

When using a global statement, stick ‘&mapi’ as the first parameter e.g.;mapi_logon_ex(&mapi, "Logon",

The logon statement is as follows:

mapi_logon_ex(&mapi, "Logon",

"ProfileName=Default Outlook Profile",

"ProfilePass=",

LAST);


To login a user, check the following settings:

The profile name can be found by; Right click Outlook; select properties; select show profiles. Funnily enough, the default Outlook profile is actually called ‘Default Outlook Profile’.

A mailbox for a user will be associated with an Outlook profile. This can be checked or amended by; Right click Outlook; select properties; highlight the profile and select properties; select email accounts; select view or change email accounts; select change / add / remove as appropriate.

In the logon statement above, password is not entered, mainly because it does not seem to be required.

More than one virtual user could be used per injector with this protocol, however, each virtual user per injector was accessing the same mailbox.It is worth increasing the mailboxes in size otherwise error messages will be returned if the mailbox fills up.

There is a setting in Exchange that detects if an automated program is running which may cause a popup message to be displayed. This will cause execution of the automation to stop. In fact, any popup will cause execution of the automation to stop.If anyone else has had a better experience with this protocol than I have, I would be very interested to hear about it.

You will find below a sample Loadrunner script that may help with your load testing project:

char * message;
char * msgid;
api;
int rc;
int i;
MAPI mapi = 0;
char msg_id;

Action()

{
// Get the Message identifier of current email message.

msgid = mapi_get_property_sz_ex(&mapi, "Message ID");

lr_output_message("the message id is %s", lr_eval_string("msgid"));
lr_start_transaction("P02S01_Logon");
mapi_logon_ex(&mapi, "Logon", "ProfileName=Default Outlook Profile", "ProfilePass=", LAST);
lr_end_transaction("P02S01_Logon", LR_AUTO);
lr_think_time(10);
lr_start_transaction("P02S02_Send");
mapi_send_mail_ex(&mapi,"SendMail",
"To={send}", //"To=Greg, David Marie",
"Subject=Test7 {GROUP}:{VUID} @ {DATE}",
"Body=Test Message! Please ignore.This is text inside the body of the email"
"111This is text inside the body of the email "
"111This is text inside the body of the email "
"111This is text inside the body of the email "
"111This is text inside the body of the email ",
"ATTACHMENTS", "File=C:\\readme.doc", "ENDITEM",
LAST);
lr_end_transaction("P02S02_Send", LR_AUTO);
lr_think_time(10);
lr_start_transaction("P02S03_Send");
mapi_send_mail_ex(&mapi,"SendMail",
"To={send}",
"Subject=Test8 {GROUP}:{VUID} @ {DATE}",
"Body=Test Message! Please ignore."
"222This is text inside the body of the email "
"222This is text inside the body of the email "
"111This is text inside the body of the email ",
"ATTACHMENTS", "File=C:\\readme.doc", "ENDITEM",
LAST);
lr_end_transaction("P02S03_Send", LR_AUTO);
msgid = mapi_get_property_sz_ex(&mapi, "Message ID");
lr_output_message("the message id is %s", lr_eval_string("msgid"));
lr_think_time(10);
lr_start_transaction("P02S04_Open_email");
mapi_read_next_mail_ex(&mapi,"NextMail",
"Show=all",
"Peek=false",
LAST);
lr_end_transaction("P02S04_Open_email", LR_AUTO);
/* lr_think_time(10);
lr_start_transaction("P02S05_Delete_email");
mapi_delete_mail_ex(&mapi,"NextMail",
"Show=all",
"Peek=false",
LAST);
lr_end_transaction("P02S05_Delete_email", LR_AUTO);
*/
for (i=0; i<(atoi(lr_eval_string("{randnum1}"))); i++)
{
lr_start_transaction("P02S04_Open_email");
rc = mapi_read_next_mail_ex(&mapi,"NextMail",
"Show=all",
"Peek=false",
LAST);
lr_end_transaction("P02S04_Open_email", LR_AUTO);
}
lr_think_time(10);
lr_start_transaction("P02S05_Delete_email");
mapi_delete_mail_ex(&mapi,"NextMail",
"Show=all",
"Peek=false",
LAST);
lr_end_transaction("P02S05_Delete_email", LR_AUTO);
return 0;

No comments: