Skip to content
This repository was archived by the owner on Feb 13, 2024. It is now read-only.

Commit df92c96

Browse files
committed
Refactor tests and add CentOS6 image
This commit does a fairly major refactor of how the spec tests are laid out. The main goal was to make it easier to run a subset of the tests--e.g., the ability to only run tests on a single OS via a simple rspec command. The test logic is now defined in some shared examples in the `support` directory. There are now spec folders for each distro, which contain some stubs to include the shared examples as well as a Vagrantfile for the particular distro. Also, the system-default postgres package tests now run successfully against the CentOS6 VM that is defined by the Vagrantfile.
1 parent bdecbe6 commit df92c96

File tree

15 files changed

+305
-290
lines changed

15 files changed

+305
-290
lines changed

manifests/initdb.pp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@
2525
$user = 'postgres'
2626
) inherits postgresql::params {
2727

28-
exec { "${initdb_path} --encoding '${encoding}' --pgdata '${datadir}'":
28+
$initdb_command = "${initdb_path} --encoding '${encoding}' --pgdata '${datadir}'"
29+
30+
exec { $initdb_command:
2931
creates => "${datadir}/PG_VERSION",
3032
user => $user,
31-
group => $group,
32-
require => Package["$postgresql::params::server_package_name"],
33+
group => $group
34+
}
35+
36+
if defined(Package["$postgresql::params::server_package_name"]) {
37+
Package["$postgresql::params::server_package_name"] ->
38+
Exec[$initdb_command]
3339
}
3440
}

spec/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Warning: these spec tests are pretty resource intensive!
2+
3+
You will need the following in order to run them:
4+
5+
* Virtualbox
6+
* vagrant
7+
* 'sahara' gem
8+
* A decent chunk of free disk space (~300MB per distro tested)
9+
* Patience :)
10+
11+
If you just run:
12+
13+
rspec ./spec
14+
15+
then, for each distro that has a Vagrantfile in the spec/distros directory,
16+
vagrant will download a base image from the web, fire up a VM, and run
17+
the suite of tests against the VM.
18+
19+
If you only want to run the tests against an individual distro, you can
20+
instead do something like:
21+
22+
rspec ./spec/distros/ubuntu_lucid_64
23+
24+
For some options that might speed up the testing process a bit during development,
25+
please see `spec/support/test_config.rb`.

spec/Vagrantfile

Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require File.expand_path(File.join(__FILE__, '../../../support/vagrant_common'))
2+
3+
Vagrant::Config.run do |config|
4+
5+
config.vm.define :centos6 do |vm_config|
6+
vm_config.vm.box = "cent63_64"
7+
vm_config.vm.box_url = "https://dl.dropbox.com/u/7225008/Vagrant/CentOS-6.3-x86_64-minimal.box"
8+
end
9+
10+
apply_common_vagrant_config(config)
11+
12+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'support/shared_examples/non_default_postgres'
2+
3+
describe "CentOS6, 64-bit: non-default postgres" do
4+
let(:vagrant_dir) { File.dirname(__FILE__) }
5+
let(:vm) { :centos6 }
6+
it_behaves_like :non_default_postgres
7+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require 'support/shared_examples/system_default_postgres'
2+
3+
describe "CentOS6, 64-bit: default system postgres" do
4+
let(:vagrant_dir) { File.dirname(__FILE__) }
5+
let(:vm) { :centos6 }
6+
let(:service_name) { 'postgresql' }
7+
it_behaves_like :system_default_postgres
8+
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require File.expand_path(File.join(__FILE__, '../../../support/vagrant_common'))
2+
3+
Vagrant::Config.run do |config|
4+
5+
config.vm.define :lucid do |vm_config|
6+
# Test on 64 bit lucid
7+
vm_config.vm.box = "lucid64"
8+
vm_config.vm.box_url = "http://files.vagrantup.com/lucid64.box"
9+
end
10+
11+
apply_common_vagrant_config(config)
12+
13+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'support/shared_examples/non_default_postgres'
2+
3+
describe "Ubuntu Lucid, 64-bit: non-default postgres" do
4+
let(:vagrant_dir) { File.dirname(__FILE__) }
5+
let(:vm) { :lucid }
6+
it_behaves_like :non_default_postgres
7+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require 'support/shared_examples/system_default_postgres'
2+
3+
describe "Ubuntu Lucid, 64-bit: default system postgres" do
4+
let(:vagrant_dir) { File.dirname(__FILE__) }
5+
let(:vm) { :lucid }
6+
let(:service_name) { 'postgresql-8.4' }
7+
it_behaves_like :system_default_postgres
8+
end

spec/manifests/test_initdb.pp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818

1919
class postgresql_tests::test_initdb {
2020

21-
include postgresql::server
21+
include postgresql::initdb
2222

23-
class { "postgresql::initdb":
24-
require => Class['postgresql::server']
25-
}
2623
}

0 commit comments

Comments
 (0)