embedded-rabbitmq
embedded-rabbitmq copied to clipboard
RabbitMq should be stopped even if tests were interrupted
if a test was interrupted and, subsequently, stop() was not called then rabbit still runs.
RabbitMq should be stopped after tests, even if stop was not called. May be launching it in subprocess would help.
i tried a few times and in various ways to interrupt the execution of thecom.sample.project.EmbeddedRabbitMqTest
test before the @After
block (which calls rabbitMq.stop();
) is executed, but I was never able to get RabbitMQ process to stick around.
Can you provide more details about how to reproduce this?
Ok, I'll try to make MWE tomorrow.
Leaves RabbitMq running after test execution. Without System.exit() works fine.
import io.arivera.oss.embedded.rabbitmq.EmbeddedRabbitMq;
import io.arivera.oss.embedded.rabbitmq.EmbeddedRabbitMqConfig;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class RabbitTest {
static EmbeddedRabbitMq rabbitMq;
@Test
public void rabbitTest() {
System.exit(0);
}
@BeforeClass
public static void init() {
EmbeddedRabbitMqConfig config = new EmbeddedRabbitMqConfig.Builder().rabbitMqServerInitializationTimeoutInMillis(5000).build();
rabbitMq = new EmbeddedRabbitMq(config);
rabbitMq.start();
}
@AfterClass
public static void destroy() {
rabbitMq.stop();
}
}
Another, more real test-case. One can restart tests during debugging (started test, stopped at breakpoint, fixed code, restarted). In this case RabbitMq would not be stopped.
I've pushed a branch containing a test to try to reproduce the issue and i just don't get the same results you do.
Try checking out the branch test/issue-28
, then running the bash script found in the folder src/test/java/issue28
. Feel free to modify the test to do System.exit(0) or anything you'd like.
For me, the output of running that script looks like this:
$ ./test.sh
Any RabbitMQ process found?
No process found.
Executing test that will exit without stopping the Embedded RabbitMQ process...
RabbitMQ processes:
RabbitMQ process found with pid: 53900
PID TTY TIME CMD
53900 ttys004 0:01.29 /var/folders/5v/x81_dvcn11ddrkb2ybs56k_r0000gn/T/rabbitmq_server-3.6.5/erts-6.4/bin/../../erts-6.4/bin/beam.smp -W w -A 128 -P 1048576 -t 5000000 -stbt db -K true -B
Waiting for mvn to finish...
Maven exit status: 1
Is RabbitMQ still running?
No process found.
I've launched test.sh with zero changes and got this output:
Any RabbitMQ process found?
No process found.
Executing test that will exit without stopping the Embedded RabbitMQ process...
RabbitMQ processes:
RabbitMQ process found with pid: 7371
PID TTY TIME CMD
7371 pts/10 00:00:02 beam.smp
Waiting for mvn to finish...
Maven exit status: 1
Is RabbitMQ still running?
Uh-oh! RabbitMQ is still running! 7371
My system is Ubuntu Mate 16.04 LTS
Interesting! My system is Mac OS X 10.11.6
I'll do some more research when i have some spare time. Thanks for the help so far 👍
My system is Mac OS X 10.12.4 and I can reproduce this even with a successful test. I ensured that stop() is called.
$ ps -ef | grep -i [r]abbit
501 87336 1 0 8:59PM ?? 0:00.00 /var/folders/j6/4qlzsrl541q6nqyfhbkmfnvr0000gn/T/rabbitmq_server-3.6.6/erts-6.4/bin/../../erts-6.4/bin/epmd -daemon
did stop()
finish successfully?
Can you enable debug for io.arivera.*
package and share the logs?
Here it is
21:05:39.778 DEBUG 1-thread-1 i.a.o.e.r.h.ErlangVersionChecker - Erlang version installed in this system: 19
21:05:39.782 DEBUG 1-thread-1 i.a.o.e.r.h.ErlangVersionChecker - RabbitMQ version to execute requires Erlang version R16B03 or above.
21:05:39.785 DEBUG 1-thread-1 i.a.o.e.r.d.CachedDownloader - RabbitMQ has been downloaded before. Using file: /Users/nislam/.embeddedrabbitmq/rabbitmq-server-mac-standalone-3.6.6.tar.xz
21:05:42.166 DEBUG 1-thread-1 i.a.o.e.r.E.P.rabbitmq-server - Executing '/var/folders/j6/4qlzsrl541q6nqyfhbkmfnvr0000gn/T/rabbitmq_server-3.6.6/sbin/rabbitmq-server' with environment vars: {RABBITMQ_NODE_PORT=5672, RABBITMQ_NODENAME=rabbit-test}
21:05:42.171 DEBUG 1-thread-1 i.a.o.e.r.E.P.rabbitmq-server - Process started.
21:05:43.476 INFO Thread-3 i.a.o.e.r.E.P.rabbitmq-server -
21:05:43.477 INFO Thread-3 i.a.o.e.r.E.P.rabbitmq-server - RabbitMQ 3.6.6. Copyright (C) 2007-2016 Pivotal Software, Inc.
21:05:43.477 INFO Thread-3 i.a.o.e.r.E.P.rabbitmq-server - ## ## Licensed under the MPL. See http://www.rabbitmq.com/
21:05:43.477 INFO Thread-3 i.a.o.e.r.E.P.rabbitmq-server - ## ##
21:05:43.477 INFO Thread-3 i.a.o.e.r.E.P.rabbitmq-server - ########## Logs: /var/folders/j6/4qlzsrl541q6nqyfhbkmfnvr0000gn/T/rabbitmq_server-3.6.6/var/log/rabbitmq/rabbit-test.log
21:05:43.477 INFO Thread-3 i.a.o.e.r.E.P.rabbitmq-server - ###### ## /var/folders/j6/4qlzsrl541q6nqyfhbkmfnvr0000gn/T/rabbitmq_server-3.6.6/var/log/rabbitmq/rabbit-test-sasl.log
21:05:43.477 INFO Thread-3 i.a.o.e.r.E.P.rabbitmq-server - ##########
21:05:43.477 INFO Thread-3 i.a.o.e.r.E.P.rabbitmq-server - Starting broker...
21:05:44.265 INFO Thread-3 i.a.o.e.r.E.P.rabbitmq-server - completed with 0 plugins.
[info] - testing rmq
Calling stop
21:05:44.348 DEBUG 1-thread-1 i.a.o.e.r.E.P.rabbitmqctl - Executing '/var/folders/j6/4qlzsrl541q6nqyfhbkmfnvr0000gn/T/rabbitmq_server-3.6.6/sbin/rabbitmqctl stop' with environment vars: {RABBITMQ_NODE_PORT=5672, RABBITMQ_NODENAME=rabbit-test}
21:05:44.353 DEBUG 1-thread-1 i.a.o.e.r.E.P.rabbitmqctl - Process started.
21:05:45.032 INFO Thread-5 i.a.o.e.r.E.P.rabbitmqctl - Stopping and halting node 'rabbit-test@Nooruls-MacBook-Air' ...
21:05:45.087 WARN Thread-4 i.a.o.e.r.E.P.rabbitmq-server - Gracefully halting Erlang VM
21:05:45.092 DEBUG s@6f91023f i.a.o.e.r.E.P.rabbitmqctl - Process finished (exit code: 0).
21:05:45.092 DEBUG s@6f91023f i.a.o.e.r.E.P.rabbitmqctl - Process stopped
21:05:45.092 DEBUG 1-thread-1 i.a.o.e.r.h.ShutdownHelper - Successfully commanded RabbitMQ Server to stop.
21:05:46.326 DEBUG s@51e677ad i.a.o.e.r.E.P.rabbitmq-server - Process finished (exit code: 0).
21:05:46.326 DEBUG s@51e677ad i.a.o.e.r.h.StartupHelper$PatternFinderOutputStream - No more output is expected since process finished (exit code: 0)
21:05:46.326 DEBUG s@51e677ad i.a.o.e.r.E.P.rabbitmq-server - Process stopped
21:05:46.327 DEBUG 1-thread-1 i.a.o.e.r.h.ShutdownHelper - RabbitMQ Server stopped successfully.
[info] Run completed in 8 seconds, 224 milliseconds.
[info] Total number of tests run: 4
[info] Suites: completed 3, aborted 0
[info] Tests: succeeded 4, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[success] Total time: 9 s, completed 8 Apr, 2017 9:05:46 PM
@noorul That is actually the Erlang Port Mapper Daemon, and it is a erlang "issue" and unrelated to this project (my opinion at least)
http://rabbitmq.1065348.n5.nabble.com/Stopping-RabbitMQ-on-Ubuntu-td22080.html http://stackoverflow.com/questions/17324786/is-there-a-way-to-stop-erlang-servers-from-automatically-starting-epmd