Fix exception calculating run time for lost builds.

When a build is reported as lost, it has no start_time, so the
code that calculated the run-time for statsd threw an exception.

Correct that by only calculating the run time for jobs that have
really completed.

Add debug lines to onBuild* that would have helped diagnose this.

Keep track of the throwaway threads that are used to report LOST
builds so that the test suite can more correctly know when the
system is settled.

Add a test case for a single non-existent post job.

Add STATSD_* env variables in tox to make sure that the statsd
code paths are executed by tests.

Change-Id: I339443cbad7b0858d70e9180d63dfb701b8eaee9
Reviewed-on: https://review.openstack.org/18792
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Tested-by: Jenkins
diff --git a/tox.ini b/tox.ini
index 198c01c..adddba8 100644
--- a/tox.ini
+++ b/tox.ini
@@ -2,6 +2,9 @@
 envlist = pep8, pyflakes, py27
 
 [testenv]
+# Set STATSD env variables so that statsd code paths are tested.
+setenv = STATSD_HOST=localhost
+         STATSD_PORT=8125
 deps = -r{toxinidir}/tools/pip-requires
        -r{toxinidir}/tools/test-requires
 commands = nosetests {posargs}