(#16437) Additional database pool config options

* conn-max-age: How many minutes a database connection can be idle
  before we terminate the connection. We default to 60 minutes.

* conn-keep-alive: How often, in minutes, should we send a keep-alive
  query to the database. We default to every 240 minutes.

Both of these can be used to configure PuppetDB so that it doesn't run
afoul of things like idle connection termination on load balancers.

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Extract helper middleware from command endpoint
Standardize facts app

This app now contains all of its own logic about what subroutes it
contains. Also, the `node` is now simply obtained from the route rather
than adding it to the params list.
Standardize metrics app

This standardizes its structure with other apps.
Standardize node app

This also standardizes this app with the others, turning it into a
proper moustache app, and delegating handling of subroutes to the app
itself.
Standardize resources app

Once again, this standardizes the resources app with the others, making
it a moustache app with its own routing.
Standardize status app
Standardize version app
Standardize catalog app
Standardize population app
Delegate any method to HTTP apps

This prevents the top-level v1 and experimental apps from having to know
which methods are supported by the nested apps.
Introduce API v2

This is currently exactly the same as v1, and indeed the v2 apps simply
wrap their corresponding v1 apps, but gives us a place to add the next
version of the apps as they develop.
Add a v2 facts API with support for getting fact values

This implements a generic /v2/facts?query=[...] endpoint, which can be
used to, among other things, get all values of a given fact on all nodes
(or set of facts on a subset of nodes). The format returned is:

    [{:node <node> :fact <fact name> :value <fact value>}
     ...
     {:node <node> :fact <fact name> :value <fact value>}]

/v2/facts/<node> can still be used to get the facts for a given node (as
can /v2/facts?query=["=", ["node", "name"], <node>]), though the results
will now be returned in the above format.
Add support for inequalities to fact query
Update facts query spec
Use the /v2/facts API in the facts terminus
add a gemfile to build puppetdb-terminus
Improve failure output for node test

This commit improves the output that is logged when tests fail
in the http/v1/node test, to simplify debugging the failures.
Fix postgres query for numeric comparisons

This commit changes the regex that we are using for
numeric comparisons in postgres to a format that
is compatible with both 8.4 and 9.1.
Add support for a test configuration file

This commit adds support for a configuration file to be used
during unit test runs.  At present, the only thing that you
can define in the config file is a function that returns
a map of database settings.  There is a default configuration
file provided, which simply returns the same database settings
that we were using before (an in-memory hsql database with
a random UUID).  However, it also provides instruction for
creating a local override of the default config file, including
an example of how to configure your tests to run against
postgres instead of hsql.

This commit also tweaks the with-test-db fixture to call
a database-cleanup function prior to running the database
migration.  This cleanup function drops all of the tables
if they exist, so that each test can start with a fresh db.