In FakeStatsd, use select() rather than poll()

The poll() system call is not available on all systems (like OS X, for
example), causing the test suite to fail. This change replaces poll()
with select(), which is more portable. With this change the test suite passes
under OS X.

Change-Id: I3ad716b127c8781d8dbf870b0f0c0e1162f264d1
Reviewed-on: https://review.openstack.org/28126
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: James E. Blair <corvus@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
report message even if no action is specified

Whenever a pipeline does not provide any action, the job message would
not be reported which is a bit annoying.  This patch makes it so we skip
reporting when there is no action and no message.

My use case is:

A `postmerge` pipeline that simply react to the `change-merged` events,
since the change is closed, there is no point in voting on it.  Jobs
then uses the `success-message` and `failure-message` to finely tune
what is reported back to the user.

Configuration exemple

  pipelines:
   - name: postmerge
     manager: IndependentPipelineManager
     trigger:
      - event: change-merged

  projects:
   - name: operations/config
     postmerge:
      - operations-config-deploy

  jobs:
   - name: operations-config-deploy
     branch: ^production$
     success-message: 'Your configuration has been deployed by Jenkins.'
     failure-message: 'Configuration NOT APPLIED. You broke wikipedia.'

Before this patch, the debug would be:

------------8<---------------8<---------------8<-----------------------
INFO zuul.IndependentPipelineManager: Reporting
change <Change 0x7f67a0d61f50 61980,1>, action: None

DEBUG zuul.Gerrit: Report change <Change
0x7f67a0d61f50 61980,1>, action None, message: Build succeeded.

- https://jenkins-url-goes-there.example.com/
  : Your configuration has been deployed by Jenkins.

DEBUG zuul.Gerrit: No action specified; not reporting

DEBUG zuul.IndependentPipelineManager: Removing reported
------------8<---------------8<---------------8<-----------------------

Change-Id: I9ab4d47a8cfc1ae66870e8ac55e8f78dfc29da3d
Reviewed-on: https://review.openstack.org/28045
Reviewed-by: Jesse Keating <jesse.keating@rackspace.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Approved: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
Drop Jenkins.getBestBuildURL() method

The ability to configure success and failure URL patterns (cf.
'success-pattern' and 'failure-pattern') obsoletes the need to
guess-by-fetching an appropriate link for the build status, which can be
extremely expensive. (Wikimedia's Zuul instance makes three HTTP requests per
invocation -- 'testReport', which 302s to 'testReport/', which 404s, and then
'consoleFull', which often runs to hundreds of kilobytes.)

Also corrects a small typo in README.rst.

Change-Id: Ib222f544c98253152a5e787ec0cdf28fa2d80cf6
Reviewed-on: https://review.openstack.org/28128
Reviewed-by: James E. Blair <corvus@inaugust.com>
Approved: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
make report times a little more user friendly

report times as 1h 22m 08s

only report hours if the job runs longer than an hour

only report minutes if the job runs longer than a minute

don't zero pad whatever the leading time unit is, making it a
little easier to scan and see differences.

Change-Id: Ibb58be233fdef1bbdf4e90a83731d43eb0be47f1
Reviewed-on: https://review.openstack.org/28143
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: matthew-wagoner <matthew.wagoner@hp.com>
Reviewed-by: Antoine Musso <hashar@free.fr>
Approved: James E. Blair <corvus@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
Ignore pep8 E123.

From the pep8 spec:

  The closing brace/bracket/parenthesis on multi-line constructs
  may either line up under the last item of the list, as in:
  ...
  or it may be lined up under the first character of the line that
  starts the multi-line construct, as in:
  ...

Bizzarly, the pep8 tool ignores the first option.

Change-Id: Ic0e8f8ad964881276d213ffd50deb75a537c250b
Reviewed-on: https://review.openstack.org/28609
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
fix message report when no action is given

031e23f allowed the Gerrit trigger to report a message even when no
action has been given (for the context of postmerge builds where the
change cant be altered).  I have noticed the Gerrit lib would stack
trace because it is missing an action (actually None).  This patch skip
the action expansion in Gerrit command line whenever there is no action.

Related stacktrace:

  INFO zuul.IndependentPipelineManager: Reporting
   change <Change 0x7fb72099d190 62446,3>, action: None
  DEBUG zuul.Gerrit: Report change <Change 0x7fb72099d190 62446,3>,
   action None, message: Build succeeded.
  ERROR zuul.IndependentPipelineManager: Exception while reporting:
  Traceback (most recent call last):
  File "zuul-5b84b5c-py2.7.egg/zuul/scheduler.py",
    line 883, in reportChange
      ret = self.sched.trigger.report(change, report, action)
  File "zuul-5b84b5c-py2.7.egg/zuul/trigger/gerrit.py",
    line 142, in report message, action)
  File "zuul-5b84b5c-py2.7.egg/zuul/lib/gerrit.py",
    line 119, in review
      for k, v in action.items():
  AttributeError: 'NoneType' object has no attribute 'items'

Change-Id: I51b66025eb6e1d074d79cf77ac4085ba3ffde77e
Reviewed-on: https://review.openstack.org/28395
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Approved: James E. Blair <corvus@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
Sync from oslo-incubator.

