From bbf17d74c9cc6694be341e2c8bf8c6bae2c18901 Mon Sep 17 00:00:00 2001 From: Jason Antman Date: Tue, 8 Jul 2014 21:44:11 -0400 Subject: [PATCH 1/2] MODULES-1202 - add module_spec_helper support for config items stringify_facts, trusted_node_data and ordering --- README.markdown | 32 ++++++++++++++++--- .../module_spec_helper.rb | 6 ++++ 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/README.markdown b/README.markdown index ec74e30a..ad182205 100644 --- a/README.markdown +++ b/README.markdown @@ -94,11 +94,33 @@ NOTE that this is specifically for initializing Puppet's core. If your project not have any dependencies on puppet and you just want to use the utility classes, see the next section. -To enable strict-variable or future-parser rspec-puppet failures export the -`STRICT_VARIABLES=yes` and/or `FUTURE_PARSER=yes` environment variables. Eg: - - FUTURE_PARSER=yes STRICT_VARIABLES=yes rake spec - +A number of the Puppet parser features, controlled via configuration during a +normal puppet run, can be controlled by exporting specific environment +variables for the spec run. These are: + +* ``FUTURE_PARSER`` - set to "yes" to enable the [future parser](http://docs.puppetlabs.com/puppet/latest/reference/experiments_future.html), + the equivalent of setting [parser=future](http://docs.puppetlabs.com/references/latest/configuration.html#parser) + in puppet.conf. +* ``STRICT_VARIABLES`` - set to "yes" to enable strict variable checking, + the equivalent of setting [strict_variables](http://docs.puppetlabs.com/references/latest/configuration.html#strictvariables)=true + in puppet.conf. +* ``ORDERING`` - set to the desired ordering method ("title-hash", "manifest", or "random") + to set the order of unrelated resources when applying a catalog. Leave unset for the default + behavior, currently "random". This is equivalent to setting [ordering](http://docs.puppetlabs.com/references/latest/configuration.html#ordering) + in puppet.conf. +* ``STRINGIFY_FACTS`` - set to "no" to enable [structured facts](http://docs.puppetlabs.com/facter/2.0/fact_overview.html#writing-structured-facts), + otherwise leave unset to retain the current default behavior. This is equivalent to setting + [stringify_facts=false](http://docs.puppetlabs.com/references/latest/configuration.html#stringifyfacts) + in puppet.conf. +* ``TRUSTED_NODE_DATA`` - set to "yes" to enable [the $facts hash and trusted node data](http://docs.puppetlabs.com/puppet/latest/reference/lang_facts_and_builtin_vars.html), + which enabled ``$facts`` and ``$trusted`` hashes. This is equivalent to setting + [trusted_node_data=true](http://docs.puppetlabs.com/references/latest/configuration.html#trustednodedata) + in puppet.conf. + +As an example, to run spec tests with the future parser, strict variable checking, +and manifest ordering, you would: + + FUTURE_PARSER=yes STRICT_VARIABLES=yes ORDERING=manifest rake spec Using Utility Classes ===================== diff --git a/lib/puppetlabs_spec_helper/module_spec_helper.rb b/lib/puppetlabs_spec_helper/module_spec_helper.rb index f6ee67fd..e09ef87b 100644 --- a/lib/puppetlabs_spec_helper/module_spec_helper.rb +++ b/lib/puppetlabs_spec_helper/module_spec_helper.rb @@ -24,9 +24,15 @@ def verify_contents(subject, title, expected_lines) ## These depend on rspec-puppet #209 and #183 being released #c.parser = 'future' if ENV['FUTURE_PARSER'] == 'yes' #c.strict_variables = true if ENV['STRICT_VARIABLES'] == 'yes' + #c.stringify_facts = false if ENV['STRINGIFY_FACTS'] == 'no' + #c.trusted_node_data = true if ENV['TRUSTED_NODE_DATA'] == 'yes' + #c.ordering = ENV['ORDERING'] if ENV['ORDERING'] c.before :each do Puppet.settings[:strict_variables] = true if ENV['STRICT_VARIABLES'] == 'yes' Puppet.settings[:parser] = 'future' if ENV['FUTURE_PARSER'] == 'yes' + Puppet.settings[:stringify_facts] = false if ENV['STRINGIFY_FACTS'] == 'no' + Puppet.settings[:trusted_node_data] = true if ENV['TRUSTED_NODE_DATA'] == 'yes' + Puppet.settings[:ordering] = ENV['ORDERING'] if ENV['ORDERING'] end end From 33a6abf14ad0de9ad1c5bb4d6dc7ed16b66d669e Mon Sep 17 00:00:00 2001 From: Jason Antman Date: Tue, 8 Jul 2014 22:21:29 -0400 Subject: [PATCH 2/2] MODULES-1202 clarify upstream PR in comment --- lib/puppetlabs_spec_helper/module_spec_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/puppetlabs_spec_helper/module_spec_helper.rb b/lib/puppetlabs_spec_helper/module_spec_helper.rb index e09ef87b..0c737ce8 100644 --- a/lib/puppetlabs_spec_helper/module_spec_helper.rb +++ b/lib/puppetlabs_spec_helper/module_spec_helper.rb @@ -24,6 +24,7 @@ def verify_contents(subject, title, expected_lines) ## These depend on rspec-puppet #209 and #183 being released #c.parser = 'future' if ENV['FUTURE_PARSER'] == 'yes' #c.strict_variables = true if ENV['STRICT_VARIABLES'] == 'yes' + ## These depend on rspec-puppet #212 being released #c.stringify_facts = false if ENV['STRINGIFY_FACTS'] == 'no' #c.trusted_node_data = true if ENV['TRUSTED_NODE_DATA'] == 'yes' #c.ordering = ENV['ORDERING'] if ENV['ORDERING']