Highlighted
Absent Member.
Absent Member.
2449 views

Integrating LoadRunner C with Python

Are there any recommended guide lines on how to integrate a python script with loaadrunner c.
Specfically after a web_reg_save_param, my script saves a character string output. This output has to be massaged (escaping double quotes, making each line a string, terminating with a ;)and then fed as input to the next web service.
Using Python I have been able to get this done. I'd rather not use the system command to do this from the loadrunner c script since that will then become a bottleneck when running with high load.
7 Replies
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Integrating LoadRunner C with Python

I saw your post from years ago about integrating a python script into Loadrunner and was wondering if you ever found a solution. Can you call a python script from within Loadrunner?  Can data be passed between the two?

 

Beth

0 Likes
Highlighted
New Member.

Re: Integrating LoadRunner C with Python

Anyone????

0 Likes
Highlighted
New Member.

Re: Integrating LoadRunner C with Python

the thing is I have converted a python script to c using cythonise(). now I have .c file. but it needs python interpreter i.e python 2.7 or python 3 . I am able to see a python compiler is bundled with HP loadrunner but it is 2.5. 

whenever I try to do execute it replies  #error Python headers needed to compile C extensions, please install development version of Python. so my question can we upgrade this compiler ? will it result any issue in the application ?

0 Likes
Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Re: Integrating LoadRunner C with Python

Are you using LRP 2020 or LRP 2020 SP1?

0 Likes
Highlighted
New Member.

Re: Integrating LoadRunner C with Python

I am using LR12.60
how to check LRP version ?
I am new to LR
0 Likes
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Re: Integrating LoadRunner C with Python

0 Likes
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Re: Integrating LoadRunner C with Python

We don’t have official support of Python in our scripting.

However, in general it's ok for C to call Python code. It's not difficult to find some materials about how to call python from C language, by searching "call python from c language".

 

Another approach is to use a JMS compliant message queue in a multi-protocol script while enabling both Web HTTP/HTML and Web Service protocols (simply because LR exposes jms_* api in Web Service protocol).

Modify your LR script to add jms_send_message_topic when you want to invoke Python or any other progoramming languages, you can use Vuser Id as the topic parameter in the step which should be unique to all Vusers (i.e. create a parameter with Vuser ID type in your script).

Enhance your existing python code by adding extra JMS support to send/receive messages to/from LR and reuse your existing python script to do whatever you want.

Modify your LR script to add jms_receive_message_topic after previous send step, probably a while loop is needed to query whether the python code returns the result periodically, something like:

 

jms_send_message_queue("jms-send",
"hello jms sent from LR",
 lr_eval_string("dynamicQueues/QueueOfVuser{VuserId}"));

while(0 != jms_receive_message_queue("jms-receive",
 lr_eval_string("dynamicQueues/QueueOfVuser{VuserId}")) {

   lr_think_time(1);

}

 

For JMS vendors, you can try apache-activemq or others of your choice.

 

Regards,

Tedy

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.