non_defaults_spec.rb 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. require 'spec_helper_system'
  2. describe 'non defaults:' do
  3. context 'test installing non-default version of postgresql' do
  4. after :each do
  5. # Cleanup
  6. psql('--command="drop database postgresql_test_db" postgres')
  7. pp = <<-EOS
  8. class { "postgresql":
  9. version => "9.2",
  10. manage_package_repo => true,
  11. }->
  12. class { 'postgresql::server':
  13. ensure => absent,
  14. service_status => 'service postgresql-9.2 status',
  15. }
  16. EOS
  17. puppet_apply(pp)
  18. end
  19. it 'perform installation and create a db' do
  20. pp = <<-EOS
  21. # Configure version and manage_package_repo globally, install postgres
  22. # and then try to install a new database.
  23. class { "postgresql":
  24. version => "9.2",
  25. manage_package_repo => true,
  26. }->
  27. class { "postgresql::server": }->
  28. postgresql::db { "postgresql_test_db":
  29. user => "foo1",
  30. password => "foo1",
  31. }
  32. EOS
  33. puppet_apply(pp) do |r|
  34. # Currently puppetlabs/apt shows deprecated messages
  35. #r.stderr.should be_empty
  36. [2,6].should include(r.exit_code)
  37. end
  38. puppet_apply(pp) do |r|
  39. # Currently puppetlabs/apt shows deprecated messages
  40. #r.stderr.should be_empty
  41. # It also returns a 4
  42. [0,4].should include(r.exit_code)
  43. end
  44. psql('postgresql_test_db --command="select datname from pg_database limit 1"')
  45. end
  46. end
  47. context 'override locale and charset' do
  48. it 'perform installation with different locale and charset' do
  49. puts node.facts.inspect
  50. pending('no support for locale parameter with centos 5', :if => (node.facts['osfamily'] == 'RedHat' and node.facts['lsbmajdistrelease'] == '5'))
  51. pending('no support for initdb with debian/ubuntu', :if => (node.facts['osfamily'] == 'Debian'))
  52. # TODO: skip for ubuntu and centos 5
  53. pp = <<-EOS
  54. # Set global locale and charset option, and try installing postgres
  55. class { 'postgresql':
  56. locale => 'en_NG',
  57. charset => 'UTF8',
  58. }->
  59. class { 'postgresql::server': }
  60. EOS
  61. puppet_apply(pp) do |r|
  62. # Currently puppetlabs/apt shows deprecated messages
  63. #r.stderr.should be_empty
  64. # It also returns a 6
  65. [2,6].should include(r.exit_code)
  66. end
  67. puppet_apply(pp) do |r|
  68. # Currently puppetlabs/apt shows deprecated messages
  69. #r.stderr.should be_empty
  70. # It also returns a 2
  71. [0,4].should include(r.exit_code)
  72. end
  73. # Remove db first, if it exists for some reason
  74. shell('su postgres -c "dropdb test1"')
  75. shell('su postgres -c "createdb test1"')
  76. shell('su postgres -c \'psql -c "show lc_ctype" test1\'') do |r|
  77. r.stdout.should =~ /en_NG/
  78. end
  79. shell('su postgres -c \'psql -c "show lc_collate" test1\'') do |r|
  80. r.stdout.should =~ /en_NG/
  81. end
  82. end
  83. end
  84. end