summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-11-02 11:10:33 -0700
committerMarkus Roberts <Markus@reality.com>2010-11-10 15:29:13 -0800
commit5f7d0fbb3699cba28d10adac62c69aedfce2df38 (patch)
tree0db3a42023237180b3b295db83773d6e751075e8 /spec
parentba4d22bce3fbb7af3bef50088623605350a9891e (diff)
downloadpuppet-5f7d0fbb3699cba28d10adac62c69aedfce2df38.tar.gz
puppet-5f7d0fbb3699cba28d10adac62c69aedfce2df38.tar.xz
puppet-5f7d0fbb3699cba28d10adac62c69aedfce2df38.zip
Fix for #2568 -- Add a dbconnections option to set AR pool size
The dbconnection option, if set to a positive integer, will be passed to active record as the connection pool size (pool).
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/rails_spec.rb74
1 files changed, 74 insertions, 0 deletions
diff --git a/spec/unit/rails_spec.rb b/spec/unit/rails_spec.rb
index 8dfc09b4a..d30e52b8a 100755
--- a/spec/unit/rails_spec.rb
+++ b/spec/unit/rails_spec.rb
@@ -103,6 +103,7 @@ describe Puppet::Rails, "when initializing a mysql connection" do
Puppet.settings.stubs(:value).with(:dbport).returns("")
Puppet.settings.stubs(:value).with(:dbuser).returns("testuser")
Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword")
+ Puppet.settings.stubs(:value).with(:dbconnections).returns((pool_size = 45).to_s)
Puppet.settings.stubs(:value).with(:dbname).returns("testname")
Puppet.settings.stubs(:value).with(:dbsocket).returns("")
@@ -112,6 +113,7 @@ describe Puppet::Rails, "when initializing a mysql connection" do
:host => "testserver",
:username => "testuser",
:password => "testpassword",
+ :pool => pool_size,
:database => "testname",
:reconnect => true
}
@@ -124,6 +126,7 @@ describe Puppet::Rails, "when initializing a mysql connection" do
Puppet.settings.stubs(:value).with(:dbport).returns("9999")
Puppet.settings.stubs(:value).with(:dbuser).returns("testuser")
Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword")
+ Puppet.settings.stubs(:value).with(:dbconnections).returns((pool_size = 12).to_s)
Puppet.settings.stubs(:value).with(:dbname).returns("testname")
Puppet.settings.stubs(:value).with(:dbsocket).returns("testsocket")
@@ -134,6 +137,7 @@ describe Puppet::Rails, "when initializing a mysql connection" do
:port => "9999",
:username => "testuser",
:password => "testpassword",
+ :pool => pool_size,
:database => "testname",
:socket => "testsocket",
:reconnect => true
@@ -147,6 +151,7 @@ describe Puppet::Rails, "when initializing a mysql connection" do
Puppet.settings.stubs(:value).with(:dbport).returns("9999")
Puppet.settings.stubs(:value).with(:dbuser).returns("testuser")
Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword")
+ Puppet.settings.stubs(:value).with(:dbconnections).returns((pool_size = 23).to_s)
Puppet.settings.stubs(:value).with(:dbname).returns("testname")
Puppet.settings.stubs(:value).with(:dbsocket).returns("testsocket")
@@ -157,11 +162,32 @@ describe Puppet::Rails, "when initializing a mysql connection" do
:port => "9999",
:username => "testuser",
:password => "testpassword",
+ :pool => pool_size,
:database => "testname",
:socket => "testsocket",
:reconnect => true
}
end
+
+ it "should not provide the pool if dbconnections is 0, '0', or ''" do
+ Puppet.settings.stubs(:value).with(:dbadapter).returns("mysql")
+ Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel")
+ Puppet.settings.stubs(:value).with(:dbserver).returns("testserver")
+ Puppet.settings.stubs(:value).with(:dbport).returns("9999")
+ Puppet.settings.stubs(:value).with(:dbuser).returns("testuser")
+ Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword")
+ Puppet.settings.stubs(:value).with(:dbname).returns("testname")
+ Puppet.settings.stubs(:value).with(:dbsocket).returns("testsocket")
+
+ Puppet.settings.stubs(:value).with(:dbconnections).returns(0)
+ Puppet::Rails.database_arguments.should_not be_include :pool
+
+ Puppet.settings.stubs(:value).with(:dbconnections).returns('0')
+ Puppet::Rails.database_arguments.should_not be_include :pool
+
+ Puppet.settings.stubs(:value).with(:dbconnections).returns('')
+ Puppet::Rails.database_arguments.should_not be_include :pool
+ end
end
describe Puppet::Rails, "when initializing a postgresql connection" do
@@ -174,6 +200,7 @@ describe Puppet::Rails, "when initializing a postgresql connection" do
Puppet.settings.stubs(:value).with(:dbport).returns("9999")
Puppet.settings.stubs(:value).with(:dbuser).returns("testuser")
Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword")
+ Puppet.settings.stubs(:value).with(:dbconnections).returns((pool_size = 200).to_s)
Puppet.settings.stubs(:value).with(:dbname).returns("testname")
Puppet.settings.stubs(:value).with(:dbsocket).returns("")
@@ -184,6 +211,7 @@ describe Puppet::Rails, "when initializing a postgresql connection" do
:port => "9999",
:username => "testuser",
:password => "testpassword",
+ :pool => pool_size,
:database => "testname",
:reconnect => true
}
@@ -196,6 +224,7 @@ describe Puppet::Rails, "when initializing a postgresql connection" do
Puppet.settings.stubs(:value).with(:dbport).returns("9999")
Puppet.settings.stubs(:value).with(:dbuser).returns("testuser")
Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword")
+ Puppet.settings.stubs(:value).with(:dbconnections).returns((pool_size = 122).to_s)
Puppet.settings.stubs(:value).with(:dbname).returns("testname")
Puppet.settings.stubs(:value).with(:dbsocket).returns("testsocket")
@@ -206,11 +235,32 @@ describe Puppet::Rails, "when initializing a postgresql connection" do
:port => "9999",
:username => "testuser",
:password => "testpassword",
+ :pool => pool_size,
:database => "testname",
:socket => "testsocket",
:reconnect => true
}
end
+
+ it "should not provide the pool if dbconnections is 0, '0', or ''" do
+ Puppet.settings.stubs(:value).with(:dbadapter).returns("mysql")
+ Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel")
+ Puppet.settings.stubs(:value).with(:dbserver).returns("testserver")
+ Puppet.settings.stubs(:value).with(:dbport).returns("9999")
+ Puppet.settings.stubs(:value).with(:dbuser).returns("testuser")
+ Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword")
+ Puppet.settings.stubs(:value).with(:dbname).returns("testname")
+ Puppet.settings.stubs(:value).with(:dbsocket).returns("testsocket")
+
+ Puppet.settings.stubs(:value).with(:dbconnections).returns(0)
+ Puppet::Rails.database_arguments.should_not be_include :pool
+
+ Puppet.settings.stubs(:value).with(:dbconnections).returns('0')
+ Puppet::Rails.database_arguments.should_not be_include :pool
+
+ Puppet.settings.stubs(:value).with(:dbconnections).returns('')
+ Puppet::Rails.database_arguments.should_not be_include :pool
+ end
end
describe Puppet::Rails, "when initializing an Oracle connection" do
@@ -221,6 +271,7 @@ describe Puppet::Rails, "when initializing an Oracle connection" do
Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel")
Puppet.settings.stubs(:value).with(:dbuser).returns("testuser")
Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword")
+ Puppet.settings.stubs(:value).with(:dbconnections).returns((pool_size = 123).to_s)
Puppet.settings.stubs(:value).with(:dbname).returns("testname")
Puppet::Rails.database_arguments.should == {
@@ -228,6 +279,7 @@ describe Puppet::Rails, "when initializing an Oracle connection" do
:log_level => "testlevel",
:username => "testuser",
:password => "testpassword",
+ :pool => pool_size,
:database => "testname"
}
end
@@ -237,6 +289,7 @@ describe Puppet::Rails, "when initializing an Oracle connection" do
Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel")
Puppet.settings.stubs(:value).with(:dbuser).returns("testuser")
Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword")
+ Puppet.settings.stubs(:value).with(:dbconnections).returns((pool_size = 124).to_s)
Puppet.settings.stubs(:value).with(:dbname).returns("testname")
Puppet::Rails.database_arguments.should == {
@@ -244,7 +297,28 @@ describe Puppet::Rails, "when initializing an Oracle connection" do
:log_level => "testlevel",
:username => "testuser",
:password => "testpassword",
+ :pool => pool_size,
:database => "testname"
}
end
+
+ it "should not provide the pool if dbconnections is 0, '0', or ''" do
+ Puppet.settings.stubs(:value).with(:dbadapter).returns("mysql")
+ Puppet.settings.stubs(:value).with(:rails_loglevel).returns("testlevel")
+ Puppet.settings.stubs(:value).with(:dbserver).returns("testserver")
+ Puppet.settings.stubs(:value).with(:dbport).returns("9999")
+ Puppet.settings.stubs(:value).with(:dbuser).returns("testuser")
+ Puppet.settings.stubs(:value).with(:dbpassword).returns("testpassword")
+ Puppet.settings.stubs(:value).with(:dbname).returns("testname")
+ Puppet.settings.stubs(:value).with(:dbsocket).returns("testsocket")
+
+ Puppet.settings.stubs(:value).with(:dbconnections).returns(0)
+ Puppet::Rails.database_arguments.should_not be_include :pool
+
+ Puppet.settings.stubs(:value).with(:dbconnections).returns('0')
+ Puppet::Rails.database_arguments.should_not be_include :pool
+
+ Puppet.settings.stubs(:value).with(:dbconnections).returns('')
+ Puppet::Rails.database_arguments.should_not be_include :pool
+ end
end