1

My Load Runner test project is intend to initialize 500 virtual users and then run 50 virtual users.So i wrote the script below in the "Action" function to let 450 virtual users jump to the "vuser_end".

int userID;
lr_whoami(&userID,NULL,NULL);
if(userID<451)
{
    lr_exit(LR_EXIT_VUSER, LR_PASS);
    return;
}

But the "lr_exit" function set the virtual users to the "pass" status and will never execute the "vuser_end".

What function can let the virtual users stop running and jump to "vuser_end" after running end?

Thank you for any helps in in advance.

Sharp Kid
  • 135
  • 1
  • 4
  • 14

3 Answers3

1

Return 0; \ Iterate normally Return 1; \Ignore iteration interval and iterate iummediately Return -1; \Iterate no further

What it really sounds like is that you structurally need a different type of user for the seccond condition. Consider a second user type which just has the folliowing in the action;

Action()
{
int rampup, \\in seconds
    idletime; \\in seconds

sleep(rampup *1000);
sleep(idletime *1000);

return 0;
}

Schedule this for a single iteration and then just have your users drop into the natural vuser_end at that point.

James Pulley
  • 5,606
  • 1
  • 14
  • 14
  • I have tried to sleep in the "Action" just now, but the respone time contained with the sleeping time. So "sleep" will cause the test result is not up to the performance indicators. – Sharp Kid Mar 05 '12 at 02:31
  • 1
    Given your follow up comments, I can add the following. (1) Sleep is there to hold the user for a single iteration of init, hold for a period, then ramp down.(2) If you are receiving a timing metric is it only because you have automatic transactions tuned on for actions. (3) If you want this to hold through your entire test, then drop the rampup variable, drop your iteration time to zero and simply schedule a group with these users to ramp up first, run for the duration of your test, then ramp down after the first group (actual workers) completes. – James Pulley Mar 05 '12 at 13:29
  • @SharpKid, @JamesPulley, Couldn't the problem be solved simply by adding the line `vuser_end()` right before teh cal to `lr_exit(LR_EXIT_VUSER, LR_PASS);`? – Pacerier May 18 '15 at 07:28
  • One never calls vuser_end() directly. That is a part of the scheduler. – James Pulley May 18 '15 at 13:22
  • @JamesPulley, True, the scheduler would call `vuser_end()` too if we had that in the run-logic settings. However, directly calling `vuser_end()` would solve the problem above isn't it? Seems to work fine for my case (LR11 here). Or, is there any particular reason that we should not call `vuser_end()` manually? – Pacerier May 19 '15 at 03:44
  • Conceptually, Vuser_init() and vuser_end() should be handled only once per user per test. This is "as designed" If you want to end the user then consider the option of return(-1); – James Pulley May 19 '15 at 14:48
0

Looks like you want lr_abort, this is straight from the docs:

The lr_abort function aborts the execution of a script . It stops the execution of theActions section,executes the vuser_end section, and ends the execution. This function is useful whenyou need tomanually abort a run as a result of a specific error condition. When you end a runusing this function,the status is "Stopped."

PBMax
  • 242
  • 3
  • 15
  • I have tried "lr_abort" in the "Action" just now, but the virtual users stopped immediately. I want to let the virtual users stop after all virtual users running out, just like the schedule of a normal Scenario. – Sharp Kid Mar 05 '12 at 02:48
0

Create a scenario in which the script that should be run after all those other users have run has a dependency on them.

TheBlastOne
  • 4,291
  • 3
  • 38
  • 72