Domanda

I am using Akka and RabbitMQ in what will become a large scale application.

Right now, for acceptance and integration tests, I am mocking out the actor that would normally send or receive messages from the module under test. Effectively, just using the exact same RabbitMQ queues and injecting or receiving data and then verifying it.

Does that sound appropriate for for assuring everything is behaving itself across rabbitMQ?

On another aspect, I started using a logging queue for testing other things. I just route all kinds of log messages to it and then read the queue to get a feel for what's going on. For example, If I want to test if something is doing something, I just stick a function LogThis("Entered: Method Name") and then read the queue that puts messages on to see if it happened or not.

Does that sound like a good idea? The idea being that I am doing that even in unit tests. Everything else is mocked out, but I am verifying correct behavior of certain hard-to-test areas using that method. Just reading the stream of log data and seeing if it's doing what I want.

I got onto the idea because it seemed a lot easier than going to all kinds of trouble with Akka test kit when I can listen to a debug level log file queue and get the same information (so long as I assure my logging is only logging accurately)

È stato utile?

Soluzione

For rabbitMq , my advice is to use a real RabbiMQ : this can be done by using Vagrant with chef for provisioning the RabbitMq and the Vagrant maven plugin to start the Box before Integration tests and halt it in the post phase of integration tests :

The Vagrant Maven plugin : http://nicoulaj.github.io/vagrant-maven-plugin/

Vagrant WebSite : http://www.vagrantup.com/

Cookbook Chef for RabbitMQ : https://github.com/opscode-cookbooks/rabbitmq

To Summarize you must :

  1. Install Vagrant and create an empty Box(Centos or Ubunutu).
  2. provision the VM with rabbitMQ cookbook .
  3. place .box into you home folder (rabbitMQ.box).
  4. Configure you maven Project to start the VM with vagrant up (~/rabbitMQ.box) in the pre phase of integration tests .
  5. Configure you maven Project to stop the VM with vagrant halt (~/rabbitMQ.box) in the pre phase of integration tests .

This way your tests will be isolated.

Hope that this help

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top