[zeromq-dev] Testing and debugging

Michel Pelletier pelletier.michel at gmail.com
Mon Aug 13 18:49:01 CEST 2012


There are generally two approaches I use in Python to test zeromq
code.  The first is to mock the zmq library with something like
flexmock (or one of the many other mocking libraries) and test my
message producing/handling code in isolation.  Since the zmq api is so
simple (bind/connect/send/recv for the most part) this is quiet easy.
It's also a good way to do test driven development, you isolate each
message interaction as a unit and fully test each unit.  It's also
really fast as no actual messages get transported.

The second level of testing is integration testing, where I use fabric
to launch my programs (via the command line) to test their interaction
with real messages, typically by giving them arguments of
configurations that cause them to do things like use a test database
or other resource instead of a live production one.  fabric is nice
because it can ssh into machines and run remote commands to start test
services.  I haven't tried this pattern yet, but using something like
vagrant you can automatically spin up test virtual machines to do a
full "cluster-wide" integration test.

-Michel


On Mon, Aug 13, 2012 at 5:26 AM, andrea crotti
<andrea.crotti.0 at gmail.com> wrote:
> Any advices about how to debug and unit test zeromq-based applications
> (Python in particular)?
>
> I have all these processes communicating with each other now, and it's
> a tricky to set a breakpoint or to add some prints here and there, so
> what could be a way to go?
>
> For automated tesating I was thinking I could run everything in
> "pretend-mode", do all the logging, check the logs and kill
> everything, a bit complicated but the best way I see so far, any other
> advices?
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev



More information about the zeromq-dev mailing list