Destroy unit's machine if eligible.

Either way, assert that the state assumptions for being eligible or
not-eligible hold true for the transaction.

Improved state assertion in removeUnitOps

More test cases, renamed destroyHostOps

destroyHostOps fix, allow machine removal on retry

If a unit's host cannot be removed, make that condition the only
assertion on the transaction, so that we can re-evaluate the state
completely on retry. Examples:
- host container removed after check, before txn exec
- host gives up voting rights after check, before txn exec

Unit tests added for the above, and the converse (host qualifies on
check, disqualified before txn exec).

Fix import

Add thrashing state testcase.

Consolidate destroyHostOps machine ops.

$or together all the "keep host alive" assertions, so that a transaction
can succeed if the individual "keep" criteria change in a transaction
but the outcome remains the same.

Improve destroyHostOps test cases.

Test coverage for removing an unassigned unit. Use assertLife helper
function. More descriptive test names. More assertion checks.

Improve non-empty containers assertion.

MongoDB makes it kind of weird.
https://stackoverflow.com/questions/14789684/find-mongodb-records-where-array-field-is-not-empty-using-mongoose

Clean up tests, log removal of unassigned unit.

Removed test cruft, .Refresh() from txn hooks.

Colocated unit set up outside of the transaction hook in
TestRemoveUnitMachineRetryOrCond.

Remove TestDestroyCleanRelations.

Check unit destroyed in TestRemoveUnitMachineRetryOrCond

Consolidate & improve destroyHostOps assert conds.

Refactor out unit test suite method setMachineVote.  More comments.

Remove subordinate unit test case.
Updated wrt state/txn refactoring.

Fixed service removal test by calling State.Cleanup.
Merge pull request #52 from cmars/rm-unit-machine

Destroy machine when last principal unit removed.

This change causes a machine to be automatically removed when the last principal unit running on that machine is removed (remove-unit). If the machine is a parent to any containers, it is left alone.

Background:
https://bugs.launchpad.net/juju-core/+bug/1206532
https://bugs.launchpad.net/juju-core/+bug/1183309/comments/8

This could use more test coverage, but I'd like to get a general feel for how it's looking so far before I go much further with it. This is my first time mucking around with state transactions. Please let me know if I've got it right!

I haven't added an option to keep empty machines/containers around after removing the last unit. I'd like to see if we can avoid it. If we do need the option, I think it should be opt in. Let me know.