Stop jobs when executor stops

If the executor stops while jobs are running, those jobs are not
explicitly aborted.  In production, the process exit would cause
all of the jobs to terminate and the gearman disconnection would
report a failure, however, in tests the python process may continue
and the ansible threads would essentially leak into a subsequent
test.  This is especially likely to happen if a test holds jobs in
build, and then fails while those jobs are still held.  Those threads
will continue to wait to be released while further tests continue
to run.  Because all tests assert that git.Repo objects are not
leaked, the outstanding reference that the leaked threads have
to a git.Repo object trips that assertion and all subsequent tests
in the same test runner fail.

This adds code to the executor shutdown to stop all jobs at the start
of the shutdown process.  It also adds a test which shuts down the
executor while jobs are held and asserts that after shutdown, those
threads are stopped, and no git repo objects are leaked.

Change-Id: I9d73775a13c289ef922c27b29162efcfca3950a9
3 files changed