cancel
Showing results for 
Search instead for 
Did you mean: 

groovy scripting question (load testing related)

Super Contributor

groovy scripting question (load testing related)

Hello,
I have a test case which i am using in a load test. In this testcase I call a webservice function for which I need a valid user. To get this valid user I query  the database to get some random user. This works fine when I run a simple testcase. However in a 200 thread load test, I guess what is happening is that I open 200 connections to my database to a get a random user.  One connection for each thread. This is putting extra load on the DB server which I don't want.

How can I script such that 200 scripts share the database connection. Is this possible.

My current stepstep is something like this
GlobalFunctions gb = new GlobalFunctions();
gb.GetRandomUser(context, "AuthenticateUser - Request 1")

In the constructor, I connect to the database.

Thanks

Ali
2 REPLIES 2
Super Contributor

Re: groovy scripting question (load testing related)

I think i figured out the problem. I was not closing connection in my groovy script. I also made the def sql static (i believe this will cause the sql object to be shared among the threads?)

so now my constructor has something like

try
{
if(sql)
{
sql = Sql.newInstance(connectionString)
}
}

Does this look ok ?
Super Contributor

Re: groovy scripting question (load testing related)

Hi Ali,

Maybe you could create a static synchronized method inside your GlobalFunctions object which would create a static connection on the first call and then reuse that for later queries.. I think this is in line what you already are trying to do !?

regards!

/Ole
eviware.com
New Here?
Join us and watch the welcome video:
Top Kudoed Authors