Change-Id: I3a7c6bdfae9f2273cf8059c322d648cda07d830d
Reviewed-on: https://review.openstack.org/28619
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Tested-by: Jenkins
Switch the launcher to Gearman.

Remove the Jenkins launcher and add a new Gearman launcher (designed
to be compatible with Jenkins) in its place.

See the documentation for how to set up the Gearman Plugin for
Jenkins.

Change-Id: Ie7224396271d7375f4ea42eebb57f883bc291738
Revert "report message even if no action is specified"

This reverts commit 031e23f72318c65346f88e3cad3989eed4f7368b
and commit 9ba206866499cbe1bbda4fb5e1b4fabbbc82e934.

This breaks the ability to have silent pipelines.

Instead, how about the following:

  pipelines:
  - name: postmerge
    manager: IndependentPipelineManager
    ...
    success:
      force-message: true

That should work without any additional code.

Change-Id: I0d15b8fcb678a36c46205693ba9a6756ec6a076f
Reviewed-on: https://review.openstack.org/29180
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Antoine Musso <hashar@free.fr>
Approved: James E. Blair <corvus@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
Merge branch 'master' into feature/gearman

Change-Id: I4f13e8ecfad5075ca40b66a989a5abe2c3be22fc
Add the ability to set git user.email and user.name

It is possible the host system does not have git properly configured,
which results in merge failures because the git client is complain. For
example:

  GitCommandError: 'git merge FETCH_HEAD' returned exit status 128:
  *** Please tell me who you are.

  Run

    git config --global user.email "you@example.com"
    git config --global user.name "Your Name"

  to set your account's default identity.
  Omit --global to set the identity only in this repository.

Now we can pass user.name and user.email settings to git, if configured
to do so.

Change-Id: I896194d8d1f5334026954b02f3a1a8dd82bed2ac
Signed-off-by: Paul Belanger <paul.belanger@polybeacon.com>
Reviewed-on: https://review.openstack.org/29015
Reviewed-by: James E. Blair <corvus@inaugust.com>
Approved: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
doc: rename manpage from `zuul` to `zuul-server`

On Debian, all binaries should have an associated manpage. While
building Zuul package we got the following lintian error:

  W: zuul: binary-without-manpage usr/bin/zuul-server

This is easily fixed by making sphinx to name the man page zuul-server.

Change-Id: Ie9fa681654a8e7e8785c1dcfa5ec21ba27ae3049
Reviewed-on: https://review.openstack.org/29287
Reviewed-by: James E. Blair <corvus@inaugust.com>
Reviewed-by: Paul Belanger <paul.belanger@polybeacon.com>
Approved: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
Use a relative URL for status.json.

So that app.js can be less specific about where it's running.

Change-Id: I2a84a659b43027b7eb59ba707396517d8ba635d3
Reviewed-on: https://review.openstack.org/29286
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
Add a test for changes that trigger multiple pipelines.

Change-Id: I147491d2c08fa1040f41f0c299113e3eb8968252
Reviewed-on: https://review.openstack.org/29158
Reviewed-by: Antoine Musso <hashar@free.fr>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Approved: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
Merge branch 'master' into feature/gearman

Change-Id: I9494196710a96414573b11788ed6007817c9f774
Update to new Gear API.

It dropped some "waitFor..." calls.

Also, update the unit tests to deal with some indeterminism in the
order jobs are run (showed up while testing this patch).

Change-Id: Id77838cc1bf0823ee0ee3795cb9190f405a1ff21
Reviewed-on: https://review.openstack.org/31109
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Approved: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
Use gear release version 0.1.1.

Change-Id: I14dbe148f0ff57e5d0c50cc712120a2708f158b1
Reviewed-on: https://review.openstack.org/31727
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Reviewed-by: Khai Do <zaro0508@gmail.com>
Approved: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
Add optional internal gearman server.

Change-Id: Id4e6b77f5abba23f46236def28f54509c61fd247
Reviewed-on: https://review.openstack.org/30170
Reviewed-by: Monty Taylor <mordred@inaugust.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Approved: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
Update to new zuul-gearman protocol.

* Use non-Jenkins terminology "manager" rather than "master".
* Use name+number as the identifier for both stopping builds and
  descriptions.
* Expect 'url' parameter instead of 'full_url'.

Change-Id: I1fe9851556618fc6d6deb8906e3f2ee41725c3ad
Reviewed-on: https://review.openstack.org/31726
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Approved: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins
Wait for internal gearman server to settle.

If we're using the internal gearman server, wait for workers
to register their functions before proceeding with startup.

This is mostly to handle restarts where we may be immediately
ready to run jobs, but workers may not have registered functions
yet.  In that case, we would immediately start declaring jobs
LOST.  So give them a chance to show up first.

The gearman-plugin for jenkins currently tries to reconnect
every 3 seconds.  We could probably even lower that to 1 or 2.

Change-Id: I173b16ba78cecac91acec26b4f2d55f38610e5a2
Reviewed-on: https://review.openstack.org/31735
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Approved: Clark Boylan <clark.boylan@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Tested-by: Jenkins