cancel
Showing results for 
Search instead for 
Did you mean: 

LoadTesting / SQL / ThreadIndex question

Highlighted
Super Contributor

LoadTesting / SQL / ThreadIndex question

Hello,
I am using thread strategy to run a load test. I have a file input as a datasource and my file name is specified something like C:\datafiles\{threadindex}.txt. So I have a few files in the datafile folder and depending on the threadindex, each thread picks a seperate file. This works fine but it becomes a hassle as database is dropped and I have to regenerate the files.

My question is
If I use JDBC as my datasource and my SQL Query is something like

WITH Ordered AS
(
      SELECT ROW_NUMBER() OVER (ORDER BY Email) AS RowNumber, Userid, isapproved, email
        FROM aspnet_Membership
) SELECT *
        FROM Ordered
        WHERE RowNumber between 1 and 100

which will  give me the first 100 records. Is is possible to do some sort of a conditional SQL where the range of Rows is dependent on the ThreadIndex
so that if ThreadIndex = 2 I want my SQL Query to be
WITH Ordered AS
(
      SELECT ROW_NUMBER() OVER (ORDER BY Email) AS RowNumber, Userid, isapproved, email
        FROM aspnet_Membership
) SELECT *
        FROM Ordered
        WHERE RowNumber between 200 and 300

That or maybe some groovy script that creates the needed datafiles from the database so that the file content is always current.

Thanks
3 REPLIES 3
Highlighted
Super Contributor

On second thought, I think I would prefer a Groovy file that creates me 5 files... Username0.txt, Username1.txt....
Each of them would contain a different range of records from the database. If you can give me some code that accomplishes this, I would really appreciate it.

Thanks

ALi
Highlighted
Super Contributor

Please ignore the post. Just need some help with the SQL

I have the following groovy code

String query = "WITH Ordered AS (SELECT ROW_NUMBER() OVER (ORDER BY Email) AS RowNumber, email FROM aspnet_Membership) SELECT email FROM Ordered WHERE RowNumber between 0 and 10 "

List myList = sql.rows(query)
log.info(myList)

This give me out in the format.
{email=ARAZA-LT7823504795@ARAZA-LT7823504795.com}, {email=ARAZA-LT78235142339@ARAZA-LT78235142339.com}, {email=ARAZA-LT79105027214@ARAZA-LT79105027214.com}, {email=cpsadmin@tvguide.com}, {email=CPSLOAD1_0_713113251753@CPSLOAD10713113251753.com}, {email=cpsuser015@tvguide.com}, {email=cpsuser016@tvguide.com}, {email=cpsuser022@tvguide.com}, {email=cpsuser023@tvguide.com}

How can I construct the SQL such that I get only comma delimited emails with 'email='. so something like

23504795@ARAZ3504795.com, ARAZA-LT7ARAZA-LT7823504795.com, ARAZA-LT795@ARAZA-LT78235.com


Thanks

Ali
Highlighted
Super Contributor

Hi Ali,

hmm.. I guess the List you are getting back from sql.rows(..) is a list of maps containing each rows values, so maybe you will need to loop these and build the desired string manually

def str = ''
myList.each
{
  if( str.length() > 0 ) str += ','
  str += it['email'];
}

log.info( str )

Hope this helps!

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