Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMeter and random variable along with if controller

Tags:

jmeter

i want to control my sampler execution by using a random variable . I have a sequence of hits login,welcome,Bla,log out . i want the log out to be performed for 6/10 requests and let others do not login(so to speak 6 requests will perform the whole sequence including log out, 4 of them will perform will not perform log out ).How to achieve the same in JMETER

I have added a random variable rand and set it between 1-10 at the beginning of the thread group .Then just above Logout sampler i placed an IF controller were i check ${rand}>4 . How ever i always get all sequence executed . Please suggest what am i doing wrong

like image 526
jyothis Avatar asked Feb 05 '26 03:02

jyothis


2 Answers

Random Variable in Jmeter is saved in long format be default so

${rand} > 4 won't work. You need to change

Condition to ${rand} > 4.0

or change Random Variable Output format to 00 (2 digits)

see Manual

like image 164
user7294900 Avatar answered Feb 15 '26 19:02

user7294900


This was accomplished by creating a combination of config element- random variable and an IF controller

1) a random variable was created with Minim and maxim value to meet above condition 2) and IF controller was able to check ${myrand}>4;

This had derived the desired result - thank you all

like image 37
jyothis Avatar answered Feb 15 '26 19:02

jyothis