buildbot/buildbot — pull request #392 by Jc2k (2012-04-29 17:34:22+00:00)
Title: Libvirt enhancements and some actual test coverage (!) (WIP)

This is a work in progress branch to improve the LibVirtSlave code and add some test coverage. Only 2 years late :D.

I'm submitting the pull request a bit early to get some feedback on the tests - libvirt is a bit underrepresented so it's hard to be know if my strategy is correct.

New stuff:

* If python-libvirt isn't importable there will be a nice configuration error

* If you restart buildbot and there are active libvirt VM's then buildbot will reuse the existing ones rather than starting duplicates.

* Libvirt has 'insubstantiate after build' and inherited latent slaves 'built wait timeout' which both control how quickly to destroy a latent slave. I've unified them (within latent slaves) - a build_wait_timeout of 0 means destroy the VM straight away after a build. (I think more of the stop_instance code needs pulling out of libvirt to finish this off). If it is < 0 then it won't ever try to kill the latent slave.

* There is a check to stop buildbot starting builds on latent slaves that are shutting down.

* There are tests!!

Still to do:

* Document the changes to the build_wait_timeout option
* Need to move the LibVirt fake to the fake module.
* Need to figure out what over bits are fakes and refactor them out
* Test coverage for AbstractLatentSlave

The bulk of the patches in this branch came from our production buildbots, but have been tidied up (they were all in a subclass of LibVirtSlave, when some where more appropriate in AbstractLatentSlave).