[PATCH/puppet 1/2] (#6513) Adjust P::U::Settings test name to reflect what it tests

1 view
Skip to first unread message

Jacob Helwig

unread,
Mar 5, 2011, 1:48:04 PM3/5/11
to puppe...@googlegroups.com, Jacob Helwig
The 'should interpolate found values using the current environment' wasn't
actually testing what it was describing, since the environment variable is
special cased.

Signed-off-by: Jacob Helwig <ja...@puppetlabs.com>
---

Local branch: ticket/2.6.x/6513-propigate-environment-in-settings-values

spec/unit/util/settings_spec.rb | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/spec/unit/util/settings_spec.rb b/spec/unit/util/settings_spec.rb
index 7bca44b..3ed843b 100755
--- a/spec/unit/util/settings_spec.rb
+++ b/spec/unit/util/settings_spec.rb
@@ -331,7 +331,7 @@ describe Puppet::Util::Settings do
@settings.value(:one, "env").should == "envval"
end

- it "should interpolate found values using the current environment" do
+ it 'should use the current environment for $environment' do
@settings.setdefaults :main, :myval => ["$environment/foo", "mydocs"]

@settings.value(:myval, "myenv").should == "myenv/foo"
--
1.7.4.1

Jacob Helwig

unread,
Mar 5, 2011, 1:48:05 PM3/5/11
to puppe...@googlegroups.com, Jacob Helwig
For example with the following:

test.conf:
[master]
rrddir = /var/lib/puppet/rrd
templatedir = /var/lib/puppet/templates
[env_a]
templatedir = $rrddir/templates
rrddir = /tmp/env_a/

The command:
RUBYLIB=lib bin/puppet master --config ./test.conf --environment env_a --configprint templatedir

originally produced '/var/lib/puppet/rrd/templates' instead of the
expected '/tmp/env_a/templates'

Signed-off-by: Jacob Helwig <ja...@puppetlabs.com>
---

Local branch: ticket/2.6.x/6513-propigate-environment-in-settings-values

lib/puppet/util/settings.rb | 2 +-
spec/unit/util/settings_spec.rb | 11 ++++++++++-
2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
index 626ed20..f243b86 100644
--- a/lib/puppet/util/settings.rb
+++ b/lib/puppet/util/settings.rb
@@ -91,7 +91,7 @@ class Puppet::Util::Settings
varname = $2 || $1
if varname == "environment" and environment
environment
- elsif pval = self.value(varname)
+ elsif pval = self.value(varname, environment)
pval
else
raise Puppet::DevError, "Could not find value for #{value}"
diff --git a/spec/unit/util/settings_spec.rb b/spec/unit/util/settings_spec.rb
index 3ed843b..07b712c 100755
--- a/spec/unit/util/settings_spec.rb
+++ b/spec/unit/util/settings_spec.rb
@@ -284,7 +284,8 @@ describe Puppet::Util::Settings do
@settings = Puppet::Util::Settings.new
@settings.setdefaults :section,
:config => ["/my/file", "a"],
- :one => ["ONE", "a"]
+ :one => ["ONE", "a"],
+ :two => ["TWO", "b"]
FileTest.stubs(:exist?).returns true
Puppet.stubs(:run_mode).returns stub('run_mode', :name => :mymode)
end
@@ -337,6 +338,14 @@ describe Puppet::Util::Settings do


@settings.value(:myval, "myenv").should == "myenv/foo"

end

+ it "should interpolate found values using the current environment" do
+ text = "[main]\none = mainval\n[myname]\none = nameval\ntwo = $one/two\n"
+ @settings.stubs(:read_file).returns(text)
+ @settings.parse
+
+ @settings.value(:two, "myname").should == "nameval/two"
+ end
+
it "should return values in a specified environment before values in the main or name sections" do
text = "[env]\none = envval\n[main]\none = mainval\n[myname]\none = nameval\n"
@settings.stubs(:read_file).returns(text)
--
1.7.4.1

Nigel Kersten

unread,
Mar 6, 2011, 3:44:36 PM3/6/11
to puppe...@googlegroups.com, Jacob Helwig
On Sat, Mar 5, 2011 at 10:48 AM, Jacob Helwig <ja...@puppetlabs.com> wrote:
For example with the following:

test.conf:
 [master]
     rrddir = /var/lib/puppet/rrd
     templatedir = /var/lib/puppet/templates
 [env_a]
     templatedir = $rrddir/templates
     rrddir = /tmp/env_a/

The command:
 RUBYLIB=lib bin/puppet master --config ./test.conf --environment env_a --configprint templatedir

originally produced '/var/lib/puppet/rrd/templates' instead of the
expected '/tmp/env_a/templates'


Jacob, is this actually expanding the list of supported settings in environments?

As I understand it, the only settings that work on a per-environment basis currently are modulepath and manifestdir, and I thought this was a deliberate design decision to push people towards using modules, rather than explicitly having a templatedir, libdir, etc per environment.

I'm not at all convinced yet that every setting available in [master] should be able to be set per [environment]. 


Nigel Kersten

unread,
Mar 6, 2011, 3:45:11 PM3/6/11
to puppe...@googlegroups.com, Jacob Helwig
On Sun, Mar 6, 2011 at 12:44 PM, Nigel Kersten <ni...@puppetlabs.com> wrote:

As I understand it, the only settings that work on a per-environment basis currently are modulepath and manifestdir, and I 

Correction: modulepath and manifest, not manifestdir.

 

Jacob Helwig

unread,
Mar 6, 2011, 4:15:28 PM3/6/11
to Nigel Kersten, puppe...@googlegroups.com
It's not expanding the list of things that can be set per environment (which currently aren't limited to that list, anyway). It is letting you set your environment modulepath relative to that environment's manifestdir, if you were setting both in the environment. Currently this would not actually Do The Right Thing.
--
Sent from my phone. Please excuse my brevity.

