(maint) Use transaction_with_resource helpers to build up catalog and transaction

Cleanup the test to reuse the helpers that build up the catalog and
transaction. Eliminate instance variables of the form `@transaction` as
these can and should be local to the rspec example.
(PUP-1843) Clean up hiera terminus

The data_binding/hiera_spec.rb had a specific after block to clear up
the hiera terminus for following tests.  Moved this to the
shared_behaviors/hiera_indirections so that both indirector/hiera_spec
and data_binding/hiera_spec would be cleaned up, preventing order
dependent errors caused by global terminus state leaking between tests.
Merge branch 'maint/master/transaction_spec'

* maint/master/transaction_spec:
  (maint) Use transaction_with_resource helpers to build up catalog and transaction
  (maint) Use real types and providers to exercise post_resource_eval
(PUP-2657) FFI Puppet::Util::Windows::Error

 - Remove dependency on 'windows/error'
 - Expand FFI helper methods from MemoryPointer to Pointer as we need
   them to operate on a chunk of memory that will be LocalFree'd (i.e.
   MemoryPointer is set to own the memory and autorelease when done)
 - Unfortunately, attempts to use FFI to call GetLastError were futile.
   FFI.errno should automatically be capturing the GetLastError result
   of any call made through FFI, however this doesn't appear to be the
   case in practice.  Furthermore, attempting to define GetLastError as
   a function in FFI yields the same result.  A number of tests fail
   as the error code is being stomped / swallowed.  The solution is to
   use Win32API.new to define / use this single function.  Sigh.
Merge pull request #2695 from Iristyle/ticket/master/PUP-2657-FFI-Puppet-Util-Windows-Error

(PUP-2657) FFI Puppet::Util::Windows:Error
Merge remote-tracking branch 'ffrank/ticket/3.6.1/PUP-2660-keys-not-purged-missing-user' into stable

* ffrank/ticket/3.6.1/PUP-2660-keys-not-purged-missing-user:
  (PUP-2660) user: set the user should-value when generating ssh_authorized_keys
(docs) Edit header of metaparameter reference

The language here was kind of ancient, and this commit updates it.
("Instances" -> "resources", among other things.)
(PUP-2659) Synchronize all webrick requests.

Puppet had some scattered thread safety code, which was removed in
4da350b, because Puppet itself is not using threads.  However, Webrick
starts a new thread to handle each incoming request.  This was probably
causing subtle problems during simultaneous requests to a webrick
master, but since 3.6.1 the issue became much more noticeable due to the
fix for PUP-2610 merged in 0dc5ad3 which was fixing a case where rack
masters would lose track of newly established environment loaders using
the master settings.  The change to Puppet::Context used a new
mark/rollback method for overriding context making it very obvious when
concurrent threads would collide attempting to rollback the same marker
and exhaust the context stack.

We are fixing this by synchronizing around incoming webrick requests,
effectively serializing their access to Puppet's innards.  Initial
manual benchmarking did not show a significant decrease in performance,
probably because Ruby uses green threads handled by the vm which cannot
take advantage of multiple processors.
(PUP-2659) Add a concurrency acceptance test

It is difficult to test concurrent requests with Beaker as it does not
allow parrallel requests to be made.  I'm using backgrounded subprocess
in a shell script to get around this, and I'm only making direct catalog
requests via curl, since an agent will halt if it spots another's pidfile in
existence on the same node.  Still, this is one of the major calls that
the agent makes, and it does effectively expose PUP-2659 on a
non-synchronized webrick master.
(PUP-2639) Change default timeout to 3 minutes

The 5 second timeout was selected assuming that the major use case would
be around a development workflow in which a user edits manifests on a
master and then immediately runs an agent to see the effect. It turns
out that this caused a lot of problems for a much more common and
impactful case of users updating to directory environments where they
ended up with excessive CPU usage. Nearly any value here is arbitrary
except 0 (purely development workflow) and unlimited (best choice for
production systems).

This makes the almost arbitrary decision that a 3 minute timeout will
create less confusion for upgrading users. It means that a development
workflow will require more restarts, however. :(
Merge pull request #2710 from zaphod42/feature/stable/pup-2639-increase-environment-timeout

(PUP-2639) Change default timeout to 3 minutes
Merge remote-tracking branch 'upstream/stable'

* upstream/stable:
  (PUP-2639) Change default timeout to 3 minutes
  (PUP-2660) user: set the user should-value when generating ssh_authorized_keys
(PUP-2689) Make AST Resource check tags against "inherited" tags

This overrides the tagged? method in AST Resource to also search
for tags in its containing resource. These tags will be set when
the resource is finalized (just before serialization on transformation
to external format).

If this is not done, resources will have a different tag set when
a search is made for the node itself (exported or virtual) vs. searching
external resources.

This also correct minor problems with passing an array (which could
result in an array being set as a tag).
It was also possible for empty tags to be set if a string tag contained
multiple :: in sequence, or if ending with ::. Now an error is raised
for these conditions (just like for empty segments generated by using a
sequence of commas (which was on a different code path).
(PUP-2703) Make 'tag' be a statement function

Tag function should not require parentheses.
(PUP-2692) Cache function info with the functions

The Puppet::Parser::Functions code used to hold onto two different sets
of information about the loaded functions: a hash of environment name to
environment module, and a hash of *environment* to a hash of function
name to function information. It was assumed that the
Puppet::Node::Environment class was written to properly work as a hash
key since it implemented both hash() and ==(). This assumption being
true would have meant that different instances for the same environment
would be the same key and the second hash above would not grow beyond a
reasonable size for the number of environments.

It turns out that to be a proper hash key a class must implement hash()
and eql?() (not ==()). Because Puppet::Node::Environment didn't do this
the hash of function information would just continually grow when
directory environments with an environment_timeout != unlimited was in
use. This is because the Puppet::Node::Environment instance would be
periodically thrown out by the Puppet::Environments::Cached loader and
be recreated, but the Puppet::Parser::Functions hash would hold onto the
old instance.

The fix for this here is to consolidate all of the function information
into a single structure. The function modules now have a few methods to
get the function metadata instead of it being stored separately. This is
completely backwards compatible and does not conflict with any existing
uses of the environment modules since the new methods are on the module
itself and will not be part of the mixin.
(PUP-2692) Correctly implement environment equality

This fixes environment equality to make it work as a hash key. It also
adds tests around this functionality.
Merge pull request #2708 from jpartlow/issue/stable/pup-2659-synchronize-webrick-rest

Issue/stable/pup 2659 synchronize webrick rest
Merge branch 'stable'
(maint) Consolidate case statement in /pson/pure/generator.rb for the Float module.

Prior to this commit, the to_pson method for the Float module contained
unnecessary duplicated code.  This commit removes the duplication by
consolidating the case statements into a single if statement.
(doc) Add some missing options to apply/agent/doc/queue usage messages