Sunil Malgaya wrote:
JMeter experts,



I have a need where I need to run a login call at the interval of 5 minutes
only (unlike every virtual user who keeps running them continuously). This
is how my test plan looks:



S1_Simple controller_LOGIN

                Test case1_login

                Test case2_landing page

                Test Case3_select from dropdown



S2_Simple controller_Select Page

S3_Simple controller_Review Page


I want the "S1_Simple controller_LOGIN" call to be run only at an interval
of 5 minutes (to simulate real time user experience). I tried putting
"Uniform Random Timer" with 5 minutes but still the login calls are running
continuously. Please advise what option(s) would work for this scenario?



Thanks,

Sunil

If this is *really* something you're looking for you can put your Login request under the If Controller <https://www.blazemeter.com/blog/jmeter-if-controller> and use the following __groovy() function <https://jmeter.apache.org/usermanual/functions.html#__groovy> as the condition:

${__groovy(if (vars.getIteration() == 1) {vars.putObject('lastLogin'\, System.currentTimeMillis());return true;} else { def lastLogin = vars.getObject('lastLogin'); if (System.currentTimeMillis() - lastLogin >= 300000) { vars.putObject('lastLogin'\, System.currentTimeMillis()); return true; }},)}

However personally if I had to re-login somewhere each 5 minutes I would abandon that application and never return so you might to want to reconsider the approach.


More readable code instead of the above one-liner to help you to understand what it does:

if (vars.getIteration() ==1) {
    vars.putObject('lastLogin',System.currentTimeMillis());
    return true;
}else {
    def lastLogin =vars.getObject('lastLogin');
    if (System.currentTimeMillis() -lastLogin >= 300000) {
        vars.putObject('lastLogin',System.currentTimeMillis());return true;
    }
}

in the above example vars stands for JMeterVariables <https://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html> class instance



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@jmeter.apache.org
For additional commands, e-mail: user-h...@jmeter.apache.org

Reply via email to