Added puppetlabs-firewall (required by puppetlabs-postgresql), updated the other modules.
This commit is contained in:
parent
5f4b7a3b72
commit
dee66abcdd
137 changed files with 11118 additions and 419 deletions
|
@ -7,6 +7,7 @@ describe 'postgresql::globals', :type => :class do
|
|||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
:lsbdistid => 'Debian',
|
||||
:lsbdistcodename => 'squeeze',
|
||||
}
|
||||
end
|
||||
|
||||
|
|
31
modules/postgresql/spec/unit/classes/lib/perl_spec.rb
Normal file
31
modules/postgresql/spec/unit/classes/lib/perl_spec.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'postgresql::lib::perl', :type => :class do
|
||||
|
||||
describe 'on a redhat based os' do
|
||||
let :facts do {
|
||||
:osfamily => 'RedHat',
|
||||
:operatingsystem => 'RedHat',
|
||||
:operatingsystemrelease => '6.4',
|
||||
}
|
||||
end
|
||||
it { should contain_package('perl-DBD-Pg').with(
|
||||
:name => 'perl-DBD-Pg',
|
||||
:ensure => 'present'
|
||||
)}
|
||||
end
|
||||
|
||||
describe 'on a debian based os' do
|
||||
let :facts do {
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
}
|
||||
end
|
||||
it { should contain_package('perl-DBD-Pg').with(
|
||||
:name => 'libdbd-pg-perl',
|
||||
:ensure => 'present'
|
||||
)}
|
||||
end
|
||||
|
||||
end
|
|
@ -7,6 +7,7 @@ describe 'postgresql::repo', :type => :class do
|
|||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
:lsbdistid => 'Debian',
|
||||
:lsbdistcodename => 'squeeze',
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ describe 'postgresql::server::contrib', :type => :class do
|
|||
:operatingsystemrelease => '6.0',
|
||||
:kernel => 'Linux',
|
||||
:concat_basedir => tmpfilename('contrib'),
|
||||
:id => 'root',
|
||||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@ describe 'postgresql::server::initdb', :type => :class do
|
|||
:operatingsystem => 'CentOS',
|
||||
:operatingsystemrelease => '6.0',
|
||||
:concat_basedir => tmpfilename('server'),
|
||||
:kernel => 'Linux',
|
||||
:id => 'root',
|
||||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
}
|
||||
end
|
||||
it { should contain_file('/var/lib/pgsql/data').with_ensure('directory') }
|
||||
|
@ -20,7 +23,11 @@ describe 'postgresql::server::initdb', :type => :class do
|
|||
{
|
||||
:osfamily => 'RedHat',
|
||||
:operatingsystem => 'Amazon',
|
||||
:operatingsystemrelease => '1.0',
|
||||
:concat_basedir => tmpfilename('server'),
|
||||
:kernel => 'Linux',
|
||||
:id => 'root',
|
||||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
}
|
||||
end
|
||||
it { should contain_file('/var/lib/pgsql9/data').with_ensure('directory') }
|
||||
|
|
|
@ -8,6 +8,8 @@ describe 'postgresql::server::plperl', :type => :class do
|
|||
:operatingsystemrelease => '6.0',
|
||||
:kernel => 'Linux',
|
||||
:concat_basedir => tmpfilename('plperl'),
|
||||
:id => 'root',
|
||||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
}
|
||||
end
|
||||
|
||||
|
|
44
modules/postgresql/spec/unit/classes/server/postgis_spec.rb
Normal file
44
modules/postgresql/spec/unit/classes/server/postgis_spec.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'postgresql::server::postgis', :type => :class do
|
||||
let :pre_condition do
|
||||
"class { 'postgresql::server': }"
|
||||
end
|
||||
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
:kernel => 'Linux',
|
||||
:concat_basedir => tmpfilename('postgis'),
|
||||
:id => 'root',
|
||||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
}
|
||||
end
|
||||
|
||||
describe 'with parameters' do
|
||||
let(:params) do
|
||||
{
|
||||
:package_name => 'mypackage',
|
||||
:package_ensure => 'absent',
|
||||
}
|
||||
end
|
||||
|
||||
it 'should create package with correct params' do
|
||||
should contain_package('postgresql-postgis').with({
|
||||
:ensure => 'absent',
|
||||
:name => 'mypackage',
|
||||
:tag => 'postgresql',
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with no parameters' do
|
||||
it 'should create package with postgresql tag' do
|
||||
should contain_package('postgresql-postgis').with({
|
||||
:tag => 'postgresql',
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
|
@ -8,6 +8,8 @@ describe 'postgresql::server', :type => :class do
|
|||
:operatingsystemrelease => '6.0',
|
||||
:concat_basedir => tmpfilename('server'),
|
||||
:kernel => 'Linux',
|
||||
:id => 'root',
|
||||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -19,6 +21,24 @@ describe 'postgresql::server', :type => :class do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'service_ensure => running' do
|
||||
let(:params) {{ :service_ensure => 'running' }}
|
||||
it { should contain_class("postgresql::params") }
|
||||
it { should contain_class("postgresql::server") }
|
||||
it 'should validate connection' do
|
||||
should contain_postgresql__validate_db_connection('validate_service_is_running')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'service_ensure => stopped' do
|
||||
let(:params) {{ :service_ensure => 'stopped' }}
|
||||
it { should contain_class("postgresql::params") }
|
||||
it { should contain_class("postgresql::server") }
|
||||
it 'shouldnt validate connection' do
|
||||
should_not contain_postgresql__validate_db_connection('validate_service_is_running')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'manage_firewall => true' do
|
||||
let(:params) do
|
||||
{
|
||||
|
@ -49,7 +69,7 @@ describe 'postgresql::server', :type => :class do
|
|||
|
||||
it 'stop the service' do
|
||||
should contain_service('postgresqld').with({
|
||||
:ensure => false,
|
||||
:ensure => 'stopped',
|
||||
})
|
||||
end
|
||||
|
||||
|
@ -81,7 +101,7 @@ describe 'postgresql::server', :type => :class do
|
|||
|
||||
it 'should still enable the service' do
|
||||
should contain_service('postgresqld').with({
|
||||
:ensure => true,
|
||||
:ensure => 'running',
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,10 @@ describe 'postgresql::server::config_entry', :type => :define do
|
|||
:osfamily => 'RedHat',
|
||||
:operatingsystem => 'RedHat',
|
||||
:operatingsystemrelease => '6.4',
|
||||
:kernel => 'Linux',
|
||||
:concat_basedir => tmpfilename('contrib'),
|
||||
:id => 'root',
|
||||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -16,6 +20,10 @@ describe 'postgresql::server::config_entry', :type => :define do
|
|||
end
|
||||
|
||||
context "syntax check" do
|
||||
let :pre_condition do
|
||||
"class {'postgresql::server':}"
|
||||
end
|
||||
|
||||
let(:params) { { :ensure => 'present'} }
|
||||
it { should contain_postgresql__server__config_entry('config_entry') }
|
||||
end
|
||||
|
|
|
@ -6,6 +6,10 @@ describe 'postgresql::server::database_grant', :type => :define do
|
|||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
:kernel => 'Linux',
|
||||
:concat_basedir => tmpfilename('contrib'),
|
||||
:id => 'root',
|
||||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -21,6 +25,10 @@ describe 'postgresql::server::database_grant', :type => :define do
|
|||
}
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
"class {'postgresql::server':}"
|
||||
end
|
||||
|
||||
it { should contain_postgresql__server__database_grant('test') }
|
||||
it { should contain_postgresql__server__grant('database:test') }
|
||||
end
|
||||
|
|
|
@ -6,11 +6,20 @@ describe 'postgresql::server::database', :type => :define do
|
|||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
:kernel => 'Linux',
|
||||
:concat_basedir => tmpfilename('contrib'),
|
||||
:id => 'root',
|
||||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
}
|
||||
end
|
||||
let :title do
|
||||
'test'
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
"class {'postgresql::server':}"
|
||||
end
|
||||
|
||||
it { should contain_postgresql__server__database('test') }
|
||||
it { should contain_postgresql_psql("Check for existence of db 'test'") }
|
||||
end
|
||||
|
|
|
@ -6,6 +6,10 @@ describe 'postgresql::server::db', :type => :define do
|
|||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
:kernel => 'Linux',
|
||||
:concat_basedir => tmpfilename('contrib'),
|
||||
:id => 'root',
|
||||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -13,16 +17,42 @@ describe 'postgresql::server::db', :type => :define do
|
|||
'test'
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
:user => 'test',
|
||||
:password => 'test',
|
||||
:owner => 'tester',
|
||||
}
|
||||
context 'without dbname param' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:user => 'test',
|
||||
:password => 'test',
|
||||
:owner => 'tester',
|
||||
}
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
"class {'postgresql::server':}"
|
||||
end
|
||||
|
||||
it { should contain_postgresql__server__db('test') }
|
||||
it { should contain_postgresql__server__database('test').with_owner('tester') }
|
||||
it { should contain_postgresql__server__role('test') }
|
||||
it { should contain_postgresql__server__database_grant('GRANT test - ALL - test') }
|
||||
|
||||
end
|
||||
|
||||
it { should contain_postgresql__server__db('test') }
|
||||
it { should contain_postgresql__server__database('test').with_owner('tester') }
|
||||
it { should contain_postgresql__server__role('test') }
|
||||
it { should contain_postgresql__server__database_grant('GRANT test - ALL - test') }
|
||||
context 'dbname' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:dbname => 'testtest',
|
||||
:user => 'test',
|
||||
:password => 'test',
|
||||
:owner => 'tester',
|
||||
}
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
"class {'postgresql::server':}"
|
||||
end
|
||||
|
||||
it { should contain_postgresql__server__database('testtest') }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,10 @@ describe 'postgresql::server::grant', :type => :define do
|
|||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
:kernel => 'Linux',
|
||||
:concat_basedir => tmpfilename('contrib'),
|
||||
:id => 'root',
|
||||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -20,5 +24,9 @@ describe 'postgresql::server::grant', :type => :define do
|
|||
}
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
"class {'postgresql::server':}"
|
||||
end
|
||||
|
||||
it { should contain_postgresql__server__grant('test') }
|
||||
end
|
||||
|
|
|
@ -6,7 +6,10 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
|
|||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
:kernel => 'Linux',
|
||||
:concat_basedir => tmpfilename('pg_hba'),
|
||||
:id => 'root',
|
||||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
}
|
||||
end
|
||||
let :title do
|
||||
|
@ -17,6 +20,12 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
|
|||
end
|
||||
|
||||
context 'test template 1' do
|
||||
let :pre_condition do
|
||||
<<-EOS
|
||||
class { 'postgresql::server': }
|
||||
EOS
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
:type => 'host',
|
||||
|
@ -28,12 +37,19 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
|
|||
}
|
||||
end
|
||||
it do
|
||||
content = param('concat::fragment', 'pg_hba_rule_test', 'content')
|
||||
content.should =~ /host\s+all\s+all\s+1\.1\.1\.1\/24\s+md5/
|
||||
should contain_concat__fragment('pg_hba_rule_test').with({
|
||||
:content => /host\s+all\s+all\s+1\.1\.1\.1\/24\s+md5/
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
context 'test template 2' do
|
||||
let :pre_condition do
|
||||
<<-EOS
|
||||
class { 'postgresql::server': }
|
||||
EOS
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
:type => 'local',
|
||||
|
@ -44,12 +60,19 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
|
|||
}
|
||||
end
|
||||
it do
|
||||
content = param('concat::fragment', 'pg_hba_rule_test', 'content')
|
||||
content.should =~ /local\s+all\s+all\s+ident/
|
||||
should contain_concat__fragment('pg_hba_rule_test').with({
|
||||
:content => /local\s+all\s+all\s+ident/
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
context 'test template 3' do
|
||||
let :pre_condition do
|
||||
<<-EOS
|
||||
class { 'postgresql::server': }
|
||||
EOS
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
:type => 'host',
|
||||
|
@ -62,13 +85,20 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
|
|||
}
|
||||
end
|
||||
it do
|
||||
content = param('concat::fragment', 'pg_hba_rule_test', 'content')
|
||||
content.should =~ /host\s+all\s+all\s+0\.0\.0\.0\/0\s+ldap\s+foo=bar/
|
||||
should contain_concat__fragment('pg_hba_rule_test').with({
|
||||
:content => /host\s+all\s+all\s+0\.0\.0\.0\/0\s+ldap\s+foo=bar/
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
context 'validation' do
|
||||
context 'validate type test 1' do
|
||||
let :pre_condition do
|
||||
<<-EOS
|
||||
class { 'postgresql::server': }
|
||||
EOS
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
:type => 'invalid',
|
||||
|
@ -86,6 +116,12 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
|
|||
end
|
||||
|
||||
context 'validate auth_method' do
|
||||
let :pre_condition do
|
||||
<<-EOS
|
||||
class { 'postgresql::server': }
|
||||
EOS
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
:type => 'local',
|
||||
|
@ -152,8 +188,9 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
|
|||
end
|
||||
|
||||
it do
|
||||
content = param('concat::fragment', 'pg_hba_rule_test', 'content')
|
||||
content.should =~ /local\s+all\s+all\s+0\.0\.0\.0\/0\s+peer/
|
||||
should contain_concat__fragment('pg_hba_rule_test').with({
|
||||
:content => /local\s+all\s+all\s+0\.0\.0\.0\/0\s+peer/
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,6 +6,10 @@ describe 'postgresql::server::role', :type => :define do
|
|||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
:kernel => 'Linux',
|
||||
:concat_basedir => tmpfilename('contrib'),
|
||||
:id => 'root',
|
||||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -19,5 +23,9 @@ describe 'postgresql::server::role', :type => :define do
|
|||
}
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
"class {'postgresql::server':}"
|
||||
end
|
||||
|
||||
it { should contain_postgresql__server__role('test') }
|
||||
end
|
||||
|
|
|
@ -6,6 +6,10 @@ describe 'postgresql::server::table_grant', :type => :define do
|
|||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
:kernel => 'Linux',
|
||||
:concat_basedir => tmpfilename('table_grant'),
|
||||
:id => 'root',
|
||||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -22,6 +26,10 @@ describe 'postgresql::server::table_grant', :type => :define do
|
|||
}
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
"class {'postgresql::server':}"
|
||||
end
|
||||
|
||||
it { should contain_postgresql__server__table_grant('test') }
|
||||
it { should contain_postgresql__server__grant('table:test') }
|
||||
end
|
||||
|
|
|
@ -6,6 +6,10 @@ describe 'postgresql::server::tablespace', :type => :define do
|
|||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:operatingsystemrelease => '6.0',
|
||||
:kernel => 'Linux',
|
||||
:concat_basedir => tmpfilename('tablespace'),
|
||||
:id => 'root',
|
||||
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -19,5 +23,9 @@ describe 'postgresql::server::tablespace', :type => :define do
|
|||
}
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
"class {'postgresql::server':}"
|
||||
end
|
||||
|
||||
it { should contain_postgresql__server__tablespace('test') }
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ describe provider_class do
|
|||
conf_class = Puppet::Type.type(:postgresql_conf)
|
||||
provider = conf_class.provider(:parsed)
|
||||
conffile = tmpfilename('postgresql.conf')
|
||||
provider.any_instance.stubs(:target).returns conffile
|
||||
provider.any_instance.stub(:target).and_return conffile
|
||||
provider
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ require 'spec_helper'
|
|||
describe Puppet::Type.type(:postgresql_conf) do
|
||||
before do
|
||||
@provider_class = described_class.provide(:simple) { mk_resource_methods }
|
||||
@provider_class.stubs(:suitable?).returns true
|
||||
described_class.stubs(:defaultprovider).returns @provider_class
|
||||
@provider_class.stub(:suitable?).and_return true
|
||||
described_class.stub(:defaultprovider).and_return @provider_class
|
||||
end
|
||||
|
||||
describe "namevar validation" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue