How to Run the RabbitMQ Tests

RabbitMQ includes a suite of functional tests, as well as unit tests for each of its components. It’s not immediately obvious how to run the functional test suite, but fortunately, it’s straightforward.

You will need:

  • a Java JDK
  • Ant
  • Erlang
  • git
  • and I guess a Unix machine of some description; I don’t imagine running these tests on Windows will work well

Running the complete test suite takes about six minutes on my eight-core, 32GB i7 Linux box. Most of this time is spent sleeping, to ensure particular interleavings required by particular test cases.

Clone the repositories
git clone git://github.com/rabbitmq/rabbitmq-public-umbrella
cd rabbitmq-public-umbrella
git clone git://github.com/rabbitmq/rabbitmq-codegen
git clone git://github.com/rabbitmq/rabbitmq-java-client
git clone git://github.com/rabbitmq/rabbitmq-server
git clone git://github.com/rabbitmq/rabbitmq-test
Build and start the server in one window
cd rabbitmq-server
make run
Run the tests in another window

The tests are written in Java and come along with the RabbitMQ Java client source code.

Be sure to wait until the server has fully initialised itself before starting ant.

cd rabbitmq-java-client
ant test-suite

Things should tick along nicely for a few minutes at this point. From time to time, you’ll see the server print a new banner to its console: the tests restart the server occasionally as part of their normal operation.

Check the results

The tests leave their output in rabbitmq-java-client/build/TEST-* files. Each test suite (FunctionalTests, ClientTests, ServerTests, HATests) produces both a plain-text and an XML file summarising the results of the run.

Comments (closed)
Simon MacMullen 17:30, 17 Jan 2014

There are more tests than that! We should probably document this better...

Firstly, you can clone everything you need via hg, just clone the public umbrella then cd into it and "make checkout".

So the Java test suites are as follows:

* ClientTests - internal tests of the Java client
* FunctionalTests - general tests of an AMQP server, not assuming RabbitMQ (maybe testing our extensions, but the idea is to not interact with the server except through AMQP)
* ServerTests - tests which require interaction through something other than AMQP
* HATests - run all the FunctionalTests and ServerTests again, with queue mirroring enabled (which implies a few tiny semantic differences)

Note that the line between FunctionalTests and ServerTests might not in practice be very well observed.

But there are more:

* internal tests (the rabbit_test module) - internal unit tests. Can be run individually with "rabbitmqctl eval 'rabbit_test:all_tests().'"

* multi-node tests - tests of clustering and HA, which tend to require bigger clusters. Can be run with "cd rabbit-test/multi-node ; make all".

So how do you run all the tests? Just "cd rabbit-test ; make all". That will run everything mentioned above (and a filtered version of the old qpid tests). You'll probably want to go and get lunch while it all runs though :-/

Oh, and you still won't have tested any plugins! They all have a "make test" target as well.

Tony Garnock-Jones 19:18, 17 Jan 2014 (in reply to this comment)

Thanks, Simon! The rabbit-test repo was new to me; good to know about the "make all" target.