1

WHAT I HAVE:

Jmeter network created for tests in distributed mode: one Jmeter master plus few Jmeter slaves. BeanShell Server disabled. Everything works fine.

WHAT I WANT TO DO:

I want to enable BeanShell server to be able to modify properties on the fly.

ACTUAL RESULT:

BeanShell server starts and works successfully. Once the test is done, the following message appears in the log:

The JVM should have exited but did not.
The following non-daemon threads are still running (DestroyJavaVM is OK):
Thread[Thread-7,5,main], stackTrace:java.net.PlainSocketImpl#socketAccept
java.net.AbstractPlainSocketImpl#accept at line:409
java.net.ServerSocket#implAccept at line:545
java.net.ServerSocket#accept at line:513
bsh.util.Sessiond#run at line:65
java.lang.Thread#run at line:748

Thread[Thread-5,5,main], stackTrace:java.net.PlainSocketImpl#socketAccept
java.net.AbstractPlainSocketImpl#accept at line:409
java.net.ServerSocket#implAccept at line:545
java.net.ServerSocket#accept at line:513
bsh.util.Httpd#run at line:64
java.lang.Thread#run at line:748

It's clear that it happens because of BeanShell server that is running and doesn't exit for some reason. As a result, java process will never exit and will hang.

QUESTION:

Any ideas why it happens? How to avoid it? I don't connect to beanshell server, neither by http nor by telnet.

MORE DETAILS:

All the nodes are running as Docker containers. All nodes are deployed in AWS. Can't reproduce the same issue locally on my machine. Even with BeanShell server enabled, all works smooth, and java exists as it should.

WHAT I TRIED:

Tried to set up the following properties:

jmeterengine.remote.system.exit=true    
jmeterengine.stopfail.system.exit=true    
jmeterengine.force.system.exit=true

Doesn't help, java process still hangs. The same for

bsh.system.shutdownOnExit = true;

Any ideas are very much appreciated.

2 Answers2

1

I don't think there is a way of stopping the Beanshell Server along with the test as it runs in an endless-loop Thread

I would recommend stopping your test and the Beanshell server using a .bsh file like:

stopEngine();
Thread.sleep(5000L); // just in case wait for 5 seconds for graceful shutdown
System.exit(0);    

where:

So you will be able to turn everything off the same way you amend the properties in the runtime.

You can also achieve the same by executing the System.exit(0); command automatically from i.e. tearDown Thread Group using OS Process Sampler, however in this case make sure to set the following property:

jmeter.save.saveservice.autoflush=true

otherwise you can loose some results which have not been written to disk yet

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Thanks for so quick answer! That's exactly what I do now. But it doesn't help in a case when test already stopped by itself, not by stop command. The idea with TearDown thread looks great in this case, so will add it. – Konstantin Dobroliubov Nov 26 '18 at 17:26
  • However, still don't have answer for a question why it doesn't stop by itself. The same docker container with beanshell server exits fine locally. So, it seems like something establishes a connection on AWS side, and since connection is opened, it doesn't allow to stop java properly. That is really weird as I don't allow any external connection by FW rules, so connection is done to localhost inside container only. – Konstantin Dobroliubov Nov 26 '18 at 17:29
0

Finally, I found a workaround, so posting it as an answer here.

Actually, it doesn't answer the original question in fact, but don't want to waste time trying to find an original root cause as it seems to be related to AWS structure (just because I can't reproduce it locally inside the same container I launch remotely).

So, the final schema is:

  1. To update properties on the fly, I don't have to launch BeanShell on slave and master both. Real property change happens on slave, so master is not required. It solves my specific case.

  2. To stop test, you can use existent shutdown.sh and stoptest.sh scripts. No need to do it over beanshell server.

  3. If the test was properly stopped, then -X option (server.exitaftertest=true) also works fine, so force shutdown for JVM is not required, and you don't have to add tearDown thread group that does System.exit. But the idea is nice.

  4. It's worth to have a shutdown.bsh script to force kill it anyway as a tool.