puppetlabs/beaker — pull request #390 by jpartlow (2014-08-06 16:45:05+00:00)
Title: (QENG-188) Allow foss runs to use service scripts

Prior to this commit, any run of beaker with a non-pe master that
attempted to stand up a master with a particular configuration in order
to test against it using the with_puppet_running_on() helper would
always stand up a webrick master by executing `puppet master ` and
then later stop it with `kill`.

The platform team needs to be able to run acceptance suites in which the
puppetmaster is started/stopped using package provided init scripts, or
by restarting apache if a passenger puppetmaster package is installed.

This PR takes the approach of enhancing Beaker::Host with a few query
methods controlled by host properties, either set in the hosts.cfg, or
directly on a master Beaker::Host instance during the execution of a
setup step. The added properties are:

* 'use-service' : if true, service scripts will be used instead of
manually starting a webrick master
* 'passenger' : if true, indicates a passenger package has been
installed, and by default graceful service restarts will be used
* 'puppetservice' : the 'puppetservice' property has been added to the
Beaker::Host::Unix.foss_defaults with the value of 'puppetmaster'. It
should be set to the appropriate service script name for passenger if a
passenger package has been installed.
* 'graceful-restarts' : can be set false if you want to stop/start with
service scripts rather than use graceful restarts when running with
passenger

The Beaker::Host#uses_passenger! call may be used to set a host
appropriately for passenger.

The graceful restarts facility of the dsl helper's bounce method assumes
apache2 was used for passenger and that apach2ctl is available.

Any existing test suite which does not 'opt-in' to any of these service
host changes by specifying any of the above properties should not be
effected by this commit.

There is also a spec related change to the FakeHost helper, which
previously was a stub pretending to provide Beaker::Host like facilities
and recording commands for review. This became unwieldy when the
various query methods for use_service_scripts? is_using_passenger? and
so forth were added, and the FakeHost has been updated to instead use
Beaker::Host.create to provide a host instance that is then extended
with the MockedExec module stubbing the exec facilities for testing.