Unanswered question

Is there a way to recognize if the script is running in validity or run mode?

For debugging I use the check virtual user validity.
The script contains multiple loops and for debugging the script I want the loop to be executed only once.

It happened a few times that I forgot to change the loop back and the actual loadtest executed less transactions than it should.

My question is if it is possible to recognize that the test is running in vu validity instead of an actual run.
For example: In loadrunner the user has id "-1" if it is running from the script in stead of from the controller.
I have looked at the API, but cannot seem to find a proper way.

Sander V.
Sander V.

Sander V.

Level
0
63 / 100
points

Answers

Nouredine A.
Nouredine A.

Nouredine A.

Level
4
5000 / 5000
points
Team

I'm not sure to understand your query. A test and a check virtual user are not run from the same area. So you can't be confused if a user is started from a check virtual user or not.

Please provide more information since i do not think i got your question correctly.

Sander V.
Sander V.

Sander V.

Level
0
63 / 100
points

Hi Nouredine,
Let me explain with a simple example.
I have a script that logs into an application and then does a searchquery. In the loadtest every login is followed by 50 searches.
When I'm debuggen the script in check virtual user I only want the search to be executed once. So I want a variable in the execute loop.
With JavaScript I want to find out from what area the script is started (test or check vu), but I just found out how I can find this out --> context.currentVU.getPopulationName() starts with "Check" when run from the validity check, so I can use this.

if (context.currentVU.getPopulationName().lastIndexOf("Check", 0) === 0) {
logger.error("Loop=1");
}
else {
logger.error("Loop=50");
}
Virtual User Validity:2015/06/11 15:45:19 ERROR - neoload.JavaScript.script: Loop=1

In Run Results: 2015/06/11 15:45:47 ERROR - neoload.JavaScript.script: Loop=50

christophe M.
christophe M.

christophe M.

Level
4
5000 / 5000
points
Team

Hi,

I think the most appropriate way is to take benefit of the Init/Actions/End containers:

  • put your Login in the Init, it will be executed once during the test
  • put the search in the Actions container (without a loop): it will be executed until the test ends.
  • put your logout/clean-up in the End container

So, it works as expected during the runtime.
During the checkVU, the default is to play 1 iteration (1 "Actions" container), and you can change this is the advanced settings if needed.

The value change policy of the variable that contains the search_criteria should be 'change on each iteration'.
If you need to run 50 search then you can use a duration policy 'by iteration' for your scenario and run 50 iterations.