|
@@ -6,22 +6,31 @@ shared_examples :non_default_postgres do
|
|
|
include_context :pg_vm_context
|
|
|
|
|
|
# this method is required by the pg_vm shared context
|
|
|
- def install_postgres
|
|
|
- sudo_and_log(vm, 'puppet apply -e "include postgresql_tests::non_default::test_install"')
|
|
|
- end
|
|
|
-
|
|
|
- describe 'postgresql::db' do
|
|
|
- it 'should idempotently create a db that we can connect to' do
|
|
|
+ def install_postgres; end
|
|
|
|
|
|
- # A bare-minimum class to add a DB to postgres, which will be running due to ubuntu
|
|
|
- test_class = 'class {"postgresql_tests::non_default::test_db": db => "postgresql_test_db" }'
|
|
|
+ describe 'postgresql global config' do
|
|
|
+ it 'with version and manage_package_repo set, we should be able to idempotently create a db that we can connect to' do
|
|
|
+ manifest = <<-EOS
|
|
|
+ # Configure version and manage_package_repo globally, install postgres
|
|
|
+ # and then try to install a new database.
|
|
|
+ class { "postgresql":
|
|
|
+ version => "9.2",
|
|
|
+ manage_package_repo => true,
|
|
|
+ package_source => "yum.postgresql.org",
|
|
|
+ }->
|
|
|
+ class { "postgresql::server": }->
|
|
|
+ postgresql::db { "postgresql_test_db":
|
|
|
+ user => "foo1",
|
|
|
+ password => "foo1",
|
|
|
+ }
|
|
|
+ EOS
|
|
|
|
|
|
begin
|
|
|
# Run once to check for crashes
|
|
|
- sudo_and_log(vm, "puppet apply --detailed-exitcodes -e '#{test_class}'; [ $? == 2 ]")
|
|
|
+ sudo_and_log(vm, "puppet apply --detailed-exitcodes -e '#{manifest}'; [ $? = 2 ]")
|
|
|
|
|
|
# Run again to check for idempotence
|
|
|
- sudo_and_log(vm, "puppet apply --detailed-exitcodes -e '#{test_class}'")
|
|
|
+ sudo_and_log(vm, "puppet apply --detailed-exitcodes -e '#{manifest}'")
|
|
|
|
|
|
# Check that the database name is present
|
|
|
sudo_psql_and_log(vm, 'postgresql_test_db --command="select datname from pg_database limit 1"')
|
|
@@ -29,5 +38,33 @@ shared_examples :non_default_postgres do
|
|
|
sudo_psql_and_log(vm, '--command="drop database postgresql_test_db" postgres')
|
|
|
end
|
|
|
end
|
|
|
+
|
|
|
+ it 'with locale and charset, the postgres database should reflect that locale' do
|
|
|
+ pending('no support for initdb with lucid', :if => vm == :lucid)
|
|
|
+
|
|
|
+ manifest = <<-EOS
|
|
|
+ # Set global locale and charset option, and try installing postgres
|
|
|
+ class { 'postgresql':
|
|
|
+ locale => 'en_NG',
|
|
|
+ charset => 'UTF8',
|
|
|
+ }->
|
|
|
+ class { 'postgresql::server': }
|
|
|
+ EOS
|
|
|
+
|
|
|
+ # Run once to check for crashes
|
|
|
+ sudo_and_log(vm, "puppet apply --detailed-exitcodes -e '#{manifest}'; [ $? = 2 ]")
|
|
|
+ # Run again to check for idempotence
|
|
|
+ sudo_and_log(vm, "puppet apply --detailed-exitcodes -e '#{manifest}'")
|
|
|
+
|
|
|
+ # Use the command line to create the database, instead of the puppet way
|
|
|
+ # to bypass any puppet effects and make sure the default works _always_.
|
|
|
+ sudo_and_log(vm, "su postgres -c 'createdb test1'")
|
|
|
+
|
|
|
+ # Check locale of database 'postgres' to ensure initdb did the correct
|
|
|
+ # thing.
|
|
|
+ sudo_and_log(vm, 'su postgres -c \'psql -c "show lc_ctype" test1\'')
|
|
|
+ sudo_and_log(vm, 'su postgres -c \'psql -c "show lc_ctype" test1\' | grep en_NG')
|
|
|
+ sudo_and_log(vm, 'su postgres -c \'psql -c "show lc_collate" test1\' | grep en_NG')
|
|
|
+ end
|
|
|
end
|
|
|
end
|