|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +describe 'puppetdb::server::database_ini', :type => :class do |
| 4 | + context 'on a supported platform' do |
| 5 | + let(:facts) do |
| 6 | + { |
| 7 | + :osfamily => 'RedHat', |
| 8 | + :operatingsystem => 'RedHat', |
| 9 | + :operatingsystemrelease => '7.0', |
| 10 | + :fqdn => 'test.domain.local', |
| 11 | + } |
| 12 | + end |
| 13 | + |
| 14 | + it { should contain_class('puppetdb::server::database_ini') } |
| 15 | + |
| 16 | + describe 'when using default values' do |
| 17 | + it { should contain_ini_setting('puppetdb_psdatabase_username'). |
| 18 | + with( |
| 19 | + 'ensure' => 'present', |
| 20 | + 'path' => '/etc/puppetdb/conf.d/database.ini', |
| 21 | + 'section' => 'database', |
| 22 | + 'setting' => 'username', |
| 23 | + 'value' => 'puppetdb' |
| 24 | + )} |
| 25 | + it { should contain_ini_setting('puppetdb_psdatabase_password'). |
| 26 | + with( |
| 27 | + 'ensure' => 'present', |
| 28 | + 'path' => '/etc/puppetdb/conf.d/database.ini', |
| 29 | + 'section' => 'database', |
| 30 | + 'setting' => 'password', |
| 31 | + 'value' => 'puppetdb' |
| 32 | + )} |
| 33 | + it { should contain_ini_setting('puppetdb_classname'). |
| 34 | + with( |
| 35 | + 'ensure' => 'present', |
| 36 | + 'path' => '/etc/puppetdb/conf.d/database.ini', |
| 37 | + 'section' => 'database', |
| 38 | + 'setting' => 'classname', |
| 39 | + 'value' => 'org.postgresql.Driver' |
| 40 | + )} |
| 41 | + it { should contain_ini_setting('puppetdb_subprotocol'). |
| 42 | + with( |
| 43 | + 'ensure' => 'present', |
| 44 | + 'path' => '/etc/puppetdb/conf.d/database.ini', |
| 45 | + 'section' => 'database', |
| 46 | + 'setting' => 'subprotocol', |
| 47 | + 'value' => 'postgresql' |
| 48 | + )} |
| 49 | + it { should contain_ini_setting('puppetdb_subname'). |
| 50 | + with( |
| 51 | + 'ensure' => 'present', |
| 52 | + 'path' => '/etc/puppetdb/conf.d/database.ini', |
| 53 | + 'section' => 'database', |
| 54 | + 'setting' => 'subname', |
| 55 | + 'value' => '//localhost:5432/puppetdb' |
| 56 | + )} |
| 57 | + it { should contain_ini_setting('puppetdb_gc_interval'). |
| 58 | + with( |
| 59 | + 'ensure' => 'present', |
| 60 | + 'path' => '/etc/puppetdb/conf.d/database.ini', |
| 61 | + 'section' => 'database', |
| 62 | + 'setting' => 'gc-interval', |
| 63 | + 'value' => '60' |
| 64 | + )} |
| 65 | + it { should contain_ini_setting('puppetdb_node_ttl'). |
| 66 | + with( |
| 67 | + 'ensure' => 'present', |
| 68 | + 'path' => '/etc/puppetdb/conf.d/database.ini', |
| 69 | + 'section' => 'database', |
| 70 | + 'setting' => 'node-ttl', |
| 71 | + 'value' => '0s' |
| 72 | + )} |
| 73 | + it { should contain_ini_setting('puppetdb_node_purge_ttl'). |
| 74 | + with( |
| 75 | + 'ensure' => 'present', |
| 76 | + 'path' => '/etc/puppetdb/conf.d/database.ini', |
| 77 | + 'section' => 'database', |
| 78 | + 'setting' => 'node-purge-ttl', |
| 79 | + 'value' => '0s' |
| 80 | + )} |
| 81 | + it { should contain_ini_setting('puppetdb_report_ttl'). |
| 82 | + with( |
| 83 | + 'ensure' => 'present', |
| 84 | + 'path' => '/etc/puppetdb/conf.d/database.ini', |
| 85 | + 'section' => 'database', |
| 86 | + 'setting' => 'report-ttl', |
| 87 | + 'value' => '14d' |
| 88 | + )} |
| 89 | + it { should contain_ini_setting('puppetdb_log_slow_statements'). |
| 90 | + with( |
| 91 | + 'ensure' => 'present', |
| 92 | + 'path' => '/etc/puppetdb/conf.d/database.ini', |
| 93 | + 'section' => 'database', |
| 94 | + 'setting' => 'log-slow-statements', |
| 95 | + 'value' => 10 |
| 96 | + )} |
| 97 | + it { should contain_ini_setting('puppetdb_conn_max_age'). |
| 98 | + with( |
| 99 | + 'ensure' => 'present', |
| 100 | + 'path' => '/etc/puppetdb/conf.d/database.ini', |
| 101 | + 'section' => 'database', |
| 102 | + 'setting' => 'conn-max-age', |
| 103 | + 'value' => '60' |
| 104 | + )} |
| 105 | + it { should contain_ini_setting('puppetdb_conn_keep_alive'). |
| 106 | + with( |
| 107 | + 'ensure' => 'present', |
| 108 | + 'path' => '/etc/puppetdb/conf.d/database.ini', |
| 109 | + 'section' => 'database', |
| 110 | + 'setting' => 'conn-keep-alive', |
| 111 | + 'value' => '45' |
| 112 | + )} |
| 113 | + it { should contain_ini_setting('puppetdb_conn_lifetime'). |
| 114 | + with( |
| 115 | + 'ensure' => 'present', |
| 116 | + 'path' => '/etc/puppetdb/conf.d/database.ini', |
| 117 | + 'section' => 'database', |
| 118 | + 'setting' => 'conn-lifetime', |
| 119 | + 'value' => '0' |
| 120 | + )} |
| 121 | + end |
| 122 | + |
| 123 | + describe 'when overriding database_path for embedded' do |
| 124 | + let(:params) do |
| 125 | + { |
| 126 | + 'database' => 'embedded', |
| 127 | + 'database_path' => '/tmp/foo', |
| 128 | + } |
| 129 | + end |
| 130 | + it { should contain_ini_setting('puppetdb_subname'). |
| 131 | + with( |
| 132 | + 'ensure' => 'present', |
| 133 | + 'path' => '/etc/puppetdb/conf.d/database.ini', |
| 134 | + 'section' => 'database', |
| 135 | + 'setting' => 'subname', |
| 136 | + 'value' => 'file:/tmp/foo;hsqldb.tx=mvcc;sql.syntax_pgs=true' |
| 137 | + )} |
| 138 | + end |
| 139 | + end |
| 140 | +end |
0 commit comments