[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5
Nick Lewis
nick at puppetlabs.com
Tue May 10 08:01:12 UTC 2011
The following commit has been merged in the experimental branch:
commit b0acb02b568598ec8dba41aa856f74658b2033dd
Author: Nick Lewis <nick at puppetlabs.com>
Date: Thu Nov 11 13:47:43 2010 -0800
(#3747) Add specs for upstart provider
Paired-With: Matt Robinson
diff --git a/lib/puppet/provider/service/upstart.rb b/lib/puppet/provider/service/upstart.rb
index 915de4c..54971ee 100755
--- a/lib/puppet/provider/service/upstart.rb
+++ b/lib/puppet/provider/service/upstart.rb
@@ -6,9 +6,6 @@ Puppet::Type.type(:service).provide :upstart, :parent => :init do
See:
* http://upstart.ubuntu.com/
"
- # Note: I did not set default for Ubuntu
- # defaultfor :operatingsystem => :ubuntu
-
# confine to :ubuntu for now because I haven't tested on other platforms
confine :operatingsystem => :ubuntu #[:ubuntu, :fedora, :debian]
@@ -37,7 +34,7 @@ Puppet::Type.type(:service).provide :upstart, :parent => :init do
else
line.split.first
end
- instances << new(:name => name) #, :path => "/etc/init/#{name}.conf")
+ instances << new(:name => name)
}
}
instances
diff --git a/spec/unit/provider/service/upstart.rb b/spec/unit/provider/service/upstart.rb
new file mode 100644
index 0000000..439fd2c
--- /dev/null
+++ b/spec/unit/provider/service/upstart.rb
@@ -0,0 +1,50 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+provider_class = Puppet::Type.type(:service).provider(:upstart)
+
+describe provider_class do
+ describe "#instances" do
+ it "should be able to find all instances" do
+ processes = ["rc stop/waiting", "ssh start/running, process 712"]
+ provider_class.stubs(:execpipe).yields(processes)
+ provider_class.instances.map {|provider| provider.name}.should =~ ["rc","ssh"]
+ end
+
+ it "should attach the interface name for network interfaces" do
+ processes = ["network-interface (eth0)"]
+ provider_class.stubs(:execpipe).yields(processes)
+ provider_class.instances.first.name.should == "network-interface INTERFACE=eth0"
+ end
+ end
+
+ describe "#status" do
+ it "should allow the user to override the status command" do
+ resource = Puppet::Type.type(:service).new(:name => "foo", :provider => :upstart, :status => "/bin/foo")
+ provider = provider_class.new(resource)
+
+ Process::Status.any_instance.stubs(:exitstatus).returns(0)
+ provider.expects(:ucommand)
+ provider.status.should == :running
+ end
+
+ it "should use the default status command if none is specified" do
+ resource = Puppet::Type.type(:service).new(:name => "foo", :provider => :upstart)
+ provider = provider_class.new(resource)
+
+ provider.expects(:status_exec).with(["foo"]).returns("foo start/running, process 1000")
+ Process::Status.any_instance.stubs(:exitstatus).returns(0)
+ provider.status.should == :running
+ end
+
+ it "should properly handle services with 'start' in their name" do
+ resource = Puppet::Type.type(:service).new(:name => "foostartbar", :provider => :upstart)
+ provider = provider_class.new(resource)
+
+ provider.expects(:status_exec).with(["foostartbar"]).returns("foostartbar stop/waiting")
+ Process::Status.any_instance.stubs(:exitstatus).returns(0)
+ provider.status.should == :stopped
+ end
+ end
+end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list