read_database_ini_spec.rb 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. require 'spec_helper'
  2. describe 'puppetdb::server::read_database', :type => :class do
  3. context 'on a supported platform' do
  4. let(:facts) do
  5. {
  6. :osfamily => 'RedHat',
  7. :operatingsystem => 'RedHat',
  8. :operatingsystemrelease => '7.0',
  9. :fqdn => 'test.domain.local',
  10. }
  11. end
  12. it { should contain_class('puppetdb::server::read_database') }
  13. describe 'when using default values' do
  14. it { should contain_file('/etc/puppetlabs/puppetdb/conf.d/read_database.ini').with('ensure' => 'absent') }
  15. end
  16. describe 'when using minimum working values' do
  17. let(:params) do
  18. {
  19. 'database_host' => 'puppetdb'
  20. }
  21. end
  22. it { should contain_file('/etc/puppetlabs/puppetdb/conf.d/read_database.ini').
  23. with(
  24. 'ensure' => 'file',
  25. 'owner' => 'puppetdb',
  26. 'group' => 'puppetdb',
  27. 'mode' => '0600'
  28. )}
  29. it { should contain_ini_setting('puppetdb_read_database_username').
  30. with(
  31. 'ensure' => 'present',
  32. 'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
  33. 'section' => 'read-database',
  34. 'setting' => 'username',
  35. 'value' => 'puppetdb'
  36. )}
  37. it { should contain_ini_setting('puppetdb_read_database_password').
  38. with(
  39. 'ensure' => 'present',
  40. 'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
  41. 'section' => 'read-database',
  42. 'setting' => 'password',
  43. 'value' => 'puppetdb'
  44. )}
  45. it { should contain_ini_setting('puppetdb_read_classname').
  46. with(
  47. 'ensure' => 'present',
  48. 'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
  49. 'section' => 'read-database',
  50. 'setting' => 'classname',
  51. 'value' => 'org.postgresql.Driver'
  52. )}
  53. it { should contain_ini_setting('puppetdb_read_subprotocol').
  54. with(
  55. 'ensure' => 'present',
  56. 'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
  57. 'section' => 'read-database',
  58. 'setting' => 'subprotocol',
  59. 'value' => 'postgresql'
  60. )}
  61. it { should contain_ini_setting('puppetdb_read_subname').
  62. with(
  63. 'ensure' => 'present',
  64. 'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
  65. 'section' => 'read-database',
  66. 'setting' => 'subname',
  67. 'value' => '//puppetdb:5432/puppetdb'
  68. )}
  69. it { should contain_ini_setting('puppetdb_read_log_slow_statements').
  70. with(
  71. 'ensure' => 'present',
  72. 'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
  73. 'section' => 'read-database',
  74. 'setting' => 'log-slow-statements',
  75. 'value' => 10
  76. )}
  77. it { should contain_ini_setting('puppetdb_read_conn_max_age').
  78. with(
  79. 'ensure' => 'present',
  80. 'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
  81. 'section' => 'read-database',
  82. 'setting' => 'conn-max-age',
  83. 'value' => '60'
  84. )}
  85. it { should contain_ini_setting('puppetdb_read_conn_keep_alive').
  86. with(
  87. 'ensure' => 'present',
  88. 'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
  89. 'section' => 'read-database',
  90. 'setting' => 'conn-keep-alive',
  91. 'value' => '45'
  92. )}
  93. it { should contain_ini_setting('puppetdb_read_conn_lifetime').
  94. with(
  95. 'ensure' => 'present',
  96. 'path' => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
  97. 'section' => 'read-database',
  98. 'setting' => 'conn-lifetime',
  99. 'value' => '0'
  100. )}
  101. end
  102. end
  103. end