celluloid / celluloid-zmq

UNMAINTAINED: See celluloid/celluloid#779 - Celluloid actors that talk over the 0MQ protocol
https://celluloid.io
MIT License
83 stars 25 forks source link

Add basic specs #32

Closed jnicklas closed 10 years ago

jnicklas commented 10 years ago

Closes #28

Sorry, this pull request is a bit of a mess.

I added a few basic specs which just check the most basic funcionality in the gem. It also provides a nice base on which to write more. These are more integration than unit tests, but I think that's what's most helpful here at this point. We might want to add some unit tests for critical components as well at some point. This is all happy path too, I'd like to be able to simulate failure conditions, but I have no idea how to do this with zeromq.

Additionally I changed some stuff. Sorry ;) I made context not lazily initialize the ZMQ context, since this is not threadsafe, and potentially problematic if the user forgets to call Celluloid::ZMQ.init. Instead it'll throw an exception if init hasn't been called.

I also made a small tweak to the waker which shuts it down properly when the mailbox goes down. This is necessary so that terminating the context doesn't hang indefinitely.

tarcieri commented 10 years ago

Sorry it's taken me so long to look at this. My initial concern is what's up with the Travis failures, but it looks incidental...

jnicklas commented 10 years ago

Maybe. I did have problems with hangs sometimes, but I thought I'd resolved everything. The main problem is that terminating the ZMQ context blocks until all sockets have been shut down. Celluloid::ZMQ.terminate should probably at least have a timeout so it doesn't hang indefinitely.

tarcieri commented 10 years ago

Well, this passes locally for me, and is certainly better than no specs at all... just kinda surprised it deadlocks on Travis consistently across all VMs. Perhaps it's due to some sort of resource contention?