1

I have ThreadGroup1 which performs login operation where it is getting Credentials from CSV file using CSV Dataset Config and saves username and password in two different variables like:

${__setProperty(USERNAMEGlobal, ${USERNAME})}
${__setProperty(PASSWORDGlobal, ${PASSWORD})}

Now in ThreadGroup2 I use these credentials using:

${__property()}

it works fine for a single user, but if I try multiple users (requests) last value overrides the previous all values and ThreadGroup2 receives only the last credentials defined.

I want all the credentials to be passed one by one to ThreadGroup2 and then the requests present in ThreadGroup2 should work according to all those credentials respectively.

How this can be done?

PS: I defined ramp-up period=1, Number of Users=3, loop=1.

Just_another_developer
  • 5,737
  • 12
  • 50
  • 83

3 Answers3

0

There are some options:

  • Inter-Thread Communication.
  • Put them to different properties:

    ${__setProperty(USERNAMEGlobal1, ${USERNAME1})}
    ${__setProperty(USERNAMEGlobal2, ${USERNAME2})}
    etc.
    
  • Initialize array with all usernames, stringify it and then put to property. However, it looks like a hack that will slow your plan.
Andrei Botalov
  • 20,686
  • 11
  • 89
  • 123
  • I can't do this as we have random number of users each time defined in a csv file.any other way around? – Just_another_developer Jan 16 '13 at 08:16
  • "initialize array with all usernames, stringify it and then put to property. However, it looks like a hack that will slow your plan." ... How to do this? I have not very much experience with Jmeter, could you please tell me how to implement this? ...code snippet? – Just_another_developer Jan 16 '13 at 08:18
0

Looks like you can save all the username-password pairs into file csv-file in ThreadGroup1 and then re-use they in ThreadGroup2 via e.g. reading with CSV Data Set Config.

Aliaksandr Belik
  • 12,725
  • 6
  • 64
  • 90
  • I was doing this ... but now I am reading them only once in ThreadGroup1 and then set and get variables using __setProperty (as I mentioned above) but getting problem (which is mentioned in Question ) – Just_another_developer Jan 16 '13 at 11:10
  • Sorry, maybe I'm missing something, but cannot understand reason to change quite a simple working solution with csv (looks like you have to use the same csv list in TG2 as in TG1) to cumbersome one with passing multiple properties between thread groups? I doubt that storing 2 properties per user is less resource consuming than re-read same credentials once more from csv in ThreadGroup2. Any reason for this? – Aliaksandr Belik Jan 16 '13 at 11:53
  • I am reading from csv file only in threadGroup1 and then using all the variables in TG2 I did this because I am passing some other variables too to TG2 which are user specific.If I read CSV seperately in TG2 it supplies wrong variables to users ... for instance if user1 supposed to have variable 1, it is possible that it will get variable2 which is actually supposed to be supplied to User2. I want each user to be passed with there specific variables in TG2 ... PS: these variables are the results of some requests I make in TG1. – Just_another_developer Jan 16 '13 at 12:50
  • I explain it more, In TG1 user logged in getting credentials from CSV file and do operations for instance create an account , an account number is generated now this account number has to be bind with user1... but when I supply this account number to TG2 and log in again in TG2 after reading Credentials from CSV it is not guaranteed that this account number will be supplied to user1, it could be supplied to user2.... – Just_another_developer Jan 17 '13 at 04:19
  • More over I have similar problem with accountnumber that in TG1 multiple account numbers generated as a result of multiple HTTP requests..when I put it in a variable to pass it on to TG2 , TG2 only gets last account number as it has already overrided all other accountnumbers. – Just_another_developer Jan 17 '13 at 04:20
0

I'm wondering if you really need two separate ThreadGroups?

It seems like you need only one ThreadGroup inside which you should perform your login actions and then save user/pass parameters in vars, not in props. Vars are thread local, so values of one thread won't override values of another.

You can set variable within the script: vars.put("var_name", "var_value"), and then use it like ${var_name}. Another option to set variable.