savory code and other culinary highlights

Integration Tests With Celluloid::IO, Part 2

In the
first post,
we wrote an integration test setup for a Celluloid::IO application.

One remaining problem is that the tests are “absorbing” all exceptions that
occur during worker execution, or are raising them some time later.
This is because the workers can just crash internally and/or the worker thread is still
running when the test is done.

Catching actor exceptions

A first solution is to store all occuring worker exceptions inside a variable in the
test thread and then re-raise them when we’re done.

The code for the test stays exactly the same as in the previous post, except that now worker
exceptions are actually raised after test execution.

The global exception hack above looks like it’s not threadsafe, so we might experiment around
with a more sophisticated setup in the future (scheduler, exception collecting actor).
But as a hotfix it’s proved to be pretty reliable in our test runs.

If you know a better solution, feel invited to post it in the comments!