123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 |
- require 'spec_helper'
- describe 'puppetdb::server::database', :type => :class do
- context 'on a supported platform' do
- let(:facts) do
- {
- :osfamily => 'RedHat',
- :operatingsystem => 'RedHat',
- :operatingsystemrelease => '7.0',
- :fqdn => 'test.domain.local',
- }
- end
- it { should contain_class('puppetdb::server::database') }
- describe 'when using default values' do
- it { should contain_file('/etc/puppetlabs/puppetdb/conf.d/database.ini').
- with(
- 'ensure' => 'file',
- 'owner' => 'puppetdb',
- 'group' => 'puppetdb',
- 'mode' => '0600'
- )}
- it { should contain_ini_setting('puppetdb_psdatabase_username').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'username',
- 'value' => 'puppetdb'
- )}
- it { should contain_ini_setting('puppetdb_psdatabase_password').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'password',
- 'value' => 'puppetdb'
- )}
- it { should contain_ini_setting('puppetdb_classname').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'classname',
- 'value' => 'org.postgresql.Driver'
- )}
- it { should contain_ini_setting('puppetdb_subprotocol').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'subprotocol',
- 'value' => 'postgresql'
- )}
- it { should contain_ini_setting('puppetdb_subname').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'subname',
- 'value' => '//localhost:5432/puppetdb'
- )}
- it { should contain_ini_setting('puppetdb_gc_interval').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'gc-interval',
- 'value' => '60'
- )}
- it { should contain_ini_setting('puppetdb_node_ttl').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'node-ttl',
- 'value' => '0s'
- )}
- it { should contain_ini_setting('puppetdb_node_purge_ttl').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'node-purge-ttl',
- 'value' => '0s'
- )}
- it { should contain_ini_setting('puppetdb_report_ttl').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'report-ttl',
- 'value' => '14d'
- )}
- it { should contain_ini_setting('puppetdb_log_slow_statements').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'log-slow-statements',
- 'value' => 10
- )}
- it { should contain_ini_setting('puppetdb_conn_max_age').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'conn-max-age',
- 'value' => '60'
- )}
- it { should contain_ini_setting('puppetdb_conn_keep_alive').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'conn-keep-alive',
- 'value' => '45'
- )}
- it { should contain_ini_setting('puppetdb_conn_lifetime').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'conn-lifetime',
- 'value' => '0'
- )}
- it { should_not contain_ini_setting('puppetdb_database_max_pool_size') }
- end
- describe 'when using a legacy PuppetDB version' do
- let (:pre_condition) { 'class { "puppetdb::globals": version => "2.2.0", }' }
- it { should contain_ini_setting('puppetdb_psdatabase_username').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'username',
- 'value' => 'puppetdb'
- )}
- it { should contain_ini_setting('puppetdb_psdatabase_password').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'password',
- 'value' => 'puppetdb'
- )}
- it { should contain_ini_setting('puppetdb_classname').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'classname',
- 'value' => 'org.postgresql.Driver'
- )}
- it { should contain_ini_setting('puppetdb_subprotocol').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'subprotocol',
- 'value' => 'postgresql'
- )}
- it { should contain_ini_setting('puppetdb_subname').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'subname',
- 'value' => '//localhost:5432/puppetdb'
- )}
- it { should contain_ini_setting('puppetdb_gc_interval').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'gc-interval',
- 'value' => '60'
- )}
- it { should contain_ini_setting('puppetdb_node_ttl').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'node-ttl',
- 'value' => '0s'
- )}
- it { should contain_ini_setting('puppetdb_node_purge_ttl').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'node-purge-ttl',
- 'value' => '0s'
- )}
- it { should contain_ini_setting('puppetdb_report_ttl').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'report-ttl',
- 'value' => '14d'
- )}
- it { should contain_ini_setting('puppetdb_log_slow_statements').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'log-slow-statements',
- 'value' => 10
- )}
- it { should contain_ini_setting('puppetdb_conn_max_age').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'conn-max-age',
- 'value' => '60'
- )}
- it { should contain_ini_setting('puppetdb_conn_keep_alive').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'conn-keep-alive',
- 'value' => '45'
- )}
- it { should contain_ini_setting('puppetdb_conn_lifetime').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'conn-lifetime',
- 'value' => '0'
- )}
- it { should_not contain_ini_setting('puppetdb_database_max_pool_size') }
- end
- describe 'when overriding database_path for embedded' do
- let(:params) do
- {
- 'database' => 'embedded',
- 'database_embedded_path' => '/tmp/foo',
- }
- end
- it { should contain_ini_setting('puppetdb_subname').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'subname',
- 'value' => 'file:/tmp/foo;hsqldb.tx=mvcc;sql.syntax_pgs=true'
- )}
- end
- describe 'when setting max pool size' do
- context 'on current PuppetDB' do
- describe 'to a numeric value' do
- let(:params) do
- {
- 'database_max_pool_size' => 12345
- }
- end
- it { should contain_ini_setting('puppetdb_database_max_pool_size').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'maximum-pool-size',
- 'value' => '12345'
- )}
- end
- describe 'to absent' do
- let(:params) do
- {
- 'database_max_pool_size' => 'absent'
- }
- end
- it { should contain_ini_setting('puppetdb_database_max_pool_size').
- with(
- 'ensure' => 'absent',
- 'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'maximum-pool-size'
- )}
- end
- end
- context 'on PuppetDB 3.2' do
- let (:pre_condition) { 'class { "puppetdb::globals": version => "3.2.0", }' }
- describe 'to a numeric value' do
- let(:params) do
- {
- 'database_max_pool_size' => 12345
- }
- end
- it { should contain_ini_setting('puppetdb_database_max_pool_size').
- with(
- 'ensure' => 'present',
- 'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'partition-conn-max',
- 'value' => '12345'
- )}
- end
- describe 'to absent' do
- let(:params) do
- {
- 'database_max_pool_size' => 'absent'
- }
- end
- it { should contain_ini_setting('puppetdb_database_max_pool_size').
- with(
- 'ensure' => 'absent',
- 'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
- 'section' => 'database',
- 'setting' => 'partition-conn-max'
- )}
- end
- end
- context 'on a legacy PuppetDB version' do
- let (:pre_condition) { 'class { "puppetdb::globals": version => "2.2.0", }' }
- describe 'to a numeric value' do
- let(:params) do
- {
- 'database_max_pool_size' => 12345
- }
- end
- it { should_not contain_ini_setting('puppetdb_database_max_pool_size') }
- end
- describe 'to absent' do
- let(:params) do
- {
- 'database_max_pool_size' => 'absent'
- }
- end
- it { should_not contain_ini_setting('puppetdb_database_max_pool_size') }
- end
- end
- end
- end
- end
|