(#12464) Avoid unnecessarily reloading facts when node_name_fact is not set

In fixing #8341 we reduced the caching of facts, leading to a performance
regression in puppet apply. Puppet apply loaded facts twice, first to look up
the fact for node_name_fact, and then a second time under the new node name
given by node_name_fact. This optimizes the common case where node_name_fact
is not set so that facts are only looked up once.

Reported in #12310.
(#12310) Remove process_name instrumentation listener

This was causing a performance regression in 2.7.10. Removing it for now, to
be added back later when the issue is fixed.
(#12296) Test cycle detection on real Puppet::Type instances.

We have found a couple of places where the behaviour of the items tested, and
the behaviour of the real system, differ - because the tests were run over
simpler objects than the real Puppet::Type instances we work on in the field.

This moves from testing on fake things to testing on the real deal, which
gives us a much more solid basis to trust the tests.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
(#12296) Make `Puppet::Type` ordered.

Type instances have a reasonable natural order, which allows us to make them
Comparable.  This, in turn, makes any interaction where ordering is of
interest easier to deal with.

This implementation uses the string form of the resource as the basis for
comparison, which is a reasonable starting point from existing definitions of
ordering over resource instances.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
(#12296) Now that `Puppet::Type` is ordered, use that.

This eliminates the proxy sorting in the graph library, which was working
around the fact that Puppet::Type was not able to be ordered out of the box.

That makes the whole process significantly more robust.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Make `Puppet::Provider` ordered.

Like types, our providers have a natural internal order.  Exposing that allows
us to eliminate proxy sorting everywhere that it is done, and have more
uniform treatment of our types.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Use natural ordering of Puppet::Provider.

The module tool used to generate and sort by a proxy key for providers, when
detailing their content.  Instead, this can use the natural ordering of
providers previously introduced.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
(#12296) Acceptance test for cycle detection in graphs.

This adds a simple acceptance test that validates we detect and report cycles
in a catalog as we compile and try to execute it.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
(#2927) Acceptance test for symbolic file modes.

This adds an acceptance test that validates that symbolic file modes are
functional on all our platforms, as expected.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Property Spec cleanup: extract new subclass to let method.

We need a shiny, new subclass of Puppet::Property every test, because we
modify class level things - and so we would pollute the tests if we touched
the same class object.

This extracts the logic around that to a let method, making the lifecycle
easier to follow by eliminating a member variable.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Property Spec cleanup: extract mock provider to let method.

This helps eliminate member variables in tests, making it easier to see where
state is or isn't shared between tests.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Property Spec cleanup: extract mock resource to let method.

This helps eliminate member variables in tests, making it easier to see where
state is or isn't shared between tests.  This only tackles the top level stub
object, rather than the embedded versions that overwrote it in other tests.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Property Spec cleanup: extract property instance to a let method.

This helps eliminate member variables in tests, making it easier to see where
state is or isn't shared between tests.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Property Spec cleanup: remove some pointless extra stubs.

One test context had a duplicate version of the outer instance management
code, probably because it was in a different class so couldn't see the member.

Replacing the outer version with let methods means that we also see the
helpers down in our nested contexts, so we can ditch the extra code.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Property Spec cleanup: remove unused instance variable.

Nobody actually used the object that was set up at the start of this context,
so we can just eliminate it.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Property Spec cleanup: extract more let methods.

This helps eliminate member variables in tests, making it easier to see where
state is or isn't shared between tests.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Property Spec cleanup: last let method extraction.

This helps eliminate member variables in tests, making it easier to see where
state is or isn't shared between tests.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Property Spec cleanup: eliminate stubbing of resource and provider.

Now that the state and scope of all our resources and providers is clear, it
becomes much easier to replace the stubs and mocks with real instances.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Add unit tests for the `insysc?` method of a property.

Previously this core, vital method was covered by a bunch of other random
stuff, including acceptance tests, but it didn't actually have tests that
belonged to just it.

This was revealed to be a problem in the last refactor of the code, which blew
up in nasty ways when an edge case wasn't found.

These tests do, in fact, show up that problem and everything.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Fix bugs around the finer-grained insync? protocol.

Due to the lack of effective testing around `insync?`, when I refactored it I
missed one of the inequality cases.  This restores the correct behaviour, in a
separate commit to call out the actual change in structure better.

It includes some specific tests around the new `property_matches?` method, to
ensure that it preserves the current - if odd - behaviour.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>