Add acceptance tests for puppet-lodgeit.

Add acceptance tests for puppet-lodgeit module so that once the module
is applied we check if files were created, packages were installed and
services were started.

Change-Id: I8dfce2cd0feb0d2ea5746383dde18e23d5d691ff
This commit is contained in:
Bruno Tavares 2015-09-18 16:00:57 -03:00
parent 3dcfde15bb
commit d067fb3c3f
8 changed files with 120 additions and 0 deletions

3
.gitignore vendored
View File

@ -1,2 +1,5 @@
Gemfile.lock
.bundled_gems/
log/
junit/
.vagrant/

View File

@ -28,3 +28,7 @@ group :development, :test do
end
# vim:ft=ruby
group :system_tests do
gem 'beaker-rspec', :require => false
end

View File

@ -0,0 +1,31 @@
require 'spec_helper_acceptance'
describe 'puppet-lodgeit module' do
def pp_path
base_path = File.dirname(__FILE__)
File.join(base_path, 'fixtures')
end
def preconditions_puppet_module
module_path = File.join(pp_path, 'preconditions.pp')
File.read(module_path)
end
def default_puppet_module
module_path = File.join(pp_path, 'default.pp')
File.read(module_path)
end
before(:all) do
apply_manifest(preconditions_puppet_module, catch_failures: true)
end
it 'should work with no errors' do
apply_manifest(default_puppet_module, catch_failures: true)
end
it 'should be idempotent' do
apply_manifest(default_puppet_module, catch_failures: true)
apply_manifest(default_puppet_module, catch_changes: true)
end
end

View File

@ -0,0 +1,30 @@
require 'spec_helper_acceptance'
describe 'required files' do
describe file('/srv/lodgeit') do
it { should be_directory }
end
describe file('/tmp/lodgeit-main/.git') do
it { should be_directory }
end
describe file('/srv/lodgeit/acceptance/.git') do
it { should be_directory }
end
describe file('/etc/init/acceptance-paste.conf') do
it { should be_file }
its(:content) { should include 'exec python /srv/lodgeit/acceptance/manage.py runserver -h 127.0.0.1 -p 80' }
end
describe file('/srv/lodgeit/acceptance/manage.py') do
it { should be_file }
its(:content) { should include "dburi = 'mysql://acceptance:123456@localhost:3306/acceptance'" }
end
describe file('/srv/lodgeit/acceptance/lodgeit/views/layout.html') do
it { should be_file }
its(:content) { should include 'Acceptance Pastebin' }
end
end

View File

@ -0,0 +1,6 @@
class { '::lodgeit': }
lodgeit::site { 'acceptance':
db_password => '123456',
port => 8080,
}

View File

@ -0,0 +1,11 @@
class { '::mysql::server':
config_hash => { 'root_password' => '123456' },
}
mysql::db { 'acceptance':
user => 'acceptance',
password => '123456',
host => 'localhost',
grant => ['all'],
require => Class['mysql::server'],
}

View File

@ -0,0 +1,23 @@
require 'spec_helper_acceptance'
describe 'required packages' do
required_packages = [
package('python-imaging'),
package('python-jinja2'),
package('python-pybabel'),
package('python-werkzeug'),
package('python-simplejson'),
package('python-pygments'),
package('python-mysqldb'),
]
required_packages.each do |package|
describe package do
it { should be_installed }
end
end
describe package('SQLAlchemy') do
it { should be_installed.by('pip') }
end
end

View File

@ -0,0 +1,12 @@
require 'spec_helper_acceptance'
describe 'required services' do
describe service('acceptance-paste') do
it { should be_running }
it { should be_enabled }
end
describe command('curl --verbose http://localhost:8080') do
its(:stdout) { should include 'Acceptance Pastebin' }
end
end