Question

Currently i'm working on load splitting scenario in jmeter.
My test-plan structure is similar as below:


TestPlan
BeanShell Preprocessor (here I have below code)

    Integer totalLoad = 0;
    Integer searchUsers = 0;
    Integer createUseres = 0; 

    totalLoad = Integer.parseInt (vars.get("TOTALUSERS")); 
    searchUsers = ((totalLoad / 100) * 40);  createUseres =((totalLoad / 100) * 10);  guestUsers = ((totalLoad / 100) * 50);

    vars.put("searchUsers", searchUsers.toString());
    vars.put("createUseres", createUseres.toString());
    vars.put("guestUsers", guestUsers.toString()); 

Thread group: Search (I am using ${searchUsers} in the number of Threads(users) field) 
Thread group: Create (I am using ${createUseres} in the number of Threads(users) field) 
Thread group: Guest (I am using ${guestUsers} in the number of Threads(users) field) 

This is not working for me.
Can you please help?

Was it helpful?

Solution

JMeter variables are local to each thread. So if you'll create those variables in preprocessor, they won't be accessible to other threads at this level.

You should use properties to put/get searchUsers, createUseres, guestUsers like:

Use props.put("guestUsers", guestUsers.toString()); in BeanShell Preprocessor. Use ${__P(searchUsers)} as number of threads in Thread Group.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top