Remove redundant use of raw string from test

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Add demarcate macro for automatic start/end msgs

We had several bits of code that would log "Starting foo", then do foo,
then log "Finished foo". That can be automated through a simple macro.

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Add publish-json! func for submitting objs to mq

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Add isa-datetime? func for use in preconditions

We had `(satisfies? ICoerce foo)` in a few places, and this captures
that in a function with a handy name.

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Remove use of current_timetamp

For time-based interactions with the database, we need to standardize on
one of two approaches:

1) Always use the database's notion of time
2) Always use the JVM's notion of time

Mixing these two things can result in some seriously strange race
conditions between the daemon's idea of time (like when we stamp
messages with a received-time annotation) and the database's idea of
time.

This patchset removes any lingering use of `current_timetamp`, replacing
such usage with JVM time.

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Add stale-nodes query function

Returns the list of nodes that haven't seen any activity in the supplied
time interval. "Acivity" is defined as having received a new catalog or
set of facts in the given time interval.

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Add funcs for internal/external command submission

There are 3 different ways in which commands get submitted:

* Send a raw command via HTTP, to an external PuppetDB daemon's
  /commands endpoint. benchmark.clj does this.

* Send an unassembled command (you have access to the command name,
  version and payload) via JMS. In-process code that needs to send a
  specific command needs this.

* Send a raw command via JMS. In-process code that needs to send a
  command, but has received it from an external source (like the
  /commands endpoint)

This patchset creates proper functions for each of these situations.

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Auto-deactivation of stale nodes

Adds the `node-ttl-days` parameter, which defines how long a node can
continue without seeing new activity (new catalogs, facts, etc) before
it's automatically deactivated during a garbage-collection run.

The default behavior is the same as before: no automatic deactivation of
anything.

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Rename isa-datetime? to datetime?

This is more in line with clojure idioms (string? number? etc).

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Code review fixups

* Default node-ttl-days to 0 instead of nil, and make the conditional
  check simply look for a positive number. That's a better way to handle
  edge cases

* Rename `db-compactor` to `sweep-database!`. It more accurately
  describes what we're doing

* Create a `send-command!` function and pass that into
  `sweep-database!`. That way, the function doesn't need to know the
  implementation details of _how_ to send a command.

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Fix typo

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Change debug arg from -d to -D

This prevents it from conflicting with "directory" arguments, commonly
represented as "-d".

Signed-off-by: Deepak Giridharagopal <deepak@puppetlabs.com>
Merge pull request #240 from grimradical/change-debug-flag

Change debug arg from -d to -D
Refactor acceptance setup scripts

Our acceptance setup scripts were pretty heinous prior to this
commit.  They used a lot of semi-global variables, and there
was one in particular (00_setup.rb) that was way, way too long
and chock-full of confusing conditionals.  We were headed for
maintenance headaches.

This commit cleans them up and hopefully makes them significantly
more maintainable, and also should allow support for heterogenous
test runs (we were previously limited to test runs wherein all
nodes were from the same osfamily).
Merge pull request #238 from grimradical/auto-deactivation-of-stale-nodes

Auto deactivation of stale nodes
Fixes based on pull req comments
Merge pull request #241 from cprice-puppet/maint/master/refactor-acceptance-setup-script

Refactor acceptance setup scripts
Update CONTRIBUTING.md to be in line with Puppet

This is almost the exact same as the updated Puppet version of the
document.
Merge pull request #242 from nicklewis/update-contributing-document

Update CONTRIBUTING.md to be in line with Puppet
Fix issues with using new version of jetty.ini on upgrade

Previously the user could choose to use the "new" version of jetty.ini,
which was a template including a placeholder password. During a regular
install, we run puppetdb-ssl-setup, which replaces the placeholder with
the actual password. However, during an upgrade, we weren't running it.
Now, we will always run the script, and determine whether or not to
generate a keystore/truststore/password based on the existence of the
password file. If it already exists, we will update the jetty.ini to use
it.