diff options
| author | Andrew Shafer <andrew@reductivelabs.com> | 2008-09-19 17:00:03 -0600 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2008-09-21 22:15:00 +1000 |
| commit | c16a5aee245a9e34e6934debee8e66630aef0fda (patch) | |
| tree | 8a736d02ecf477a08ed92339f02752832f8ab5f6 /spec | |
| parent | 27f0c7d6e7bf3400ccecc6512d6a5d477cb9bea9 (diff) | |
| download | puppet-c16a5aee245a9e34e6934debee8e66630aef0fda.tar.gz puppet-c16a5aee245a9e34e6934debee8e66630aef0fda.tar.xz puppet-c16a5aee245a9e34e6934debee8e66630aef0fda.zip | |
Only apply splay the first run
Issue 1491
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/network/client/master.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/unit/network/client/master.rb b/spec/unit/network/client/master.rb index 754fd0583..f55ba316c 100755 --- a/spec/unit/network/client/master.rb +++ b/spec/unit/network/client/master.rb @@ -397,4 +397,46 @@ describe Puppet::Network::Client::Master, " when using the cached catalog" do @client.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) + @client.expects(:rand).never + @client.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" do + @client.expects(:rand).with(42).returns(42) + @client.expects(:sleep).with(42) + @client.send(:splay) + end + + it "should inform that it is splayed" do + @client.stubs(:rand).with(42).returns(42) + @client.stubs(:sleep).with(42) + Puppet.expects(:info) + @client.send(:splay) + end + + it "should set splay = true" do + @client.stubs(:rand).with(42).returns(42) + @client.stubs(:sleep).with(42) + @client.send(:splay) + @client.send(:splayed?).should == true + end + + it "should do nothing if already splayed" do + @client.stubs(:rand).with(42).returns(42).at_most_once + @client.stubs(:sleep).with(42).at_most_once + @client.send(:splay) + @client.send(:splay) + end + end + end end |
