[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35
test branch
puppet-dev at googlegroups.com
Wed Jul 14 10:33:15 UTC 2010
The following commit has been merged in the upstream branch:
commit c79b2282ab0af181d354cfbae7d0b8da964cc03c
Author: Jesse Wolfe <jes5199 at gmail.com>
Date: Tue Apr 20 16:23:03 2010 -0700
feature #2276 Single Executable: "puppet kick"
Add "puppet kick" as the new invocation of "puppetrun"
Signed-off-by: Jesse Wolfe <jes5199 at gmail.com>
diff --git a/lib/puppet/application/run.rb b/lib/puppet/application/kick.rb
similarity index 99%
rename from lib/puppet/application/run.rb
rename to lib/puppet/application/kick.rb
index 395ba98..7b4993b 100644
--- a/lib/puppet/application/run.rb
+++ b/lib/puppet/application/kick.rb
@@ -4,7 +4,7 @@ require 'puppet/application'
Puppet.warning "RubyGems not installed" unless Puppet.features.rubygems?
Puppet.warning "Failed to load ruby LDAP library. LDAP functionality will not be available" unless Puppet.features.ldap?
-Puppet::Application.new(:run) do
+Puppet::Application.new(:kick) do
should_not_parse_config
diff --git a/sbin/puppetrun b/sbin/puppetrun
index 6dc8fd2..641c1bb 100755
--- a/sbin/puppetrun
+++ b/sbin/puppetrun
@@ -125,6 +125,6 @@
# Copyright (c) 2005 Reductive Labs, LLC
# Licensed under the GNU Public License
-require 'puppet/application/run'
-Puppet::Application[:run].run
+require 'puppet/application/kick'
+Puppet::Application[:kick].run
diff --git a/spec/unit/application/run.rb b/spec/unit/application/kick.rb
similarity index 56%
rename from spec/unit/application/run.rb
rename to spec/unit/application/kick.rb
index bb76c5b..b617537 100755
--- a/spec/unit/application/run.rb
+++ b/spec/unit/application/kick.rb
@@ -3,71 +3,72 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require 'puppet/util/ldap/connection'
-require 'puppet/application/run'
+require 'puppet/application/kick'
-describe "run" do
+describe Puppet::Application[:kick] do
before :each do
Puppet::Util::Ldap::Connection.stubs(:new).returns(stub_everything)
- @run = Puppet::Application[:run]
+ @kick = Puppet::Application[:kick]
Puppet::Util::Log.stubs(:newdestination)
Puppet::Util::Log.stubs(:level=)
end
it "should ask Puppet::Application to not parse Puppet configuration file" do
- @run.should_parse_config?.should be_false
+ p @kick.object_id
+ @kick.should_parse_config?.should be_false
end
it "should declare a main command" do
- @run.should respond_to(:main)
+ @kick.should respond_to(:main)
end
it "should declare a test command" do
- @run.should respond_to(:test)
+ @kick.should respond_to(:test)
end
it "should declare a preinit block" do
- @run.should respond_to(:run_preinit)
+ @kick.should respond_to(:run_preinit)
end
describe "during preinit" do
before :each do
- @run.stubs(:trap)
+ @kick.stubs(:trap)
end
it "should catch INT and TERM" do
- @run.stubs(:trap).with { |arg,block| arg == :INT or arg == :TERM }
+ @kick.stubs(:trap).with { |arg,block| arg == :INT or arg == :TERM }
- @run.run_preinit
+ @kick.run_preinit
end
it "should set parallel option to 1" do
- @run.run_preinit
+ @kick.run_preinit
- @run.options[:parallel].should == 1
+ @kick.options[:parallel].should == 1
end
it "should set verbose by default" do
- @run.run_preinit
+ @kick.run_preinit
- @run.options[:verbose].should be_true
+ @kick.options[:verbose].should be_true
end
it "should set fqdn by default" do
- @run.run_preinit
+ @kick.run_preinit
- @run.options[:fqdn].should be_true
+ @kick.options[:fqdn].should be_true
end
it "should set ignoreschedules to 'false'" do
- @run.run_preinit
+ @kick.run_preinit
- @run.options[:ignoreschedules].should be_false
+ @kick.options[:ignoreschedules].should be_false
end
it "should set foreground to 'false'" do
- @run.run_preinit
+ @kick.run_preinit
- @run.options[:foreground].should be_false
+ @kick.options[:foreground].should be_false
end
end
@@ -75,68 +76,68 @@ describe "run" do
[:all, :foreground, :debug, :ping, :test].each do |option|
it "should declare handle_#{option} method" do
- @run.should respond_to("handle_#{option}".to_sym)
+ @kick.should respond_to("handle_#{option}".to_sym)
end
it "should store argument value when calling handle_#{option}" do
- @run.options.expects(:[]=).with(option, 'arg')
- @run.send("handle_#{option}".to_sym, 'arg')
+ @kick.options.expects(:[]=).with(option, 'arg')
+ @kick.send("handle_#{option}".to_sym, 'arg')
end
end
it "should add to the host list with the host option" do
- @run.handle_host('host')
+ @kick.handle_host('host')
- @run.hosts.should == ['host']
+ @kick.hosts.should == ['host']
end
it "should add to the tag list with the tag option" do
- @run.handle_tag('tag')
+ @kick.handle_tag('tag')
- @run.tags.should == ['tag']
+ @kick.tags.should == ['tag']
end
it "should add to the class list with the class option" do
- @run.handle_class('class')
+ @kick.handle_class('class')
- @run.classes.should == ['class']
+ @kick.classes.should == ['class']
end
end
describe "during setup" do
before :each do
- @run.classes = []
- @run.tags = []
- @run.hosts = []
+ @kick.classes = []
+ @kick.tags = []
+ @kick.hosts = []
Puppet::Log.stubs(:level=)
- @run.stubs(:trap)
- @run.stubs(:puts)
+ @kick.stubs(:trap)
+ @kick.stubs(:puts)
Puppet.stubs(:parse_config)
- @run.options.stubs(:[]).with(any_parameters)
+ @kick.options.stubs(:[]).with(any_parameters)
end
it "should set log level to debug if --debug was passed" do
- @run.options.stubs(:[]).with(:debug).returns(true)
+ @kick.options.stubs(:[]).with(:debug).returns(true)
Puppet::Log.expects(:level=).with(:debug)
- @run.run_setup
+ @kick.run_setup
end
it "should set log level to info if --verbose was passed" do
- @run.options.stubs(:[]).with(:verbose).returns(true)
+ @kick.options.stubs(:[]).with(:verbose).returns(true)
Puppet::Log.expects(:level=).with(:info)
- @run.run_setup
+ @kick.run_setup
end
it "should Parse puppet config" do
Puppet.expects(:parse_config)
- @run.run_setup
+ @kick.run_setup
end
describe "when using the ldap node terminus" do
@@ -145,103 +146,103 @@ describe "run" do
end
it "should pass the fqdn option to search" do
- @run.options.stubs(:[]).with(:fqdn).returns(:something)
- @run.options.stubs(:[]).with(:all).returns(true)
- @run.stubs(:puts)
+ @kick.options.stubs(:[]).with(:fqdn).returns(:something)
+ @kick.options.stubs(:[]).with(:all).returns(true)
+ @kick.stubs(:puts)
Puppet::Node.expects(:search).with("whatever",:fqdn => :something).returns([])
- @run.run_setup
+ @kick.run_setup
end
it "should search for all nodes if --all" do
- @run.options.stubs(:[]).with(:all).returns(true)
- @run.stubs(:puts)
+ @kick.options.stubs(:[]).with(:all).returns(true)
+ @kick.stubs(:puts)
Puppet::Node.expects(:search).with("whatever",:fqdn => nil).returns([])
- @run.run_setup
+ @kick.run_setup
end
it "should search for nodes including given classes" do
- @run.options.stubs(:[]).with(:all).returns(false)
- @run.stubs(:puts)
- @run.classes = ['class']
+ @kick.options.stubs(:[]).with(:all).returns(false)
+ @kick.stubs(:puts)
+ @kick.classes = ['class']
Puppet::Node.expects(:search).with("whatever", :class => "class", :fqdn => nil).returns([])
- @run.run_setup
+ @kick.run_setup
end
end
describe "when using regular nodes" do
it "should fail if some classes have been specified" do
$stderr.stubs(:puts)
- @run.classes = ['class']
+ @kick.classes = ['class']
- @run.expects(:exit).with(24)
+ @kick.expects(:exit).with(24)
- @run.run_setup
+ @kick.run_setup
end
end
end
describe "when running" do
before :each do
- @run.stubs(:puts)
+ @kick.stubs(:puts)
end
it "should dispatch to test if --test is used" do
- @run.options.stubs(:[]).with(:test).returns(true)
+ @kick.options.stubs(:[]).with(:test).returns(true)
- @run.get_command.should == :test
+ @kick.get_command.should == :test
end
it "should dispatch to main if --test is not used" do
- @run.options.stubs(:[]).with(:test).returns(false)
+ @kick.options.stubs(:[]).with(:test).returns(false)
- @run.get_command.should == :main
+ @kick.get_command.should == :main
end
describe "the test command" do
it "should exit with exit code 0 " do
- @run.expects(:exit).with(0)
+ @kick.expects(:exit).with(0)
- @run.test
+ @kick.test
end
end
describe "the main command" do
before :each do
- @run.options.stubs(:[]).with(:parallel).returns(1)
- @run.options.stubs(:[]).with(:ping).returns(false)
- @run.options.stubs(:[]).with(:ignoreschedules).returns(false)
- @run.options.stubs(:[]).with(:foreground).returns(false)
- @run.stubs(:print)
- @run.stubs(:exit)
+ @kick.options.stubs(:[]).with(:parallel).returns(1)
+ @kick.options.stubs(:[]).with(:ping).returns(false)
+ @kick.options.stubs(:[]).with(:ignoreschedules).returns(false)
+ @kick.options.stubs(:[]).with(:foreground).returns(false)
+ @kick.stubs(:print)
+ @kick.stubs(:exit)
$stderr.stubs(:puts)
end
it "should create as much childs as --parallel" do
- @run.options.stubs(:[]).with(:parallel).returns(3)
- @run.hosts = ['host1', 'host2', 'host3']
- @run.stubs(:exit).raises(SystemExit)
+ @kick.options.stubs(:[]).with(:parallel).returns(3)
+ @kick.hosts = ['host1', 'host2', 'host3']
+ @kick.stubs(:exit).raises(SystemExit)
Process.stubs(:wait).returns(1).then.returns(2).then.returns(3).then.raises(Errno::ECHILD)
- @run.expects(:fork).times(3).returns(1).then.returns(2).then.returns(3)
+ @kick.expects(:fork).times(3).returns(1).then.returns(2).then.returns(3)
- lambda { @run.main }.should raise_error
+ lambda { @kick.main }.should raise_error
end
it "should delegate to run_for_host per host" do
- @run.hosts = ['host1', 'host2']
- @run.stubs(:exit).raises(SystemExit)
- @run.stubs(:fork).returns(1).yields
+ @kick.hosts = ['host1', 'host2']
+ @kick.stubs(:exit).raises(SystemExit)
+ @kick.stubs(:fork).returns(1).yields
Process.stubs(:wait).returns(1).then.raises(Errno::ECHILD)
- @run.expects(:run_for_host).times(2)
+ @kick.expects(:run_for_host).times(2)
- lambda { @run.main }.should raise_error
+ lambda { @kick.main }.should raise_error
end
describe "during call of run_for_host" do
@@ -260,31 +261,31 @@ describe "run" do
it "should call run on a Puppet::Run for the given host" do
@agent_run.expects(:save).with('https://host:8139/production/run/host').returns(@agent_run)
- @run.run_for_host('host')
+ @kick.run_for_host('host')
end
it "should exit the child with 0 on success" do
@agent_run.stubs(:status).returns("success")
- @run.expects(:exit).with(0)
+ @kick.expects(:exit).with(0)
- @run.run_for_host('host')
+ @kick.run_for_host('host')
end
it "should exit the child with 3 on running" do
@agent_run.stubs(:status).returns("running")
- @run.expects(:exit).with(3)
+ @kick.expects(:exit).with(3)
- @run.run_for_host('host')
+ @kick.run_for_host('host')
end
it "should exit the child with 12 on unknown answer" do
@agent_run.stubs(:status).returns("whatever")
- @run.expects(:exit).with(12)
+ @kick.expects(:exit).with(12)
- @run.run_for_host('host')
+ @kick.run_for_host('host')
end
end
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list