cyrusimap / cassandane

Other
6 stars 11 forks source link

Better cleanup after errors during instance shutdown #181

Closed elliefm closed 2 years ago

elliefm commented 2 years ago

We keep having problems where errors detected during Cassandane::Instance::stop() lead to the test not being cleaned up properly, which then causes cascading failures later due to cassandane's 91xx ports still being in use by processes left behind by earlier tests.

This fixes the problem by carefully removing all the cases where stop() could die, and instead collecting those errors into an array that's returned to the caller.

If one of the instances' stop()s manages to die somehow anyway, Cassandane::Cyrus::TestCase::tear_down() evals and ignores it, and continues cleaning up anyway. The first error that was returned by stop() is used for the eventual die message.

I have tested this for the specific case of "Errors found in syslog", by temporarily building a cyrus where imapd syslogs a fake IOERROR during shut_down(). And indeed, even though nearly every test errors in such a case, cassandane still runs to completion and properly cleans up after every test.

I have not tested this for the other types of errors stop() can fail on, for lack of any immediate insight about how to force them to occur (am open to ideas!), so please review carefully.