DataDog/dd-agent — pull request #1060 by jzoldak (2014-07-30 14:20:52+00:00)
Title: Add tests for jenkins agent check

This includes a test (currently marked as expected to fail) which exposes the `KeyError: 'result'` error that has been reported in #567.

The logic of how highwater marks are done in the jenkins agent check is flawed:
1. Jenkins will create build.xml files before the build is finished, which does not yet include the result in the XML. I have seen this on long-running matrix jobs. This will cause the agent to throw the KeyError, as shown in the testCheckWithRunningBuild added in this PR. Also the agent will already have set the highwater mark to that build, so its results will never be processed even after jenkins finishes and updates the build.xml file.
2. Note also that for concurrent builds, if a build that started later finishes first then the agent will set the highwater mark at the timestamp of the later build and the earlier one will never be processed. I didn't write a test for that, but you can see it by reading through the jenkins.py code.