I have experienced the need of generating UUID in LoadRunner several times while scripting but there is no in-build function to do so. Therefore, I had to use a custom function to satisfy my need.
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer systems. The term globally unique identifier (GUID) is also used.
In its canonical textual representation, the sixteen octets of a UUID are represented as 32 hexadecimal (base 16) digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters (32 alphanumeric characters and four hyphens). For example:
2be78146-f869-4a4c-b2c2-8ff3db023c57
You can generate a simple random UUID by using LoadRunner parameter (as shown below), however it does not generate your standard UUID and your request may fail. Snapshot 1
Action(){
char r_UUID[50];
sprintf(r_UUID,
"%s%s-%s-%s-%s-%s%s%s",
lr_eval_string("{r_hex}"),lr_eval_string("{r_hex}"),
lr_eval_string("{r_hex}"),
lr_eval_string("{r_hex}"),
lr_eval_string("{r_hex}"),
lr_eval_string("{r_hex}"),lr_eval_string("{r_hex}"),lr_eval_string("{r_hex}"));
lr_save_string(r_UUID, "PAR_GUID");
lr_output_message("Random UUID : %s", lr_eval_string("{PAR_GUID}") );
return 0;}
Thanks to Scott Moore for writing a code which uses windows in-build CoCreateGuid function (dependent on ole32.dll) to generate required UUID. However that code is completely dependent on windows platform and doesn't work in Linux platform (If you want to use linux server as your Load Generator). In order to overcome the OS dependency, I have come up with the below mentioned solution
Aucun commentaire:
Enregistrer un commentaire