0

During my load test, I would like to fetch values from an SQL database. How can I achieve this on load runner TrueClient protocol using JavaScript?

This would be great help…

Patrick Hund
  • 19,163
  • 11
  • 66
  • 95
  • 2
    indeed - what have you done about it so far? – Jaromanda X Jun 08 '17 at 06:28
  • Do not use this to pull data from the same environment under test as you will be placing a disproportionately large load on the system which is not present in production with your direct connections and your unoptimized queries – James Pulley Jun 08 '17 at 13:22
  • Spelling, added TruClient tag – Patrick Hund Jun 08 '17 at 15:19
  • If you do that you might be load testing your SQL server and not your application – Buzzy Jun 11 '17 at 05:29
  • In my case am not going to fetch the value from the Application database. Here i will using the different Database altogether which would be my source of test input to my load test. @JamesPulley – Aravinth Amir Jun 13 '17 at 05:56
  • Use a queue. VTS ships in the Box. RabbitMQ is a great alternative. You could probably even use the serverless queue options on AWS, ClooudAzure, IBM Cloud, .... – James Pulley Jun 13 '17 at 13:12

2 Answers2

0

Important: This will only work in TruClient (IE) and not in TruClient (Firefox).


Enter a new "Eveluate Javascript" step, and edit the javasctipt like so:

var connection = new ActiveXObject("ADODB.Connection") ;
var connectionstring="Data Source=<server>;Initial Catalog=<catalog>;User ID=<user>;Password=<password>;Provider=SQLOLEDB";

connection.Open(connectionstring);
var rs = new ActiveXObject("ADODB.Recordset");

rs.Open("SELECT * FROM table", connection);
rs.MoveFirst
while(!rs.eof)
{
   // Here you should get the value from the 1st cell, 1st column
   var value = rs.fields(1);
   rs.movenext;
}

rs.close;
connection.close; 
Koby Douek
  • 16,156
  • 19
  • 74
  • 103
  • Thank you for your reply. Let me try this and get back to you. But in my case we are using Trueclient firefox for the load test. Anything which supports firefox would be a great help. – Aravinth Amir Jun 13 '17 at 06:21
0

There are several options. I'll list them in order of their complexity:

Option 1: Use a parameter file to hold all of your data. If you need to modify it periodically, consider placing it in a shared location, accessible for all LGs.

Option 2: Use the Virtual Table Server (VTS) provided with LoadRunner. It is dedicated to sharing test data between virtual-users. Queries are easy with a built in API.

Option 3: You could write a custom C function, using LoadRunner DB API to query the DB, calling the function from your script using an Eval C step. Note this can only be done in VuGen.

e-Dough
  • 56
  • 3