Luke Kanies

unread,
Mar 6, 2011, 5:19:11 PM3/6/11
to puppe...@googlegroups.com
As Jacob said, per-environment settings aren't limited at all any more, and I don't think they have been for the whole 2.6 release series.


--
Always behave like a duck - keep calm and unruffled on the surface but
paddle like the devil underneath. -- Jacob Braude
---------------------------------------------------------------------
Luke Kanies -|- http://puppetlabs.com -|- +1(615)594-8199


Nigel Kersten

unread,
Mar 6, 2011, 6:45:28 PM3/6/11
to puppe...@googlegroups.com, Luke Kanies


On Sun, Mar 6, 2011 at 2:19 PM, Luke Kanies <lu...@puppetlabs.com> wrote:

As Jacob said, per-environment settings aren't limited at all any more, and I don't think they have been for the whole 2.6 release series.


Not every setting available in [master] works on a per-environment basis. exec_terminus etc come to mind. Did we document what changed in 2.6.x in this regard?

Jacob Helwig

unread,
Mar 6, 2011, 8:02:08 PM3/6/11
to puppe...@googlegroups.com, Nigel Kersten, Luke Kanies
Nigel Kersten <ni...@puppetlabs.com> wrote:
--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to puppe...@googlegroups.com.
To unsubscribe from this group, send email to puppet-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

We should probably break this into a separate thread, since this is starting to sound like we've moved on to discussing a separate bug or documentation issue.

Luke Kanies

unread,
Mar 6, 2011, 8:19:12 PM3/6/11
to Nigel Kersten, puppe...@googlegroups.com
I agree with Jacob that this is a separate thread, but the short rule is:

All settings support environments, but not all of the code that uses settings does.  E.g., anything global like the terminus settings is still, um, global.

It's nearly impossible to document all of these, unfortunately, but we should clearly do a better job.
Reply all
Reply to author
Forward
0 new messages