diff options
| author | James Turnbull <james@lovedthanlost.net> | 2008-02-29 12:49:06 +1100 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2008-02-29 12:49:06 +1100 |
| commit | f1d75c8bc2604ea396c6d88ba7eef866f48f6046 (patch) | |
| tree | b534a6011dd4074a61ff76962b855bb404faa310 | |
| parent | 62865e0dc921b3d81a89d59c387c3697f37a629c (diff) | |
| parent | 43aea83eb1ac388566246e5418394e31a4cad697 (diff) | |
| download | puppet-f1d75c8bc2604ea396c6d88ba7eef866f48f6046.tar.gz puppet-f1d75c8bc2604ea396c6d88ba7eef866f48f6046.tar.xz puppet-f1d75c8bc2604ea396c6d88ba7eef866f48f6046.zip | |
Merge branch '0.24.x' of git://reductivelabs.com/puppet into 0.24.x
| -rw-r--r-- | CHANGELOG | 18 | ||||
| -rwxr-xr-x | bin/puppetrun | 7 | ||||
| -rw-r--r-- | lib/puppet/defaults.rb | 7 | ||||
| -rw-r--r-- | lib/puppet/file_serving/file_base.rb | 1 | ||||
| -rw-r--r-- | lib/puppet/network/client.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/astarray.rb | 24 | ||||
| -rw-r--r-- | lib/puppet/parser/compiler.rb | 5 | ||||
| -rw-r--r-- | lib/puppet/parser/interpreter.rb | 6 | ||||
| -rw-r--r-- | lib/puppet/provider/package/yumhelper.py | 14 | ||||
| -rw-r--r-- | lib/puppet/type/service.rb | 9 | ||||
| -rwxr-xr-x | spec/integration/node.rb | 5 | ||||
| -rwxr-xr-x | spec/unit/file_serving/file_base.rb | 6 | ||||
| -rwxr-xr-x | spec/unit/parser/compiler.rb | 4 | ||||
| -rwxr-xr-x | spec/unit/parser/interpreter.rb | 286 | ||||
| -rwxr-xr-x | spec/unit/ral/type/exec.rb (renamed from spec/unit/ral/types/exec.rb) | 0 | ||||
| -rwxr-xr-x | spec/unit/ral/type/file.rb (renamed from spec/unit/ral/types/file.rb) | 0 | ||||
| -rwxr-xr-x | spec/unit/ral/type/interface.rb (renamed from spec/unit/ral/types/interface.rb) | 0 | ||||
| -rwxr-xr-x | spec/unit/ral/type/mount.rb (renamed from spec/unit/ral/types/mount.rb) | 0 | ||||
| -rwxr-xr-x | spec/unit/ral/type/nagios.rb (renamed from spec/unit/ral/types/nagios.rb) | 0 | ||||
| -rwxr-xr-x | spec/unit/ral/type/package.rb (renamed from spec/unit/ral/types/package.rb) | 0 | ||||
| -rwxr-xr-x | spec/unit/ral/type/schedule.rb (renamed from spec/unit/ral/types/schedule.rb) | 0 | ||||
| -rwxr-xr-x | spec/unit/ral/type/service.rb (renamed from spec/unit/ral/types/service.rb) | 15 | ||||
| -rwxr-xr-x | spec/unit/ral/type/user.rb (renamed from spec/unit/ral/types/user.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/basic.rb (renamed from test/ral/types/basic.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/cron.rb (renamed from test/ral/types/cron.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/exec.rb (renamed from test/ral/types/exec.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/file.rb (renamed from test/ral/types/file.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/file/target.rb (renamed from test/ral/types/file/target.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/filebucket.rb (renamed from test/ral/types/filebucket.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/fileignoresource.rb (renamed from test/ral/types/fileignoresource.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/filesources.rb (renamed from test/ral/types/filesources.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/group.rb (renamed from test/ral/types/group.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/host.rb (renamed from test/ral/types/host.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/mailalias.rb (renamed from test/ral/types/mailalias.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/parameter.rb (renamed from test/ral/types/parameter.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/port.rb (renamed from test/ral/types/port.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/property.rb (renamed from test/ral/types/property.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/resources.rb (renamed from test/ral/types/resources.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/service.rb (renamed from test/ral/types/service.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/sshkey.rb (renamed from test/ral/types/sshkey.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/tidy.rb (renamed from test/ral/types/tidy.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/user.rb (renamed from test/ral/types/user.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/yumrepo.rb (renamed from test/ral/types/yumrepo.rb) | 0 | ||||
| -rwxr-xr-x | test/ral/type/zone.rb (renamed from test/ral/types/zone.rb) | 0 |
44 files changed, 222 insertions, 187 deletions
@@ -1,7 +1,19 @@ - Removed the loglevels from the valid values for 'logoutput' + Fixing #1062 by moving the yamldir setting to its own yaml + section. This should keep the yamldir from being created + on clients. + + Fixed #1047 -- Puppet's parser no longer changes the order + in which statements are evaluated, which means that case + statements can now set variables that are used by other + variables. + + Fixed #1063 -- the master correctly logs syntax errors when + reparsing during a single run. + + Removed the loglevels from the valid values for `logoutput` in the Exec resource type -- the log levels are specified - using the 'loglevel' parameter, not 'logoutput'. This never - worked, or at least hasn't for ages, and now the docs are + using the `loglevel` parameter, not `logoutput`. This never + worked, or at least hasn`t for ages, and now the docs are just correct. Somewhat refactored fileserving so that it no longer caches diff --git a/bin/puppetrun b/bin/puppetrun index c92b59fc6..d0823b9c5 100755 --- a/bin/puppetrun +++ b/bin/puppetrun @@ -274,12 +274,7 @@ else end # Now parse the config -config = File.join(Puppet[:confdir], "puppet.conf") -Puppet.parse_config(config) - -if File.exists? config - Puppet.settings.parse(config) -end +Puppet.parse_config if Puppet[:node_terminus] = "ldap" if options[:all] diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 520a18d1a..77792172f 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -140,8 +140,6 @@ module Puppet :show_diff => [false, "Whether to print a contextual diff when files are being replaced. The diff is printed on stdout, so this option is meaningless unless you are running Puppet interactively. This feature currently requires the ``diff/lcs`` Ruby library."], - :yamldir => {:default => "$vardir/yaml", :owner => "$user", :group => "$user", :mode => "750", - :desc => "The directory in which YAML data is stored, usually in a subdirectory."}, :daemonize => { :default => true, :desc => "Send the process into the background. This is the default.", :short => "D" @@ -672,5 +670,10 @@ module Puppet :rrdinterval => ["$runinterval", "How often RRD should expect data. This should match how often the hosts report back to the server."] ) + + Puppet.setdefaults(:yaml, + :yamldir => {:default => "$vardir/yaml", :owner => "$user", :group => "$user", :mode => "750", + :desc => "The directory in which YAML data is stored, usually in a subdirectory."} + ) end diff --git a/lib/puppet/file_serving/file_base.rb b/lib/puppet/file_serving/file_base.rb index 06b3ad9ef..e87d683aa 100644 --- a/lib/puppet/file_serving/file_base.rb +++ b/lib/puppet/file_serving/file_base.rb @@ -46,6 +46,7 @@ class Puppet::FileServing::FileBase # Determine how we deal with links. attr_reader :links def links=(value) + value = :manage if value == :ignore raise(ArgumentError, ":links can only be set to :manage or :follow") unless [:manage, :follow].include?(value) @links = value end diff --git a/lib/puppet/network/client.rb b/lib/puppet/network/client.rb index 0a0a72345..cf1782f79 100644 --- a/lib/puppet/network/client.rb +++ b/lib/puppet/network/client.rb @@ -7,6 +7,8 @@ require 'puppet/util/subclass_loader' require 'puppet/util/methodhelper' require 'puppet/sslcertificates/support' +require 'puppet/network/handler' + require 'net/http' # Some versions of ruby don't have this method defined, which basically causes diff --git a/lib/puppet/parser/ast/astarray.rb b/lib/puppet/parser/ast/astarray.rb index b66fd6bba..8f09aa922 100644 --- a/lib/puppet/parser/ast/astarray.rb +++ b/lib/puppet/parser/ast/astarray.rb @@ -16,16 +16,6 @@ class Puppet::Parser::AST # Evaluate our children. def evaluate(scope) - rets = nil - # We basically always operate declaratively, and when we - # do we need to evaluate the settor-like statements first. This - # is basically variable and type-default declarations. - # This is such a stupid hack. I've no real idea how to make a - # "real" declarative language, so I hack it so it looks like - # one, yay. - settors = [] - others = [] - # Make a new array, so we don't have to deal with the details of # flattening and such items = [] @@ -34,22 +24,14 @@ class Puppet::Parser::AST @children.each { |child| if child.instance_of?(AST::ASTArray) child.each do |ac| - if ac.class.settor? - settors << ac - else - others << ac - end + items << ac end else - if child.class.settor? - settors << child - else - others << child - end + items << child end } - rets = [settors, others].flatten.collect { |child| + rets = items.flatten.collect { |child| child.safeevaluate(scope) } return rets.reject { |o| o.nil? } diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb index 132ec15db..70cd6e11a 100644 --- a/lib/puppet/parser/compiler.rb +++ b/lib/puppet/parser/compiler.rb @@ -366,9 +366,8 @@ class Puppet::Parser::Compiler # Make sure all of our resources and such have done any last work # necessary. def finish - @catalog.resources.each do |name| - resource = @catalog.resource(name) - + #@catalog.resources.each do |name| + @catalog.vertices.each do |resource| # Add in any resource overrides. if overrides = resource_overrides(resource) overrides.each do |over| diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index d4655c403..f27c1c5c8 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -61,7 +61,11 @@ class Puppet::Parser::Interpreter # If a parser already exists, than assume that we logged the # exception elsewhere and reuse the parser. If one doesn't # exist, then reraise. - raise detail unless @parsers[environment] + if @parsers[environment] + Puppet.err detail + else + raise detail + end end end @parsers[environment] diff --git a/lib/puppet/provider/package/yumhelper.py b/lib/puppet/provider/package/yumhelper.py index 1142401b9..962b96ce4 100644 --- a/lib/puppet/provider/package/yumhelper.py +++ b/lib/puppet/provider/package/yumhelper.py @@ -13,8 +13,7 @@ OVERRIDE_OPTS = { 'logfile': '/dev/null' } -def pkg_lists(): - my = yum.YumBase() +def pkg_lists(my): my.doConfigSetup() for k in OVERRIDE_OPTS.keys(): @@ -28,10 +27,13 @@ def pkg_lists(): return my.doPackageLists('updates') try: - ypl = pkg_lists() + try: + my = yum.YumBase() + ypl = pkg_lists(my) + for pkg in ypl.updates: + print "_pkg %s %s %s %s %s" % (pkg.name, pkg.epoch, pkg.version, pkg.release, pkg.arch) + finally: + my.closeRpmDB() except IOError, e: print "_err IOError %d %s" % (e.errno, e) sys.exit(1) - -for pkg in ypl.updates: - print "_pkg %s %s %s %s %s" % (pkg.name, pkg.epoch, pkg.version, pkg.release, pkg.arch) diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb index c41a7883b..1b625cc41 100644 --- a/lib/puppet/type/service.rb +++ b/lib/puppet/type/service.rb @@ -28,6 +28,8 @@ module Puppet feature :enableable, "The provider can enable and disable the service", :methods => [:disable, :enable, :enabled?] + feature :controllable, "The provider uses a control variable." + newproperty(:enable, :required_features => :enableable) do desc "Whether a service should be enabled to start at boot. This property behaves quite differently depending on the platform; @@ -163,6 +165,13 @@ module Puppet desc "Specify a *stop* command manually." end + newparam(:control) do + desc "The control variable used to manage services (originally for HP-UX). + Defaults to the upcased service name plus ``START`` replacing dots with + underscores, for those providers that support the ``controllable`` feature." + defaultto { resource.name.gsub(".","_").upcase + "_START" if resource.provider.controllable? } + end + newparam :hasrestart do desc "Specify that an init script has a ``restart`` option. Otherwise, the init script's ``stop`` and ``start`` methods are used." diff --git a/spec/integration/node.rb b/spec/integration/node.rb index e4a311998..87ff448e4 100755 --- a/spec/integration/node.rb +++ b/spec/integration/node.rb @@ -10,10 +10,15 @@ require 'puppet/node' describe Puppet::Node, " when using the memory terminus" do before do @name = "me" + @old_terminus = Puppet::Node.indirection.terminus_class Puppet::Node.terminus_class = :memory @node = Puppet::Node.new(@name) end + after do + Puppet::Node.terminus_class = @old_terminus + end + it "should find no nodes by default" do Puppet::Node.find(@name).should be_nil end diff --git a/spec/unit/file_serving/file_base.rb b/spec/unit/file_serving/file_base.rb index e1a61cd65..ded6ae4a8 100755 --- a/spec/unit/file_serving/file_base.rb +++ b/spec/unit/file_serving/file_base.rb @@ -13,7 +13,11 @@ describe Puppet::FileServing::FileBase do Puppet::FileServing::FileBase.new("puppet://host/module/dir/file", :links => :manage).links.should == :manage end - it "should fail if :links is set to anything other than :manage or :follow" do + it "should consider :ignore links equivalent to :manage links" do + Puppet::FileServing::FileBase.new("puppet://host/module/dir/file", :links => :ignore).links.should == :manage + end + + it "should fail if :links is set to anything other than :manage, :follow, or :ignore" do proc { Puppet::FileServing::FileBase.new("puppet://host/module/dir/file", :links => :else) }.should raise_error(ArgumentError) end diff --git a/spec/unit/parser/compiler.rb b/spec/unit/parser/compiler.rb index 9980f2c6a..ab430da62 100755 --- a/spec/unit/parser/compiler.rb +++ b/spec/unit/parser/compiler.rb @@ -7,7 +7,7 @@ describe Puppet::Parser::Compiler do @node = Puppet::Node.new "testnode" @parser = Puppet::Parser::Parser.new :environment => "development" - @scope_resource = stub 'scope_resource', :builtin? => true + @scope_resource = stub 'scope_resource', :builtin? => true, :finish => nil, :ref => 'Class[main]' @scope = stub 'scope', :resource => @scope_resource, :source => mock("source") @compiler = Puppet::Parser::Compiler.new(@node, @parser) end @@ -529,4 +529,4 @@ describe Puppet::Parser::Compiler do lambda { @compiler.class_set("one", @node) }.should raise_error(Puppet::ParseError) end end -end
\ No newline at end of file +end diff --git a/spec/unit/parser/interpreter.rb b/spec/unit/parser/interpreter.rb index eb5dd9aaf..f2526c73d 100755 --- a/spec/unit/parser/interpreter.rb +++ b/spec/unit/parser/interpreter.rb @@ -2,148 +2,158 @@ require File.dirname(__FILE__) + '/../../spec_helper' -describe Puppet::Parser::Interpreter, " when creating parser instances" do +describe Puppet::Parser::Interpreter do before do @interp = Puppet::Parser::Interpreter.new - @parser = mock('parser') - end - - it "should create a parser with code if there is code defined in the :code setting" do - Puppet.settings.stubs(:value).with(:code, :myenv).returns("mycode") - @parser.expects(:string=).with("mycode") - @parser.expects(:parse) - Puppet::Parser::Parser.expects(:new).with(:environment => :myenv).returns(@parser) - @interp.send(:create_parser, :myenv).object_id.should equal(@parser.object_id) - end - - it "should create a parser with the main manifest when the code setting is an empty string" do - Puppet.settings.stubs(:value).with(:code, :myenv).returns("") - Puppet.settings.stubs(:value).with(:manifest, :myenv).returns("/my/file") - @parser.expects(:parse) - @parser.expects(:file=).with("/my/file") - Puppet::Parser::Parser.expects(:new).with(:environment => :myenv).returns(@parser) - @interp.send(:create_parser, :myenv).should equal(@parser) - end - - it "should return nothing when new parsers fail" do - Puppet::Parser::Parser.expects(:new).with(:environment => :myenv).raises(ArgumentError) - proc { @interp.send(:create_parser, :myenv) }.should raise_error(Puppet::Error) - end - - it "should create parsers with environment-appropriate manifests" do - # Set our per-environment values. We can't just stub :value, because - # it's called by too much of the rest of the code. - text = "[env1]\nmanifest = /t/env1.pp\n[env2]\nmanifest = /t/env2.pp" - file = mock 'file' - file.stubs(:changed?).returns(true) - file.stubs(:file).returns("/whatever") - Puppet.settings.stubs(:read_file).with(file).returns(text) - Puppet.settings.parse(file) - - parser1 = mock 'parser1' - Puppet::Parser::Parser.expects(:new).with(:environment => :env1).returns(parser1) - parser1.expects(:file=).with("/t/env1.pp") - parser1.expects(:parse) - @interp.send(:create_parser, :env1) - - parser2 = mock 'parser2' - Puppet::Parser::Parser.expects(:new).with(:environment => :env2).returns(parser2) - parser2.expects(:file=).with("/t/env2.pp") - parser2.expects(:parse) - @interp.send(:create_parser, :env2) - end -end - -describe Puppet::Parser::Interpreter, " when managing parser instances" do - before do - @interp = Puppet::Parser::Interpreter.new - @parser = mock('parser') - end - - it "should use the same parser when the parser does not need reparsing" do - @interp.expects(:create_parser).with(:myenv).returns(@parser) - @interp.send(:parser, :myenv).should equal(@parser) - - @parser.expects(:reparse?).returns(false) - @interp.send(:parser, :myenv).should equal(@parser) - end - - it "should create a new parser when reparse is true" do - oldparser = mock('oldparser') - newparser = mock('newparser') - oldparser.expects(:reparse?).returns(true) - oldparser.expects(:clear) - - @interp.expects(:create_parser).with(:myenv).returns(oldparser) - @interp.send(:parser, :myenv).should equal(oldparser) - @interp.expects(:create_parser).with(:myenv).returns(newparser) - @interp.send(:parser, :myenv).should equal(newparser) - end - - it "should fail intelligently if a parser cannot be created and one does not already exist" do - @interp.expects(:create_parser).with(:myenv).raises(ArgumentError) - proc { @interp.send(:parser, :myenv) }.should raise_error(ArgumentError) - end - - it "should keep the old parser if a new parser cannot be created" do - # Get the first parser in the hash. - @interp.expects(:create_parser).with(:myenv).returns(@parser) - @interp.send(:parser, :myenv).should equal(@parser) - - # Have it indicate something has changed - @parser.expects(:reparse?).returns(true) - - # But fail to create a new parser - @interp.expects(:create_parser).with(:myenv).raises(ArgumentError) - - # And make sure we still get the old valid parser - @interp.send(:parser, :myenv).should equal(@parser) - end - - it "should use different parsers for different environments" do - # get one for the first env - @interp.expects(:create_parser).with(:first_env).returns(@parser) - @interp.send(:parser, :first_env).should equal(@parser) - - other_parser = mock('otherparser') - @interp.expects(:create_parser).with(:second_env).returns(other_parser) - @interp.send(:parser, :second_env).should equal(other_parser) - end -end - -describe Puppet::Parser::Interpreter, " when compiling catalog" do - before do - @interp = Puppet::Parser::Interpreter.new - @node = stub 'node', :environment => :myenv - @compiler = mock 'compile' @parser = mock 'parser' end - it "should create a compile with the node and parser" do - @compiler.expects(:compile).returns(:config) - @interp.expects(:parser).with(:myenv).returns(@parser) - Puppet::Parser::Compiler.expects(:new).with(@node, @parser).returns(@compiler) - @interp.compile(@node) - end - - it "should fail intelligently when no parser can be found" do - @node.stubs(:name).returns("whatever") - @interp.expects(:parser).with(:myenv).returns(nil) - proc { @interp.compile(@node) }.should raise_error(Puppet::ParseError) - end -end - -describe Puppet::Parser::Interpreter, " when returning catalog version" do - before do - @interp = Puppet::Parser::Interpreter.new - end - - it "should ask the appropriate parser for the catalog version" do - node = mock 'node' - node.expects(:environment).returns(:myenv) - parser = mock 'parser' - parser.expects(:version).returns(:myvers) - @interp.expects(:parser).with(:myenv).returns(parser) - @interp.configuration_version(node).should equal(:myvers) + describe "when creating parser instances" do + it "should create a parser with code if there is code defined in the :code setting" do + Puppet.settings.stubs(:value).with(:code, :myenv).returns("mycode") + @parser.expects(:string=).with("mycode") + @parser.expects(:parse) + Puppet::Parser::Parser.expects(:new).with(:environment => :myenv).returns(@parser) + @interp.send(:create_parser, :myenv).object_id.should equal(@parser.object_id) + end + + it "should create a parser with the main manifest when the code setting is an empty string" do + Puppet.settings.stubs(:value).with(:code, :myenv).returns("") + Puppet.settings.stubs(:value).with(:manifest, :myenv).returns("/my/file") + @parser.expects(:parse) + @parser.expects(:file=).with("/my/file") + Puppet::Parser::Parser.expects(:new).with(:environment => :myenv).returns(@parser) + @interp.send(:create_parser, :myenv).should equal(@parser) + end + + it "should return nothing when new parsers fail" do + Puppet::Parser::Parser.expects(:new).with(:environment => :myenv).raises(ArgumentError) + proc { @interp.send(:create_parser, :myenv) }.should raise_error(Puppet::Error) + end + + it "should create parsers with environment-appropriate manifests" do + # Set our per-environment values. We can't just stub :value, because + # it's called by too much of the rest of the code. + text = "[env1]\nmanifest = /t/env1.pp\n[env2]\nmanifest = /t/env2.pp" + file = mock 'file' + file.stubs(:changed?).returns(true) + file.stubs(:file).returns("/whatever") + Puppet.settings.stubs(:read_file).with(file).returns(text) + Puppet.settings.parse(file) + + parser1 = mock 'parser1' + Puppet::Parser::Parser.expects(:new).with(:environment => :env1).returns(parser1) + parser1.expects(:file=).with("/t/env1.pp") + parser1.expects(:parse) + @interp.send(:create_parser, :env1) + + parser2 = mock 'parser2' + Puppet::Parser::Parser.expects(:new).with(:environment => :env2).returns(parser2) + parser2.expects(:file=).with("/t/env2.pp") + parser2.expects(:parse) + @interp.send(:create_parser, :env2) + end + end + + describe "when managing parser instances" do + it "should use the same parser when the parser does not need reparsing" do + @interp.expects(:create_parser).with(:myenv).returns(@parser) + @interp.send(:parser, :myenv).should equal(@parser) + + @parser.expects(:reparse?).returns(false) + @interp.send(:parser, :myenv).should equal(@parser) + end + + it "should fail intelligently if a parser cannot be created and one does not already exist" do + @interp.expects(:create_parser).with(:myenv).raises(ArgumentError) + proc { @interp.send(:parser, :myenv) }.should raise_error(ArgumentError) + end + + it "should use different parsers for different environments" do + # get one for the first env + @interp.expects(:create_parser).with(:first_env).returns(@parser) + @interp.send(:parser, :first_env).should equal(@parser) + + other_parser = mock('otherparser') + @interp.expects(:create_parser).with(:second_env).returns(other_parser) + @interp.send(:parser, :second_env).should equal(other_parser) + end + + describe "when files need reparsing" do + it "should create a new parser" do + oldparser = mock('oldparser') + newparser = mock('newparser') + oldparser.expects(:reparse?).returns(true) + oldparser.expects(:clear) + + @interp.expects(:create_parser).with(:myenv).returns(oldparser) + @interp.send(:parser, :myenv).should equal(oldparser) + @interp.expects(:create_parser).with(:myenv).returns(newparser) + @interp.send(:parser, :myenv).should equal(newparser) + end + + it "should keep the old parser if a new parser cannot be created" do + # Get the first parser in the hash. + @interp.expects(:create_parser).with(:myenv).returns(@parser) + @interp.send(:parser, :myenv).should equal(@parser) + + # Have it indicate something has changed + @parser.expects(:reparse?).returns(true) + + # But fail to create a new parser + @interp.expects(:create_parser).with(:myenv).raises(ArgumentError) + + # And make sure we still get the old valid parser + @interp.send(:parser, :myenv).should equal(@parser) + end + + it "should log syntax errors when using the old parser" do + # Get the first parser in the hash. + @interp.stubs(:create_parser).with(:myenv).returns(@parser) + @interp.send(:parser, :myenv) + + # Have it indicate something has changed + @parser.stubs(:reparse?).returns(true) + + # But fail to create a new parser + @interp.stubs(:create_parser).with(:myenv).raises(ArgumentError) + + Puppet.expects(:err) + + # And make sure we still get the old valid parser + @interp.send(:parser, :myenv) + end + end + end + + describe "when compiling a catalog" do + before do + @node = stub 'node', :environment => :myenv + @compiler = mock 'compile' + end + + it "should create a compile with the node and parser" do + @compiler.expects(:compile).returns(:config) + @interp.expects(:parser).with(:myenv).returns(@parser) + Puppet::Parser::Compiler.expects(:new).with(@node, @parser).returns(@compiler) + @interp.compile(@node) + end + + it "should fail intelligently when no parser can be found" do + @node.stubs(:name).returns("whatever") + @interp.expects(:parser).with(:myenv).returns(nil) + proc { @interp.compile(@node) }.should raise_error(Puppet::ParseError) + end + end + + describe "when returning catalog version" do + it "should ask the appropriate parser for the catalog version" do + node = mock 'node' + node.expects(:environment).returns(:myenv) + parser = mock 'parser' + parser.expects(:version).returns(:myvers) + @interp.expects(:parser).with(:myenv).returns(parser) + @interp.configuration_version(node).should equal(:myvers) + end end end diff --git a/spec/unit/ral/types/exec.rb b/spec/unit/ral/type/exec.rb index 260804227..260804227 100755 --- a/spec/unit/ral/types/exec.rb +++ b/spec/unit/ral/type/exec.rb diff --git a/spec/unit/ral/types/file.rb b/spec/unit/ral/type/file.rb index b213987bb..b213987bb 100755 --- a/spec/unit/ral/types/file.rb +++ b/spec/unit/ral/type/file.rb diff --git a/spec/unit/ral/types/interface.rb b/spec/unit/ral/type/interface.rb index 2e0176152..2e0176152 100755 --- a/spec/unit/ral/types/interface.rb +++ b/spec/unit/ral/type/interface.rb diff --git a/spec/unit/ral/types/mount.rb b/spec/unit/ral/type/mount.rb index 9247601e6..9247601e6 100755 --- a/spec/unit/ral/types/mount.rb +++ b/spec/unit/ral/type/mount.rb diff --git a/spec/unit/ral/types/nagios.rb b/spec/unit/ral/type/nagios.rb index 8aca7d401..8aca7d401 100755 --- a/spec/unit/ral/types/nagios.rb +++ b/spec/unit/ral/type/nagios.rb diff --git a/spec/unit/ral/types/package.rb b/spec/unit/ral/type/package.rb index 5d96dc4ae..5d96dc4ae 100755 --- a/spec/unit/ral/types/package.rb +++ b/spec/unit/ral/type/package.rb diff --git a/spec/unit/ral/types/schedule.rb b/spec/unit/ral/type/schedule.rb index 4e9840c34..4e9840c34 100755 --- a/spec/unit/ral/types/schedule.rb +++ b/spec/unit/ral/type/schedule.rb diff --git a/spec/unit/ral/types/service.rb b/spec/unit/ral/type/service.rb index 981d38a15..0f00992fa 100755 --- a/spec/unit/ral/types/service.rb +++ b/spec/unit/ral/type/service.rb @@ -15,7 +15,7 @@ describe Puppet::Type::Service do end describe Puppet::Type::Service, "when validating attributes" do - [:name, :binary, :hasstatus, :path, :pattern, :start, :restart, :stop, :status, :hasrestart].each do |param| + [:name, :binary, :hasstatus, :path, :pattern, :start, :restart, :stop, :status, :hasrestart, :control].each do |param| it "should have a #{param} parameter" do Puppet::Type::Service.attrtype(param).should == :param end @@ -30,7 +30,7 @@ end describe Puppet::Type::Service, "when validating attribute values" do before do - @provider = stub 'provider', :class => Puppet::Type::Service.defaultprovider, :clear => nil + @provider = stub 'provider', :class => Puppet::Type::Service.defaultprovider, :clear => nil, :controllable? => false Puppet::Type::Service.defaultprovider.stubs(:new).returns(@provider) end @@ -132,16 +132,23 @@ describe Puppet::Type::Service, "when setting default attribute values" do svc[:path].should == ["testing"] end - it "should default to the binary for the pattern if one is provided" do + it "should default 'pattern' to the binary if one is provided" do svc = Puppet::Type::Service.create(:name => "other", :binary => "/some/binary") svc[:pattern].should == "/some/binary" end - it "should default to the name for the pattern if no pattern is provided" do + it "should default 'pattern' to the name if no pattern is provided" do svc = Puppet::Type::Service.create(:name => "other") svc[:pattern].should == "other" end + it "should default 'control' to the upcased service name with periods replaced by underscores if the provider supports the 'controllable' feature" do + provider = stub 'provider', :controllable? => true, :class => Puppet::Type::Service.defaultprovider, :clear => nil + Puppet::Type::Service.defaultprovider.stubs(:new).returns(provider) + svc = Puppet::Type::Service.create(:name => "nfs.client") + svc[:control].should == "NFS_CLIENT_START" + end + after { Puppet::Type::Service.clear } end diff --git a/spec/unit/ral/types/user.rb b/spec/unit/ral/type/user.rb index 4e43a8ceb..4e43a8ceb 100755 --- a/spec/unit/ral/types/user.rb +++ b/spec/unit/ral/type/user.rb diff --git a/test/ral/types/basic.rb b/test/ral/type/basic.rb index 3c5faeee0..3c5faeee0 100755 --- a/test/ral/types/basic.rb +++ b/test/ral/type/basic.rb diff --git a/test/ral/types/cron.rb b/test/ral/type/cron.rb index 73e941894..73e941894 100755 --- a/test/ral/types/cron.rb +++ b/test/ral/type/cron.rb diff --git a/test/ral/types/exec.rb b/test/ral/type/exec.rb index e2a3dd9ed..e2a3dd9ed 100755 --- a/test/ral/types/exec.rb +++ b/test/ral/type/exec.rb diff --git a/test/ral/types/file.rb b/test/ral/type/file.rb index cbbe818ae..cbbe818ae 100755 --- a/test/ral/types/file.rb +++ b/test/ral/type/file.rb diff --git a/test/ral/types/file/target.rb b/test/ral/type/file/target.rb index 035ea905b..035ea905b 100755 --- a/test/ral/types/file/target.rb +++ b/test/ral/type/file/target.rb diff --git a/test/ral/types/filebucket.rb b/test/ral/type/filebucket.rb index f9706663b..f9706663b 100755 --- a/test/ral/types/filebucket.rb +++ b/test/ral/type/filebucket.rb diff --git a/test/ral/types/fileignoresource.rb b/test/ral/type/fileignoresource.rb index ff867c879..ff867c879 100755 --- a/test/ral/types/fileignoresource.rb +++ b/test/ral/type/fileignoresource.rb diff --git a/test/ral/types/filesources.rb b/test/ral/type/filesources.rb index a7bb6fefa..a7bb6fefa 100755 --- a/test/ral/types/filesources.rb +++ b/test/ral/type/filesources.rb diff --git a/test/ral/types/group.rb b/test/ral/type/group.rb index d28c8eea5..d28c8eea5 100755 --- a/test/ral/types/group.rb +++ b/test/ral/type/group.rb diff --git a/test/ral/types/host.rb b/test/ral/type/host.rb index a5d645bd1..a5d645bd1 100755 --- a/test/ral/types/host.rb +++ b/test/ral/type/host.rb diff --git a/test/ral/types/mailalias.rb b/test/ral/type/mailalias.rb index ff1dd562a..ff1dd562a 100755 --- a/test/ral/types/mailalias.rb +++ b/test/ral/type/mailalias.rb diff --git a/test/ral/types/parameter.rb b/test/ral/type/parameter.rb index e1b8e00b3..e1b8e00b3 100755 --- a/test/ral/types/parameter.rb +++ b/test/ral/type/parameter.rb diff --git a/test/ral/types/port.rb b/test/ral/type/port.rb index e28904d55..e28904d55 100755 --- a/test/ral/types/port.rb +++ b/test/ral/type/port.rb diff --git a/test/ral/types/property.rb b/test/ral/type/property.rb index 6a3370caa..6a3370caa 100755 --- a/test/ral/types/property.rb +++ b/test/ral/type/property.rb diff --git a/test/ral/types/resources.rb b/test/ral/type/resources.rb index 0663fe795..0663fe795 100755 --- a/test/ral/types/resources.rb +++ b/test/ral/type/resources.rb diff --git a/test/ral/types/service.rb b/test/ral/type/service.rb index 01533c63e..01533c63e 100755 --- a/test/ral/types/service.rb +++ b/test/ral/type/service.rb diff --git a/test/ral/types/sshkey.rb b/test/ral/type/sshkey.rb index b9aed20e8..b9aed20e8 100755 --- a/test/ral/types/sshkey.rb +++ b/test/ral/type/sshkey.rb diff --git a/test/ral/types/tidy.rb b/test/ral/type/tidy.rb index 60fad6516..60fad6516 100755 --- a/test/ral/types/tidy.rb +++ b/test/ral/type/tidy.rb diff --git a/test/ral/types/user.rb b/test/ral/type/user.rb index b280acfed..b280acfed 100755 --- a/test/ral/types/user.rb +++ b/test/ral/type/user.rb diff --git a/test/ral/types/yumrepo.rb b/test/ral/type/yumrepo.rb index 899a02135..899a02135 100755 --- a/test/ral/types/yumrepo.rb +++ b/test/ral/type/yumrepo.rb diff --git a/test/ral/types/zone.rb b/test/ral/type/zone.rb index eb485b944..eb485b944 100755 --- a/test/ral/types/zone.rb +++ b/test/ral/type/zone.rb |
