'Jmeter OS Process Sampler

I'm using 4 OS Process Samplers in Jmeter to launch binaries. Can't really say much more than that.

When I run the test, the first OS Sampler doesn't work. And by that, I mean it doesn't fail or succeed, it just takes too long. Nothing happens. When I stop the test, the error is that it failed because it got interrupted (by me).

When I run the test a 2nd time, the first OS Sampler works right away, but then the same problem happens with the 2nd OS Sampler.

On the third test try, OS Sampler 1 and 2 work quickly, but the 3rd one doesn't.

On the fourth test try, OS Samplers 1, 2, and 3 work, but not the 4th.

Finally, on the fifth test try, all OS Samplers work.

So all in all, each Sampler needs a trial run before it works.

Why? Please help.



Solution 1:[1]

If you use OS Process Sampler to "launch" a binary my expectation is that OS Process Sampler will wait till the binary execution completes to record execution time, return code, any output, etc. This is what the sampler is designed for.

If you need to launch something "in background" with JMeter you will need to "cheat" a little bit. There are at least 2 options:

  1. Use separate Thread Groups. You can put your OS Process Samplers under separate Thread Groups with 1 virtual user and 1 iteration. Just make sure you have "Run thread groups consecutively" on Test Plan level box unchecked

  2. Use underlying operating system mechanisms to provide JMeter response code and output it's looking for.

    For instance launch your program as:

    • Windows: cmd /c pushd path_to_your_binary_location && your binary
    • Linux/Unix: nohup /path/to/your/binary > /dev/null 2>&1 &

See How to Run External Commands and Programs Locally and Remotely from JMeter for more information on executing local and remote commands from JMeter script.

Solution 2:[2]

There is no particular reason for OS Sampler to work this way. Most probably the issue comes from the underlying called code.

can you provide more infos on what your shells do ?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 UBIK LOAD PACK