summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-01-23 18:54:44 -0600
committerLuke Kanies <luke@madstop.com>2009-02-06 18:08:42 -0600
commit337057ad666e3ef3a5b2d8f7baccbc9370add5b4 (patch)
treee4bfc9f38cf11c35dc540d8bb49d3b1b4df32b2e /spec/unit
parentd53ad3181d3f5953b00512d7793945d238d1879f (diff)
downloadpuppet-337057ad666e3ef3a5b2d8f7baccbc9370add5b4.tar.gz
puppet-337057ad666e3ef3a5b2d8f7baccbc9370add5b4.tar.xz
puppet-337057ad666e3ef3a5b2d8f7baccbc9370add5b4.zip
Removing obsolete code and tests for the agent.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/agent.rb163
1 files changed, 0 insertions, 163 deletions
diff --git a/spec/unit/agent.rb b/spec/unit/agent.rb
index 0d6ed952e..c4f5793d2 100755
--- a/spec/unit/agent.rb
+++ b/spec/unit/agent.rb
@@ -258,166 +258,3 @@ describe Puppet::Agent, "when preparing for a run" do
@agent.prepare
end
end
-
-describe Puppet::Agent, " when using the cached catalog" do
- before do
- Puppet.settings.stubs(:use).returns(true)
- @agent = Puppet::Agent.new
- @facts = {"one" => "two", "three" => "four"}
- end
-
- it "should return do nothing and true if there is already an in-memory catalog" do
- @agent.catalog = :whatever
- Puppet::Agent.publicize_methods :use_cached_config do
- @agent.use_cached_config.should be_true
- end
- end
-
- it "should return do nothing and false if it has been told there is a failure and :nocacheonfailure is enabled" do
- Puppet.settings.expects(:value).with(:usecacheonfailure).returns(false)
- Puppet::Agent.publicize_methods :use_cached_config do
- @agent.use_cached_config(true).should be_false
- end
- end
-
- it "should return false if no cached catalog can be found" do
- @agent.expects(:retrievecache).returns(nil)
- Puppet::Agent.publicize_methods :use_cached_config do
- @agent.use_cached_config().should be_false
- end
- end
-
- it "should return false if the cached catalog cannot be instantiated" do
- YAML.expects(:load).raises(ArgumentError)
- @agent.expects(:retrievecache).returns("whatever")
- Puppet::Agent.publicize_methods :use_cached_config do
- @agent.use_cached_config().should be_false
- end
- end
-
- it "should warn if the cached catalog cannot be instantiated" do
- YAML.stubs(:load).raises(ArgumentError)
- @agent.stubs(:retrievecache).returns("whatever")
- Puppet.expects(:warning).with { |m| m.include?("Could not load cache") }
- Puppet::Agent.publicize_methods :use_cached_config do
- @agent.use_cached_config().should be_false
- end
- end
-
- it "should clear the client if the cached catalog cannot be instantiated" do
- YAML.stubs(:load).raises(ArgumentError)
- @agent.stubs(:retrievecache).returns("whatever")
- @agent.expects(:clear)
- Puppet::Agent.publicize_methods :use_cached_config do
- @agent.use_cached_config().should be_false
- end
- end
-
- it "should return true if the cached catalog can be instantiated" do
- config = mock 'config'
- YAML.stubs(:load).returns(config)
-
- ral_config = mock 'ral config'
- ral_config.stubs(:from_cache=)
- ral_config.stubs(:host_config=)
- config.expects(:to_catalog).returns(ral_config)
-
- @agent.stubs(:retrievecache).returns("whatever")
- Puppet::Agent.publicize_methods :use_cached_config do
- @agent.use_cached_config().should be_true
- end
- end
-
- it "should set the catalog instance variable if the cached catalog can be instantiated" do
- config = mock 'config'
- YAML.stubs(:load).returns(config)
-
- ral_config = mock 'ral config'
- ral_config.stubs(:from_cache=)
- ral_config.stubs(:host_config=)
- config.expects(:to_catalog).returns(ral_config)
-
- @agent.stubs(:retrievecache).returns("whatever")
- Puppet::Agent.publicize_methods :use_cached_config do
- @agent.use_cached_config()
- end
-
- @agent.catalog.should equal(ral_config)
- end
-
- it "should mark the catalog as a host_config if valid" do
- config = mock 'config'
- YAML.stubs(:load).returns(config)
-
- ral_config = mock 'ral config'
- ral_config.stubs(:from_cache=)
- ral_config.expects(:host_config=).with(true)
- config.expects(:to_catalog).returns(ral_config)
-
- @agent.stubs(:retrievecache).returns("whatever")
- Puppet::Agent.publicize_methods :use_cached_config do
- @agent.use_cached_config()
- end
-
- @agent.catalog.should equal(ral_config)
- end
-
- it "should mark the catalog as from the cache if valid" do
- config = mock 'config'
- YAML.stubs(:load).returns(config)
-
- ral_config = mock 'ral config'
- ral_config.expects(:from_cache=).with(true)
- ral_config.stubs(:host_config=)
- config.expects(:to_catalog).returns(ral_config)
-
- @agent.stubs(:retrievecache).returns("whatever")
- Puppet::Agent.publicize_methods :use_cached_config do
- @agent.use_cached_config()
- end
-
- @agent.catalog.should equal(ral_config)
- end
-
- describe "when calling splay" do
- it "should do nothing if splay is not enabled" do
- Puppet.stubs(:[]).with(:splay).returns(false)
- @agent.expects(:rand).never
- @agent.send(:splay)
- end
-
- describe "when splay is enabled" do
- before do
- Puppet.stubs(:[]).with(:splay).returns(true)
- Puppet.stubs(:[]).with(:splaylimit).returns(42)
- end
-
- it "should sleep for a random time plus 1" do
- @agent.expects(:rand).with(43).returns(43)
- @agent.expects(:sleep).with(43)
- @agent.send(:splay)
- end
-
- it "should inform that it is splayed" do
- @agent.stubs(:rand).with(43).returns(43)
- @agent.stubs(:sleep).with(43)
- Puppet.expects(:info)
- @agent.send(:splay)
- end
-
- it "should set splay = true" do
- @agent.stubs(:rand).returns(43)
- @agent.stubs(:sleep)
- @agent.send(:splay)
- @agent.send(:splayed?).should == true
- end
-
- it "should do nothing if already splayed" do
- @agent.stubs(:rand).returns(43).at_most_once
- @agent.stubs(:sleep).at_most_once
- @agent.send(:splay)
- @agent.send(:splay)
- end
- end
- end
-end